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
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"symfony/http-kernel": "^3.4|^4.0"
},
"require-dev": {
"allocine/twigcs": "^3.0",
"friendsofphp/php-cs-fixer": "^2.8",
"symfony/phpunit-bridge": "^3.4|^4.0",
"symfony/process": "^3.4|^4.0"
Expand Down
22 changes: 19 additions & 3 deletions src/Test/MakerTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ protected function executeMakerCommand(MakerTestDetails $testDetails)
throw new \Exception(sprintf('Running maker command failed: "%s" "%s"', $makerProcess->getOutput(), $makerProcess->getErrorOutput()));
}

$files = $this->getGeneratedPhpFilesFromOutputText($makerProcess->getOutput());
$files = $this->getGeneratedFilesFromOutputText($makerProcess->getOutput(), '.php');
foreach ($files as $file) {
$process = $this->createProcess(
sprintf(
Expand All @@ -100,6 +100,19 @@ protected function executeMakerCommand(MakerTestDetails $testDetails)
$this->assertTrue($process->isSuccessful(), sprintf('File "%s" has a php-cs problem: %s', $file, $process->getOutput()));
}

$files = $this->getGeneratedFilesFromOutputText($makerProcess->getOutput(), '.twig');
foreach ($files as $file) {
$process = $this->createProcess(
sprintf(
'php vendor/bin/twigcs lint %s',
self::$currentRootDir.'/'.$file
),
__DIR__.'/../../'
);
$process->run();
$this->assertTrue($process->isSuccessful(), sprintf('File "%s" has a php-cs problem: %s', $file, $process->getOutput()));
}

foreach ($testDetails->getPostMakeCommands() as $postCommand) {
$process = $this->createProcess($postCommand, self::$currentRootDir);
$process->run();
Expand Down Expand Up @@ -154,7 +167,7 @@ private function buildFlexProject()
$this->runProcess($process);
}

private function getGeneratedPhpFilesFromOutputText($output)
private function getGeneratedFilesFromOutputText($output, $fileExtension)
{
$files = [];
foreach (explode("\n", $output) as $line) {
Expand All @@ -163,7 +176,10 @@ private function getGeneratedPhpFilesFromOutputText($output)
}

list(, $filename) = explode(':', $line);
$files[] = trim($filename);
$filename = trim($filename);
if ($fileExtension === substr($filename, (-1 * strlen($fileExtension)))) {
$files[] = trim($filename);
}
}

return $files;
Expand Down