~ubuntu-branches/ubuntu/utopic/php-doctrine-common/utopic

« back to all changes in this revision

Viewing changes to tests/Doctrine/Tests/Common/Persistence/Mapping/SymfonyFileLocatorTest.php

  • Committer: Package Import Robot
  • Author(s): David Prévot
  • Date: 2014-06-15 11:26:00 UTC
  • mfrom: (2.1.1 experimental)
  • Revision ID: package-import@ubuntu.com-20140615112600-sg4mgpwq9sfg4mre
Tags: 2.4.2-2
* Upload to unstable
* No tests if DEB_BUILD_OPTIONS contains nocheck

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
}