Skip to content

Instantly share code, notes, and snippets.

@Ocramius
Created April 22, 2013 11:48
Show Gist options
  • Save Ocramius/5434209 to your computer and use it in GitHub Desktop.
Save Ocramius/5434209 to your computer and use it in GitHub Desktop.
Functional test case for schema validation in Doctrine2 ORM
<?php
namespace Ocramius\CMS\ContentTest;
use Ocramius\CMS\ContentTest\Util\ServiceManagerFactory;
use Doctrine\ORM\Tools\SchemaTool;
use Doctrine\ORM\Tools\SchemaValidator;
use PHPUnit_Framework_TestCase;
/**
* Tests to verify that the schema is valid
*
* @author Marco Pivetta <[email protected]>
*/
class SchemaValidityFunctionalTest extends PHPUnit_Framework_TestCase
{
public function testCanGenerateValidDatabase()
{
$serviceManager = ServiceManagerFactory::getServiceManager();
/* @var $entityManager \Doctrine\ORM\EntityManager */
$entityManager = $serviceManager->get('Doctrine\ORM\EntityManager');
$schemaTool = new SchemaTool($entityManager);
$validator = new SchemaValidator($entityManager);
$this->assertSame(array(), $validator->validateMapping(), 'Schema has valid mappings');
$schemaTool->createSchema($entityManager->getMetadataFactory()->getAllMetadata());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment