2011-06-18 03:05:30 +04:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Doctrine\Tests\ORM\Tools;
|
|
|
|
|
|
|
|
use Doctrine\ORM\Tools\Setup;
|
2011-08-30 22:40:26 +04:00
|
|
|
use Doctrine\Common\Cache\ArrayCache;
|
2011-06-18 03:05:30 +04:00
|
|
|
|
|
|
|
require_once __DIR__ . '/../../TestInit.php';
|
|
|
|
|
|
|
|
class SetupTest extends \Doctrine\Tests\OrmTestCase
|
|
|
|
{
|
|
|
|
private $originalAutoloaderCount;
|
|
|
|
private $originalIncludePath;
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2011-06-18 03:05:30 +04:00
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
if (strpos(\Doctrine\ORM\Version::VERSION, "DEV") === false) {
|
|
|
|
$this->markTestSkipped("Test only runs in a dev-installation from Github");
|
|
|
|
}
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2011-06-18 03:05:30 +04:00
|
|
|
$this->originalAutoloaderCount = count(spl_autoload_functions());
|
|
|
|
$this->originalIncludePath = get_include_path();
|
|
|
|
}
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2011-06-18 03:05:30 +04:00
|
|
|
public function testGitAutoload()
|
2011-12-20 01:56:19 +04:00
|
|
|
{
|
2011-06-18 03:05:30 +04:00
|
|
|
Setup::registerAutoloadGit(__DIR__ . "/../../../../../");
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2011-06-18 03:05:30 +04:00
|
|
|
$this->assertEquals($this->originalAutoloaderCount + 4, count(spl_autoload_functions()));
|
|
|
|
}
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2011-06-18 03:05:30 +04:00
|
|
|
public function testPEARAutoload()
|
|
|
|
{
|
|
|
|
set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . "/../../../../../lib/vendor/doctrine-common/lib");
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2011-06-18 03:05:30 +04:00
|
|
|
Setup::registerAutoloadPEAR();
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2011-06-18 03:05:30 +04:00
|
|
|
$this->assertEquals($this->originalAutoloaderCount + 2, count(spl_autoload_functions()));
|
|
|
|
}
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2011-06-18 03:05:30 +04:00
|
|
|
public function testDirectoryAutoload()
|
|
|
|
{
|
|
|
|
Setup::registerAutoloadDirectory(__DIR__ . "/../../../../../lib/vendor/doctrine-common/lib");
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2011-06-18 03:05:30 +04:00
|
|
|
$this->assertEquals($this->originalAutoloaderCount + 2, count(spl_autoload_functions()));
|
|
|
|
}
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2011-06-18 03:05:30 +04:00
|
|
|
public function testAnnotationConfiguration()
|
|
|
|
{
|
2011-06-18 10:47:10 +04:00
|
|
|
$config = Setup::createAnnotationMetadataConfiguration(array(), true);
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2011-06-18 10:47:10 +04:00
|
|
|
$this->assertInstanceOf('Doctrine\ORM\Configuration', $config);
|
|
|
|
$this->assertEquals(sys_get_temp_dir(), $config->getProxyDir());
|
|
|
|
$this->assertEquals('DoctrineProxies', $config->getProxyNamespace());
|
|
|
|
$this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\AnnotationDriver', $config->getMetadataDriverImpl());
|
|
|
|
}
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2011-06-18 10:47:10 +04:00
|
|
|
public function testXMLConfiguration()
|
|
|
|
{
|
|
|
|
$config = Setup::createXMLMetadataConfiguration(array(), true);
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2011-06-18 10:47:10 +04:00
|
|
|
$this->assertInstanceOf('Doctrine\ORM\Configuration', $config);
|
|
|
|
$this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\XmlDriver', $config->getMetadataDriverImpl());
|
|
|
|
}
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2011-06-18 10:47:10 +04:00
|
|
|
public function testYAMLConfiguration()
|
|
|
|
{
|
|
|
|
$config = Setup::createYAMLMetadataConfiguration(array(), true);
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2011-06-18 10:47:10 +04:00
|
|
|
$this->assertInstanceOf('Doctrine\ORM\Configuration', $config);
|
|
|
|
$this->assertInstanceOf('Doctrine\ORM\Mapping\Driver\YamlDriver', $config->getMetadataDriverImpl());
|
2011-06-18 03:05:30 +04:00
|
|
|
}
|
2011-08-30 22:40:26 +04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @group DDC-1350
|
|
|
|
*/
|
|
|
|
public function testConfigureProxyDir()
|
|
|
|
{
|
|
|
|
$config = Setup::createAnnotationMetadataConfiguration(array(), true, "/foo");
|
|
|
|
$this->assertEquals('/foo', $config->getProxyDir());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @group DDC-1350
|
|
|
|
*/
|
|
|
|
public function testConfigureCache()
|
|
|
|
{
|
|
|
|
$cache = new ArrayCache();
|
|
|
|
$config = Setup::createAnnotationMetadataConfiguration(array(), true, null, $cache);
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2011-08-30 22:40:26 +04:00
|
|
|
$this->assertSame($cache, $config->getResultCacheImpl());
|
|
|
|
$this->assertSame($cache, $config->getMetadataCacheImpl());
|
|
|
|
$this->assertSame($cache, $config->getQueryCacheImpl());
|
|
|
|
}
|
2011-12-20 01:56:19 +04:00
|
|
|
|
2011-06-18 03:05:30 +04:00
|
|
|
public function tearDown()
|
|
|
|
{
|
|
|
|
set_include_path($this->originalIncludePath);
|
|
|
|
$loaders = spl_autoload_functions();
|
|
|
|
for ($i = 0; $i < count($loaders); $i++) {
|
|
|
|
if ($i > $this->originalAutoloaderCount+1) {
|
|
|
|
spl_autoload_unregister($loaders[$i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|