2011-01-27 14:16:11 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of the Symfony package.
|
|
|
|
*
|
2011-03-06 11:40:06 +00:00
|
|
|
* (c) Fabien Potencier <fabien@symfony.com>
|
2011-01-27 14:16:11 +00:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2011-11-08 07:22:51 +00:00
|
|
|
namespace Symfony\Tests\Bridge\Doctrine;
|
2011-02-22 00:06:06 +00:00
|
|
|
|
2011-06-08 07:36:14 +01:00
|
|
|
use Symfony\Bridge\Doctrine\Annotations\IndexedReader;
|
2011-05-19 21:46:34 +01:00
|
|
|
use Doctrine\Common\Annotations\AnnotationReader;
|
|
|
|
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
|
2011-01-27 14:16:11 +00:00
|
|
|
use Doctrine\ORM\EntityManager;
|
|
|
|
|
2011-04-22 16:41:21 +01:00
|
|
|
abstract class DoctrineOrmTestCase extends \PHPUnit_Framework_TestCase
|
2011-01-27 14:16:11 +00:00
|
|
|
{
|
|
|
|
protected function setUp()
|
|
|
|
{
|
|
|
|
if (!class_exists('Doctrine\\Common\\Version')) {
|
|
|
|
$this->markTestSkipped('Doctrine is not available.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return EntityManager
|
|
|
|
*/
|
2012-07-09 13:38:28 +01:00
|
|
|
public static function createTestEntityManager($paths = array())
|
2011-01-27 14:16:11 +00:00
|
|
|
{
|
2011-11-14 17:37:25 +00:00
|
|
|
if (!class_exists('PDO') || !in_array('sqlite', \PDO::getAvailableDrivers())) {
|
|
|
|
self::markTestSkipped('This test requires SQLite support in your environment');
|
|
|
|
}
|
2011-01-27 14:16:11 +00:00
|
|
|
$config = new \Doctrine\ORM\Configuration();
|
|
|
|
$config->setAutoGenerateProxyClasses(true);
|
|
|
|
$config->setProxyDir(\sys_get_temp_dir());
|
|
|
|
$config->setProxyNamespace('SymfonyTests\Doctrine');
|
2011-05-19 22:15:41 +01:00
|
|
|
$config->setMetadataDriverImpl(new AnnotationDriver(new IndexedReader(new AnnotationReader())));
|
2011-01-27 14:16:11 +00:00
|
|
|
$config->setQueryCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
|
|
|
|
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
|
|
|
|
|
|
|
|
$params = array(
|
|
|
|
'driver' => 'pdo_sqlite',
|
|
|
|
'memory' => true,
|
|
|
|
);
|
|
|
|
|
|
|
|
return EntityManager::create($params, $config);
|
|
|
|
}
|
|
|
|
}
|