Skip to content

Commit

Permalink
Test json format on failed platform reqs (#11477)
Browse files Browse the repository at this point in the history
* test: Adds case for json format arg

* test: A failed platofrm requirement

* chore: style fix

* chore: removes redundant test case
  • Loading branch information
theoboldalex committed May 28, 2023
1 parent c45b403 commit 7528c86
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions tests/Composer/Test/Command/CheckPlatformReqsCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,55 @@ public static function caseProvider(): \Generator
"Checking platform requirements using the lock file\next-barbaz 2.3.4.5 success \next-foobar 2.3.4 success"
];
}

public function testFailedPlatformRequirement(): void
{
$this->initTempComposer([
'require' => [
'ext-foobar' => '^0.3'
],
'require-dev' => [
'ext-barbaz' => '^2.3'
]
]);

$packages = [
self::getPackage('ext-foobar', '2.3.4'),
];
$devPackages = [
self::getPackage('ext-barbaz', '2.3.4.5')
];

$this->createInstalledJson($packages, $devPackages);

$this->createComposerLock($packages, $devPackages);

$appTester = $this->getApplicationTester();
$appTester->run(['command' => 'check-platform-reqs', '--format' => 'json']);

$expected = 'Checking platform requirements for packages in the vendor dir
[
{
"name": "ext-barbaz",
"version": "2.3.4.5",
"status": "success",
"failed_requirement": null,
"provider": null
},
{
"name": "ext-foobar",
"version": "2.3.4",
"status": "failed",
"failed_requirement": {
"source": "__root__",
"type": "requires",
"target": "ext-foobar",
"constraint": "^0.3"
},
"provider": null
}
]';

$this->assertSame(trim($expected), trim($appTester->getDisplay(true)));
}
}

0 comments on commit 7528c86

Please sign in to comment.