Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / common / tests / Doctrine / Tests / Common / Persistence / Mapping / DefaultFileLocatorTest.php
1 <?php
2
3 namespace Doctrine\Tests\Common\Persistence\Mapping;
4
5 use Doctrine\Tests\DoctrineTestCase;
6 use Doctrine\Common\Persistence\Mapping\Driver\DefaultFileLocator;
7
8 class DefaultFileLocatorTest extends DoctrineTestCase
9 {
10     public function testGetPaths()
11     {
12         $path = __DIR__ . "/_files";
13
14         $locator = new DefaultFileLocator(array($path));
15         $this->assertEquals(array($path), $locator->getPaths());
16
17         $locator = new DefaultFileLocator($path);
18         $this->assertEquals(array($path), $locator->getPaths());
19     }
20
21     public function testGetFileExtension()
22     {
23         $locator = new DefaultFileLocator(array(), ".yml");
24         $this->assertEquals(".yml", $locator->getFileExtension());
25         $locator->setFileExtension(".xml");
26         $this->assertEquals(".xml", $locator->getFileExtension());
27     }
28
29     public function testUniquePaths()
30     {
31         $path = __DIR__ . "/_files";
32
33         $locator = new DefaultFileLocator(array($path, $path));
34         $this->assertEquals(array($path), $locator->getPaths());
35     }
36
37     public function testFindMappingFile()
38     {
39         $path = __DIR__ . "/_files";
40
41         $locator = new DefaultFileLocator(array($path), ".yml");
42
43         $this->assertEquals(__DIR__ . '/_files' . DIRECTORY_SEPARATOR . 'stdClass.yml', $locator->findMappingFile('stdClass'));
44     }
45
46     public function testFindMappingFileNotFound()
47     {
48         $path = __DIR__ . "/_files";
49
50         $locator = new DefaultFileLocator(array($path), ".yml");
51
52         $this->setExpectedException(
53             'Doctrine\Common\Persistence\Mapping\MappingException',
54             "No mapping file found named 'stdClass2.yml' for class 'stdClass2'"
55         );
56         $locator->findMappingFile('stdClass2');
57     }
58
59     public function testGetAllClassNames()
60     {
61         $path = __DIR__ . "/_files";
62
63         $locator = new DefaultFileLocator(array($path), ".yml");
64         $classes = $locator->getAllClassNames(null);
65         sort($classes);
66
67         $this->assertEquals(array('global', 'stdClass'), $classes);
68         $this->assertEquals(array('stdClass'), $locator->getAllClassNames("global"));
69     }
70
71     public function testGetAllClassNamesNonMatchingFileExtension()
72     {
73         $path = __DIR__ . "/_files";
74
75         $locator = new DefaultFileLocator(array($path), ".xml");
76         $this->assertEquals(array(), $locator->getAllClassNames("global"));
77     }
78
79     public function testFileExists()
80     {
81         $path = __DIR__ . "/_files";
82
83         $locator = new DefaultFileLocator(array($path), ".yml");
84
85         $this->assertTrue($locator->fileExists("stdClass"));
86         $this->assertFalse($locator->fileExists("stdClass2"));
87         $this->assertTrue($locator->fileExists("global"));
88         $this->assertFalse($locator->fileExists("global2"));
89     }
90 }