Fix main test expectations and ticket key matching
This commit is contained in:
@@ -6,6 +6,9 @@ class TicketKeyReferenceMatcher
|
||||
{
|
||||
public function matches(string $ticketKey, string $referenceName): bool
|
||||
{
|
||||
return str_contains(mb_strtolower($referenceName), mb_strtolower($ticketKey));
|
||||
return preg_match(
|
||||
'/^'.preg_quote($ticketKey, '/').'(?=$|[-_\/])/i',
|
||||
$referenceName,
|
||||
) === 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ class TicketKeyReferenceMatcherTest extends TestCase
|
||||
use RefreshDatabase;
|
||||
|
||||
/**
|
||||
* Ensure a reference must start with the exact ticket key.
|
||||
* Ensure a reference must start with the ticket key, regardless of case.
|
||||
*/
|
||||
public function test_matcher_accepts_exact_ticket_key_prefixes(): void
|
||||
public function test_matcher_accepts_ticket_key_prefixes_case_insensitively(): void
|
||||
{
|
||||
$matcher = app(TicketKeyReferenceMatcher::class);
|
||||
|
||||
@@ -21,10 +21,11 @@ class TicketKeyReferenceMatcherTest extends TestCase
|
||||
$this->assertTrue($matcher->matches('CORE-1', 'CORE-1/fix-oauth'));
|
||||
$this->assertTrue($matcher->matches('CORE-1', 'CORE-1_hotfix'));
|
||||
$this->assertTrue($matcher->matches('CORE-1', 'CORE-1'));
|
||||
$this->assertTrue($matcher->matches('CORE-1', 'core-1-login-form'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure similar ticket keys are not treated as matches.
|
||||
* Ensure similar or embedded ticket keys are not treated as matches.
|
||||
*/
|
||||
public function test_matcher_rejects_other_ticket_prefixes(): void
|
||||
{
|
||||
@@ -32,6 +33,5 @@ class TicketKeyReferenceMatcherTest extends TestCase
|
||||
|
||||
$this->assertFalse($matcher->matches('CORE-1', 'CORE-10-login-form'));
|
||||
$this->assertFalse($matcher->matches('CORE-1', 'MY-CORE-1-login-form'));
|
||||
$this->assertFalse($matcher->matches('CORE-1', 'core-1-login-form'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ class BoardColumnTest extends TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure board columns expose tickets ordered by descending sequence number.
|
||||
* Ensure board columns expose tickets ordered by ascending sequence number.
|
||||
*/
|
||||
public function test_board_column_tickets_are_returned_in_sequence_order(): void
|
||||
{
|
||||
@@ -98,7 +98,7 @@ class BoardColumnTest extends TestCase
|
||||
]);
|
||||
|
||||
$this->assertSame(
|
||||
['CORE-2', 'CORE-1'],
|
||||
['CORE-1', 'CORE-2'],
|
||||
$boardColumn->fresh()->tickets->pluck('ticket_key')->all(),
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user