Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / tests / Doctrine / Tests / ORM / Functional / SchemaValidatorTest.php
1 <?php
2
3 namespace Doctrine\Tests\ORM\Functional;
4
5 use Doctrine\ORM\Tools\SchemaValidator;
6
7 /**
8  * Test the validity of all modelsets
9  *
10  * @group DDC-1601
11  */
12 class SchemaValidatorTest extends \Doctrine\Tests\OrmFunctionalTestCase
13 {
14     static public function dataValidateModelSets()
15     {
16         $modelSets = array();
17         foreach (self::$_modelSets as $modelSet => $classes) {
18             if ($modelSet == "customtype") {
19                 continue;
20             }
21             $modelSets[] = array($modelSet);
22         }
23         return $modelSets;
24     }
25
26     /**
27      * @dataProvider dataValidateModelSets
28      */
29     public function testValidateModelSets($modelSet)
30     {
31         $validator = new SchemaValidator($this->_em);
32
33         $classes = array();
34         foreach (self::$_modelSets[$modelSet] as $className) {
35             $classes[] = $this->_em->getClassMetadata($className);
36         }
37
38         foreach ($classes as $class) {
39             $ce = $validator->validateClass($class);
40
41             foreach ($ce as $key => $error) {
42                 if (strpos($error, "must be private or protected. Public fields may break lazy-loading.") !== false) {
43                     unset($ce[$key]);
44                 }
45             }
46
47             $this->assertEquals(0, count($ce), "Invalid Modelset: " . $modelSet . " class " . $class->name . ": ". implode("\n", $ce));
48         }
49     }
50 }