Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions generator/src/GenerateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +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');
}

require_once __DIR__.'/../../lib/Exceptions/SafeExceptionInterface.php';
foreach ($files as $file) {
require($file);
}

// Finally, let's edit the composer.json file
$output->writeln('Editing composer.json');
ComposerJsonEditor::editComposerFileForGeneration(\array_values($modules));
Expand Down
42 changes: 42 additions & 0 deletions tests/GeneratedFilesTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

declare(strict_types=1);

use PHPUnit\Framework\TestCase;

final class GeneratedFilesTest extends TestCase
{
public function testRequireModules(): 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_once($file);
}
}

public function testRequireExceptions(): void
{
self::expectNotToPerformAssertions();

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

public function testRequireExceptionInterface(): void
{
self::expectNotToPerformAssertions();

require_once __DIR__.'/../lib/Exceptions/SafeExceptionInterface.php';
}
}