From 7528c86e58884f5676d5851d52cd94c67372d609 Mon Sep 17 00:00:00 2001 From: Alex Theobold <44616505+theoboldalex@users.noreply.github.com> Date: Sun, 28 May 2023 14:15:21 +0100 Subject: [PATCH] Test json format on failed platform reqs (#11477) * test: Adds case for json format arg * test: A failed platofrm requirement * chore: style fix * chore: removes redundant test case --- .../Command/CheckPlatformReqsCommandTest.php | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/tests/Composer/Test/Command/CheckPlatformReqsCommandTest.php b/tests/Composer/Test/Command/CheckPlatformReqsCommandTest.php index 931701d70..9f9d56df6 100644 --- a/tests/Composer/Test/Command/CheckPlatformReqsCommandTest.php +++ b/tests/Composer/Test/Command/CheckPlatformReqsCommandTest.php @@ -88,4 +88,55 @@ ext-foobar 2.3.4 success' "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))); + } }