SchemaValidatorTest.php 1.3 KB

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