Skip to content

Instantly share code, notes, and snippets.

@enumag
Created March 1, 2019 08:10
Show Gist options
  • Save enumag/8d5679ed335cf0e2a8c418781bff228c to your computer and use it in GitHub Desktop.
Save enumag/8d5679ed335cf0e2a8c418781bff228c to your computer and use it in GitHub Desktop.
Doctrine schema tests
<?php declare(strict_types = 1);
namespace App\Core\Tests\Infrastructure\Doctrine;
use App\Library\Test\KernelTestCase;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput;
final class MigrationsUpToDateTest extends KernelTestCase
{
public function testNoMissingMigration(): void
{
$this->useEnvironment('test');
$application = new Application($this->getKernel());
$application->setAutoExit(false);
$input = new ArrayInput(
[
'command' => 'doctrine:schema:update',
'--no-interaction' => true,
]
);
$output = new BufferedOutput();
$errorCode = $application->run($input, $output);
self::assertSame(0, $errorCode, $output->fetch());
}
}
<?php declare(strict_types = 1);
namespace App\Core\Tests\Infrastructure\Doctrine;
use App\Library\Test\KernelTestCase;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput;
final class ValidSchemaTest extends KernelTestCase
{
public function testSchemaIsValid(): void
{
$this->useEnvironment('test');
$application = new Application($this->getKernel());
$application->setAutoExit(false);
$input = new ArrayInput(
[
'command' => 'doctrine:schema:validate',
'--no-interaction' => true,
]
);
$output = new BufferedOutput();
$errorCode = $application->run($input, $output);
self::assertSame(0, $errorCode, $output->fetch());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment