Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / orm / tests / Doctrine / Tests / ORM / Tools / SetupTest.php
1 <?php
2
3 namespace Doctrine\Tests\ORM\Tools;
4
5 use Doctrine\ORM\Tools\Setup;
6 use Doctrine\Common\Cache\ArrayCache;
7
8 require_once __DIR__ . '/../../TestInit.php';
9
10 class SetupTest extends \Doctrine\Tests\OrmTestCase
11 {
12     private $originalAutoloaderCount;
13     private $originalIncludePath;
14
15     public function setUp()
16     {
17         if (strpos(\Doctrine\ORM\Version::VERSION, "DEV") === false) {
18             $this->markTestSkipped("Test only runs in a dev-installation from Github");
19         }
20
21         $this->originalAutoloaderCount = count(spl_autoload_functions());
22         $this->originalIncludePath = get_include_path();
23     }
24
25     public function tearDown()
26     {
27         if ( ! $this->originalIncludePath) {
28             return;
29         }
30
31         set_include_path($this->originalIncludePath);
32         $loaders = spl_autoload_functions();
33         for ($i = 0; $i < count($loaders); $i++) {
34             if ($i > $this->originalAutoloaderCount+1) {
35                 spl_autoload_unregister($loaders[$i]);
36             }
37         }
38     }
39
40     public function testGitAutoload()
41     {
42         Setup::registerAutoloadGit(__DIR__ . "/../../../../../");
43
44         $this->assertEquals($this->originalAutoloaderCount + 4, count(spl_autoload_functions()));
45     }
46
47     public function testPEARAutoload()
48     {
49         set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . "/../../../../../lib/vendor/doctrine-common/lib");
50
51         Setup::registerAutoloadPEAR();
52
53         $this->assertEquals($this->originalAutoloaderCount + 2, count(spl_autoload_functions()));
54     }
55
56     public function testDirectoryAutoload()
57     {
58         Setup::registerAutoloadDirectory(__DIR__ . "/../../../../../lib/vendor/doctrine-common/lib");
59
60         $this->assertEquals($this->originalAutoloaderCount + 2, count(spl_autoload_functions()));
61     }
62
63     public function testAnnotationConfiguration()
64     {
65         $config = Setup::createAnnotationMetadataConfiguration(array(), true);
66
67         $this->assertInstanceOf('Doctrine\ORM\Configuration', $config);
68         $this->assertEquals(sys_get_temp_dir(), $config->getProxyDir());
69         $this->assertEquals('DoctrineProxies', $config->getProxyNamespace());
70         $this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\AnnotationDriver', $config->getMetadataDriverImpl());
71     }
72
73     public function testXMLConfiguration()
74     {
75         $config = Setup::createXMLMetadataConfiguration(array(), true);
76
77         $this->assertInstanceOf('Doctrine\ORM\Configuration', $config);
78         $this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\XmlDriver', $config->getMetadataDriverImpl());
79     }
80
81     public function testYAMLConfiguration()
82     {
83         $config = Setup::createYAMLMetadataConfiguration(array(), true);
84
85         $this->assertInstanceOf('Doctrine\ORM\Configuration', $config);
86         $this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\YamlDriver', $config->getMetadataDriverImpl());
87     }
88
89     /**
90      * @group DDC-1350
91      */
92     public function testConfigureProxyDir()
93     {
94         $config = Setup::createAnnotationMetadataConfiguration(array(), true, "/foo");
95         $this->assertEquals('/foo', $config->getProxyDir());
96     }
97
98     /**
99      * @group DDC-1350
100      */
101     public function testConfigureCache()
102     {
103         $cache = new ArrayCache();
104         $config = Setup::createAnnotationMetadataConfiguration(array(), true, null, $cache);
105
106         $this->assertSame($cache, $config->getResultCacheImpl());
107         $this->assertSame($cache, $config->getMetadataCacheImpl());
108         $this->assertSame($cache, $config->getQueryCacheImpl());
109     }
110 }