Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / tests / Doctrine / Tests / ORM / Mapping / YamlMappingDriverTest.php
1 <?php
2
3 namespace Doctrine\Tests\ORM\Mapping;
4
5 use Doctrine\ORM\Mapping\ClassMetadata,
6     Doctrine\ORM\Mapping\Driver\XmlDriver,
7     Doctrine\ORM\Mapping\Driver\YamlDriver;
8
9 require_once __DIR__ . '/../../TestInit.php';
10
11 class YamlMappingDriverTest extends AbstractMappingDriverTest
12 {
13     protected function _loadDriver()
14     {
15         if (!class_exists('Symfony\Component\Yaml\Yaml', true)) {
16             $this->markTestSkipped('Please install Symfony YAML Component into the include path of your PHP installation.');
17         }
18
19         return new YamlDriver(__DIR__ . DIRECTORY_SEPARATOR . 'yaml');
20     }
21
22     /**
23      * @group DDC-671
24      *
25      * Entities for this test are in AbstractMappingDriverTest
26      */
27     public function testJoinTablesWithMappedSuperclassForYamlDriver()
28     {
29         $yamlDriver = $this->_loadDriver();
30         $yamlDriver->getLocator()->addPaths(array(__DIR__ . DIRECTORY_SEPARATOR . 'yaml'));
31
32         $em = $this->_getTestEntityManager();
33         $em->getConfiguration()->setMetadataDriverImpl($yamlDriver);
34         $factory = new \Doctrine\ORM\Mapping\ClassMetadataFactory();
35         $factory->setEntityManager($em);
36
37         $classPage = new ClassMetadata('Doctrine\Tests\Models\DirectoryTree\File');
38         $classPage = $factory->getMetadataFor('Doctrine\Tests\Models\DirectoryTree\File');
39         $this->assertEquals('Doctrine\Tests\Models\DirectoryTree\File', $classPage->associationMappings['parentDirectory']['sourceEntity']);
40
41         $classDirectory = new ClassMetadata('Doctrine\Tests\Models\DirectoryTree\Directory');
42         $classDirectory = $factory->getMetadataFor('Doctrine\Tests\Models\DirectoryTree\Directory');
43         $this->assertEquals('Doctrine\Tests\Models\DirectoryTree\Directory', $classDirectory->associationMappings['parentDirectory']['sourceEntity']);
44     }
45
46     /**
47      * @group DDC-1468
48      *
49      * @expectedException Doctrine\Common\Persistence\Mapping\MappingException
50      * @expectedExceptionMessage Invalid mapping file 'Doctrine.Tests.Models.Generic.SerializationModel.dcm.yml' for class 'Doctrine\Tests\Models\Generic\SerializationModel'.
51      */
52     public function testInvalidMappingFileException()
53     {
54         $this->createClassMetadata('Doctrine\Tests\Models\Generic\SerializationModel');
55     }
56
57 }