Align matcher tests with substring matching
linter / quality (pull_request) Successful in 1m18s
tests / ci (8.4) (pull_request) Successful in 1m33s

This commit is contained in:
2026-06-03 09:25:11 +00:00
parent 5af4c6a9df
commit dbfbc26866
3 changed files with 14 additions and 12 deletions
@@ -11,9 +11,9 @@ class TicketKeyReferenceMatcherTest extends TestCase
use RefreshDatabase;
/**
* Ensure a reference must start with the ticket key, regardless of case.
* Ensure a reference matches when it contains the ticket key, regardless of case.
*/
public function test_matcher_accepts_ticket_key_prefixes_case_insensitively(): void
public function test_matcher_accepts_references_containing_the_ticket_key_case_insensitively(): void
{
$matcher = app(TicketKeyReferenceMatcher::class);
@@ -22,16 +22,18 @@ class TicketKeyReferenceMatcherTest extends TestCase
$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'));
$this->assertTrue($matcher->matches('CORE-1', 'CORE-10-login-form'));
$this->assertTrue($matcher->matches('CORE-1', 'MY-CORE-1-login-form'));
}
/**
* Ensure similar or embedded ticket keys are not treated as matches.
* Ensure references without the ticket key are not treated as matches.
*/
public function test_matcher_rejects_other_ticket_prefixes(): void
public function test_matcher_rejects_references_without_the_ticket_key(): void
{
$matcher = app(TicketKeyReferenceMatcher::class);
$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-2-login-form'));
$this->assertFalse($matcher->matches('CORE-1', 'feature/auth-cleanup'));
}
}
@@ -338,18 +338,21 @@ class ProjectTicketControllerTest extends TestCase
->component('projects/Ticket')
->where('suggestedBranchName', 'core-1-branch-detail-test')
->where('repositoryBranches.0.repository_connection.repository_full_name', 'core-team/kanbangit')
->has('repositoryBranches.0.branches', 2)
->has('repositoryBranches.0.branches', 3)
->where('repositoryBranches.0.branches.0.name', 'CORE-1-login-form')
->where('repositoryBranches.0.branches.1.name', 'CORE-1/fix-oauth')
->where('repositoryBranches.0.branches.2.name', 'CORE-10-should-not-match')
->where('repositoryBranches.1.repository_connection.repository_full_name', 'other-team/mobile')
->where('repositoryBranches.1.repository_connection.has_personal_access', false)
->where('repositoryBranches.1.branches', [])
->has('repositoryPullRequests.0.pull_requests', 2)
->has('repositoryPullRequests.0.pull_requests', 3)
->where('repositoryPullRequests.0.pull_requests.0.number', '42')
->where('repositoryPullRequests.0.pull_requests.0.title', 'Add login form')
->where('repositoryPullRequests.0.pull_requests.0.status', 'open')
->where('repositoryPullRequests.0.pull_requests.1.number', '43')
->where('repositoryPullRequests.0.pull_requests.1.status', 'merged')
->where('repositoryPullRequests.0.pull_requests.2.number', '99')
->where('repositoryPullRequests.0.pull_requests.2.status', 'open')
->where('repositoryPullRequests.1.repository_connection.repository_full_name', 'other-team/mobile')
->where('repositoryPullRequests.1.repository_connection.has_personal_access', false)
->where('repositoryPullRequests.1.pull_requests', []),