Skip to content

Commit

Permalink
[generator] make import tests into a unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
shish committed Jan 19, 2025
1 parent 0dddc07 commit d3483b4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 10 deletions.
10 changes: 0 additions & 10 deletions generator/src/GenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int

$this->runCsFix($output);

// Let's require the generated file to check there is no error.
$files = \glob(__DIR__.'/../../generated/*.php');
if ($files === false) {
throw new \RuntimeException('Failed to require the generated file');
}

foreach ($files as $file) {
require($file);
}

$files = \glob(__DIR__.'/../../generated/Exceptions/*.php');
if ($files === false) {
throw new \RuntimeException('Failed to require the generated exception file');
Expand Down
22 changes: 22 additions & 0 deletions tests/GeneratedFilesTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

declare(strict_types=1);

use PHPUnit\Framework\TestCase;

final class GeneratedFilesTest extends TestCase
{
public function testImport(): void
{
self::expectNotToPerformAssertions();

$files = \glob(__DIR__.'/../generated/*.php');
if ($files === false) {
throw new \RuntimeException('Failed to require the generated file');
}

foreach ($files as $file) {
require($file);
}
}
}

0 comments on commit d3483b4

Please sign in to comment.