diff --git a/tests/Console/CodegenCommandTest.php b/tests/Console/CodegenCommandTest.php index 5122f88..b04cf6e 100644 --- a/tests/Console/CodegenCommandTest.php +++ b/tests/Console/CodegenCommandTest.php @@ -6,11 +6,26 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Tester\CommandTester; +use Symfony\Component\Filesystem\Filesystem; use XGraphQL\Codegen\Console\CodegenCommand; use XGraphQL\Codegen\Generator; class CodegenCommandTest extends TestCase { + private const DESTINATION_PATH = __DIR__ . '/../generated'; + + private const SOURCE_PATH = __DIR__ . '/../fixtures/source_dir'; + + protected function setUp(): void + { + $fileSystem = new Filesystem(); + + $fileSystem->remove(self::DESTINATION_PATH); + $fileSystem->mkdir(self::DESTINATION_PATH); + + parent::setUp(); + } + public function testRunCommand() { $command = new CodegenCommand(); @@ -18,8 +33,8 @@ public function testRunCommand() [ 'test' => new Generator( '', - __DIR__ . '/../fixtures/source_dir', - __DIR__ . '/../generated', + self::SOURCE_PATH, + self::DESTINATION_PATH, ) ] ); diff --git a/tests/Console/InitConfigCommandTest.php b/tests/Console/InitConfigCommandTest.php index 2c4b172..b8cce3b 100644 --- a/tests/Console/InitConfigCommandTest.php +++ b/tests/Console/InitConfigCommandTest.php @@ -6,6 +6,7 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Console\Tester\CommandTester; +use Symfony\Component\Filesystem\Filesystem; use XGraphQL\Codegen\Console\InitConfigCommand; class InitConfigCommandTest extends TestCase @@ -14,10 +15,12 @@ class InitConfigCommandTest extends TestCase protected function setUp(): void { - parent::setUp(); + $fileSystem = new Filesystem(); + + $fileSystem->remove(self::CONFIG_FILE); + $fileSystem->mkdir(dirname(self::CONFIG_FILE)); - @mkdir(__DIR__ . '../generated'); - @unlink(self::CONFIG_FILE); + parent::setUp(); } public function testInitConfig(): void