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