From 27dbbb509e934887887936c827e2ae4037d99698 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Sat, 25 Mar 2023 19:34:43 +0100 Subject: [PATCH 1/2] test: Add tests for the Pharaoh class --- tests/Pharaoh/PharaohTest.php | 60 +++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 tests/Pharaoh/PharaohTest.php diff --git a/tests/Pharaoh/PharaohTest.php b/tests/Pharaoh/PharaohTest.php new file mode 100644 index 000000000..1b6c28384 --- /dev/null +++ b/tests/Pharaoh/PharaohTest.php @@ -0,0 +1,60 @@ + + * Théo Fidry + * + * This source file is subject to the MIT license that is bundled + * with this source code in the file LICENSE. + */ + +namespace KevinGH\RequirementChecker\Pharaoh; + +use KevinGH\Box\Pharaoh\Pharaoh; +use PHPUnit\Framework\TestCase; + +/** + * @covers \KevinGH\Box\Pharaoh\Pharaoh + * + * @internal + */ +final class PharaohTest extends TestCase +{ + private const FIXTURES_DIR = __DIR__.'/../../fixtures/info'; + + public function test_it_can_be_instantiated(): void + { + $file = self::FIXTURES_DIR.'/simple-phar.phar'; + $pharInfo = new Pharaoh($file); + + self::assertSame($file, $pharInfo->getFile()); + self::assertSame('simple-phar.phar', $pharInfo->getFileName()); + } + + public function test_it_cleans_itself_up_upon_destruction(): void + { + $pharInfo = new Pharaoh(self::FIXTURES_DIR.'/simple-phar.phar'); + + $tmp = $pharInfo->getTmp(); + + self::assertDirectoryExists($tmp); + + unset($pharInfo); + + self::assertDirectoryDoesNotExist($tmp); + } + + public function test_it_can_create_two_instances_of_the_same_phar(): void + { + $file = self::FIXTURES_DIR.'/simple-phar.phar'; + + $pharInfoA = new Pharaoh($file); + $pharInfoB = new Pharaoh($file); + + self::assertNotSame($pharInfoA->getPhar(), $pharInfoB->getPhar()); + } +} From dda7e318f686c8fc0663485392197c9f7eee29a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20FIDRY?= Date: Sat, 25 Mar 2023 22:13:39 +0100 Subject: [PATCH 2/2] fix --- tests/Pharaoh/PharaohTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/Pharaoh/PharaohTest.php b/tests/Pharaoh/PharaohTest.php index 1b6c28384..ee989c2e9 100644 --- a/tests/Pharaoh/PharaohTest.php +++ b/tests/Pharaoh/PharaohTest.php @@ -15,6 +15,7 @@ namespace KevinGH\RequirementChecker\Pharaoh; use KevinGH\Box\Pharaoh\Pharaoh; +use KevinGH\Box\Test\RequiresPharReadonlyOff; use PHPUnit\Framework\TestCase; /** @@ -24,8 +25,15 @@ */ final class PharaohTest extends TestCase { + use RequiresPharReadonlyOff; + private const FIXTURES_DIR = __DIR__.'/../../fixtures/info'; + protected function setUp(): void + { + $this->markAsSkippedIfPharReadonlyIsOn(); + } + public function test_it_can_be_instantiated(): void { $file = self::FIXTURES_DIR.'/simple-phar.phar';