Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add missing cast for the sort function of the requirement builder #1335

Merged
merged 1 commit into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/RequirementChecker/RequirementsBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ static function (array $sources): array {
usort(
$sources,
static fn (array $sourceTypePairA, array $sourceTypePairB) => strcmp(
$sourceTypePairA[0],
(string) $sourceTypePairA[0],
(string) $sourceTypePairB[0],
),
);
Expand Down
31 changes: 31 additions & 0 deletions tests/RequirementChecker/RequirementsBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,40 @@ public function test_it_can_build_requirements_from_provided_extensions(): void
new Extension('http'),
'package2',
);
$this->builder->addProvidedExtension(
new Extension('http'),
null,
);

$expectedBuiltRequirements = new Requirements([]);
$expectedAllRequirements = new Requirements([
Requirement::forProvidedExtension('http', null),
Requirement::forProvidedExtension('http', 'package1'),
Requirement::forProvidedExtension('http', 'package2'),
]);

$this->assertBuiltRequirementsEquals($expectedBuiltRequirements);
$this->assertAllRequirementsEquals($expectedAllRequirements);
}

public function test_it_can_build_requirements_from_provided_extensions_sorting_edge_case(): void
{
$this->builder->addProvidedExtension(
new Extension('http'),
null,
);
$this->builder->addProvidedExtension(
new Extension('http'),
'package1',
);
$this->builder->addProvidedExtension(
new Extension('http'),
'package2',
);

$expectedBuiltRequirements = new Requirements([]);
$expectedAllRequirements = new Requirements([
Requirement::forProvidedExtension('http', null),
Requirement::forProvidedExtension('http', 'package1'),
Requirement::forProvidedExtension('http', 'package2'),
]);
Expand Down
Loading