Skip to content

Commit

Permalink
chore: decoupling tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vuongxuongminh committed Mar 27, 2024
1 parent ef8bdd7 commit 6010f88
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
19 changes: 17 additions & 2 deletions tests/Console/CodegenCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,35 @@

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();
$command->setGenerators(
[
'test' => new Generator(
'',
__DIR__ . '/../fixtures/source_dir',
__DIR__ . '/../generated',
self::SOURCE_PATH,
self::DESTINATION_PATH,
)
]
);
Expand Down
9 changes: 6 additions & 3 deletions tests/Console/InitConfigCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 6010f88

Please sign in to comment.