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
2 changes: 2 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ ARG DEBIAN_FRONTEND=noninteractive
ARG XDEBUG_MODE=coverage
RUN apt update -y && apt install -y git composer php-cli php-dom php-curl php-xdebug vim
WORKDIR /app
RUN git config --global --add safe.directory /app/generator/doc/doc-en/en && \
git config --global --add safe.directory /app/generator/doc/doc-en/doc-base
CMD cd /app/generator/doc && ./update.sh && \
cd /app && composer install && \
cd /app/generator && composer install && php ./safe.php generate
1 change: 1 addition & 0 deletions .devcontainer/build.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/bin/sh
set -eu
cd $(dirname $0)/../
docker run --rm -v ${PWD}:/app $(docker build -q -f .devcontainer/Dockerfile .)
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';
}
}
Loading