Created
June 25, 2019 16:01
-
-
Save tarlepp/c98f3ce78784d908f944072be84b0cf4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
declare(strict_types = 1); | |
namespace App\Tests\Integration; | |
use Doctrine\ORM\Tools\SchemaValidator; | |
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; | |
use function array_walk; | |
use function implode; | |
class SchemaTest extends KernelTestCase | |
{ | |
private $validator; | |
public function testThatMappingsAreValid(): void | |
{ | |
$errors = $this->validator->validateMapping(); | |
$messages = []; | |
$formatter = static function ($errors, $className) use (&$messages) { | |
$messages[] = $className . ': ' . implode(', ', $errors); | |
}; | |
array_walk($errors, $formatter); | |
static::assertEmpty($errors, implode("\n", $messages)); | |
unset($errors, $messages); | |
} | |
public function testThatSchemaInSyncWithMetadata(): void | |
{ | |
static::assertTrue( | |
$this->validator->schemaInSyncWithMetadata(), | |
'The database schema is not in sync with the current mapping file.' | |
); | |
} | |
protected function setUp(): void | |
{ | |
parent::setUp(); | |
static::bootKernel(); | |
$em = static::$kernel->getContainer() | |
->get('doctrine') | |
->getManager(); | |
$this->validator = new SchemaValidator($em); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment