YamlMappingDriverTest.php 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Doctrine\Tests\ORM\Mapping;
  3. use Doctrine\ORM\Mapping\ClassMetadata,
  4. Doctrine\ORM\Mapping\Driver\XmlDriver,
  5. Doctrine\ORM\Mapping\Driver\YamlDriver;
  6. require_once __DIR__ . '/../../TestInit.php';
  7. class YamlMappingDriverTest extends AbstractMappingDriverTest
  8. {
  9. protected function _loadDriver()
  10. {
  11. if (!class_exists('Symfony\Component\Yaml\Yaml', true)) {
  12. $this->markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.');
  13. }
  14. return new YamlDriver(__DIR__ . DIRECTORY_SEPARATOR . 'yaml');
  15. }
  16. /**
  17. * @group DDC-671
  18. *
  19. * Entities for this test are in AbstractMappingDriverTest
  20. */
  21. public function testJoinTablesWithMappedSuperclassForYamlDriver()
  22. {
  23. $yamlDriver = $this->_loadDriver();
  24. $yamlDriver->addPaths(array(__DIR__ . DIRECTORY_SEPARATOR . 'yaml'));
  25. $em = $this->_getTestEntityManager();
  26. $em->getConfiguration()->setMetadataDriverImpl($yamlDriver);
  27. $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory();
  28. $factory->setEntityManager($em);
  29. $classPage = new ClassMetadata('Doctrine\Tests\Models\DirectoryTree\File');
  30. $classPage = $factory->getMetadataFor('Doctrine\Tests\Models\DirectoryTree\File');
  31. $this->assertEquals('Doctrine\Tests\Models\DirectoryTree\File', $classPage->associationMappings['parentDirectory']['sourceEntity']);
  32. $classDirectory = new ClassMetadata('Doctrine\Tests\Models\DirectoryTree\Directory');
  33. $classDirectory = $factory->getMetadataFor('Doctrine\Tests\Models\DirectoryTree\Directory');
  34. $this->assertEquals('Doctrine\Tests\Models\DirectoryTree\Directory', $classDirectory->associationMappings['parentDirectory']['sourceEntity']);
  35. }
  36. }