2012-01-15 11:27:28 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Doctrine\Tests\ORM\Functional;
|
|
|
|
|
|
|
|
use Doctrine\ORM\Tools\SchemaValidator;
|
2016-05-11 02:41:26 +07:00
|
|
|
use Doctrine\Tests\OrmFunctionalTestCase;
|
2012-01-15 11:27:28 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Test the validity of all modelsets
|
|
|
|
*
|
|
|
|
* @group DDC-1601
|
|
|
|
*/
|
2016-05-11 02:41:26 +07:00
|
|
|
class SchemaValidatorTest extends OrmFunctionalTestCase
|
2012-01-15 11:27:28 +01:00
|
|
|
{
|
|
|
|
static public function dataValidateModelSets()
|
|
|
|
{
|
2016-12-07 23:33:41 +01:00
|
|
|
$modelSets = [];
|
2012-01-15 11:27:28 +01:00
|
|
|
foreach (self::$_modelSets as $modelSet => $classes) {
|
|
|
|
if ($modelSet == "customtype") {
|
|
|
|
continue;
|
|
|
|
}
|
2016-12-07 23:33:41 +01:00
|
|
|
$modelSets[] = [$modelSet];
|
2012-01-15 11:27:28 +01:00
|
|
|
}
|
|
|
|
return $modelSets;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @dataProvider dataValidateModelSets
|
|
|
|
*/
|
|
|
|
public function testValidateModelSets($modelSet)
|
|
|
|
{
|
|
|
|
$validator = new SchemaValidator($this->_em);
|
|
|
|
|
2016-12-07 23:33:41 +01:00
|
|
|
$classes = [];
|
2012-01-15 11:27:28 +01:00
|
|
|
foreach (self::$_modelSets[$modelSet] as $className) {
|
|
|
|
$classes[] = $this->_em->getClassMetadata($className);
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($classes as $class) {
|
|
|
|
$ce = $validator->validateClass($class);
|
|
|
|
|
|
|
|
$this->assertEquals(0, count($ce), "Invalid Modelset: " . $modelSet . " class " . $class->name . ": ". implode("\n", $ce));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|