Skip to content

Commit

Permalink
#109 Tests for OnMoon\OpenApiServerBundle\CodeGenerator\PhpParserGene…
Browse files Browse the repository at this point in the history
…rators\DtoCodeGenerator
  • Loading branch information
Alex2k committed Aug 27, 2020
1 parent cdcf41e commit 532474b
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@
use PhpParser\BuilderFactory;
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\TestCase;
use Safe\Exceptions\PcreException;

use function array_key_exists;
use function Safe\preg_replace;
use function ucfirst;

use const PHP_EOL;

/**
* @covers \OnMoon\OpenApiServerBundle\CodeGenerator\PhpParserGenerators\DtoCodeGenerator
*/
Expand Down Expand Up @@ -517,6 +521,8 @@ public function generateProvider(): array
/**
* @param mixed[] $payload
*
* @throws PcreException
*
* @dataProvider generateProvider
*/
public function testGenerate(array $payload, string $expected): void
Expand All @@ -533,7 +539,10 @@ public function testGenerate(array $payload, string $expected): void
$generatedFileDefinition = $codeGenerator->generate($definition);

Assert::assertSame($definition, $generatedFileDefinition->getClass());
Assert::assertSame($expected, $generatedFileDefinition->getFileContents());
Assert::assertSame(
preg_replace('/\r\n|\r|\n/', PHP_EOL, $expected),
$generatedFileDefinition->getFileContents()
);
}

// /**
Expand Down

0 comments on commit 532474b

Please sign in to comment.