From c0fc5b57e6be7621850e7c4b1b93d1cae4a1ed5f Mon Sep 17 00:00:00 2001 From: Florent Morselli Date: Sun, 17 Dec 2023 18:24:51 +0100 Subject: [PATCH] Add tearDown method and asserts to CommandTest A tearDown method that removes 'samples' directory from cache was introduced in CommandTest. Two assertions were also added to the test case to verify existence of 'my-pwa.json' file and 'data' directory within 'samples'. These changes enhance test cleanup and verifications. --- tests/Functional/CommandTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/Functional/CommandTest.php b/tests/Functional/CommandTest.php index f3cd282..5ec6a29 100644 --- a/tests/Functional/CommandTest.php +++ b/tests/Functional/CommandTest.php @@ -14,12 +14,22 @@ */ final class CommandTest extends KernelTestCase { + protected function tearDown(): void + { + $filesystem = self::getContainer()->get('filesystem'); + $filesystem->remove(sprintf('%s/samples', self::$kernel->getCacheDir())); + + parent::tearDown(); + } + #[Test] public static function theCommandCanGenerateTheManifestAndIcons(): void { // Given $kernel = self::bootKernel(); $application = new Application($kernel); + $filesystem = self::getContainer()->get('filesystem'); + $filesystem->remove(sprintf('%s/samples', $kernel->getCacheDir())); $command = $application->find('pwa:build'); $commandTester = new CommandTester($command); @@ -36,5 +46,7 @@ public static function theCommandCanGenerateTheManifestAndIcons(): void $commandTester->assertCommandIsSuccessful(); $output = $commandTester->getDisplay(); static::assertStringContainsString('PWA Manifest Generator', $output); + static::assertFileExists(sprintf('%s/samples/my-pwa.json', $kernel->getCacheDir())); + static::assertDirectoryExists(sprintf('%s/samples/data', $kernel->getCacheDir())); } }