3
namespace Doctrine\Tests\Common\Persistence\Mapping;
5
use Doctrine\Tests\DoctrineTestCase;
6
use Doctrine\Common\Persistence\Mapping\Driver\SymfonyFileLocator;
8
class SymfonyFileLocatorTest extends DoctrineTestCase
10
public function testGetPaths()
12
$path = __DIR__ . "/_files";
15
$locator = new SymfonyFileLocator(array($path => $prefix));
16
$this->assertEquals(array($path), $locator->getPaths());
18
$locator = new SymfonyFileLocator(array($path => $prefix));
19
$this->assertEquals(array($path), $locator->getPaths());
22
public function testGetPrefixes()
24
$path = __DIR__ . "/_files";
27
$locator = new SymfonyFileLocator(array($path => $prefix));
28
$this->assertEquals(array($path => $prefix), $locator->getNamespacePrefixes());
31
public function testGetFileExtension()
33
$locator = new SymfonyFileLocator(array(), ".yml");
34
$this->assertEquals(".yml", $locator->getFileExtension());
35
$locator->setFileExtension(".xml");
36
$this->assertEquals(".xml", $locator->getFileExtension());
39
public function testFileExists()
41
$path = __DIR__ . "/_files";
44
$locator = new SymfonyFileLocator(array($path => $prefix), ".yml");
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"));
52
public function testGetAllClassNames()
54
$path = __DIR__ . "/_files";
57
$locator = new SymfonyFileLocator(array($path => $prefix), ".yml");
58
$classes = $locator->getAllClassNames(null);
61
$this->assertEquals(array("Foo\\global", "Foo\\stdClass"), $classes);
62
$this->assertEquals(array("Foo\\stdClass"), $locator->getAllClassNames("global"));
65
public function testFindMappingFile()
67
$path = __DIR__ . "/_files";
70
$locator = new SymfonyFileLocator(array($path => $prefix), ".yml");
72
$this->assertEquals(__DIR__ . "/_files/stdClass.yml", $locator->findMappingFile("Foo\\stdClass"));
75
public function testFindMappingFileNotFound()
77
$path = __DIR__ . "/_files";
80
$locator = new SymfonyFileLocator(array($path => $prefix), ".yml");
82
$this->setExpectedException(
83
"Doctrine\Common\Persistence\Mapping\MappingException",
84
"No mapping file found named '".__DIR__."/_files/stdClass2.yml' for class 'Foo\stdClass2'."
86
$locator->findMappingFile("Foo\\stdClass2");