2009-01-22 22:38:10 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Doctrine\Tests;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Base testcase class for all ORM testcases.
|
|
|
|
*/
|
|
|
|
class OrmTestCase extends DoctrineTestCase
|
|
|
|
{
|
2009-02-04 21:03:05 +03:00
|
|
|
/** The metadata cache that is shared between all ORM tests (except functional tests). */
|
|
|
|
private static $_metadataCacheImpl = null;
|
|
|
|
|
2009-01-22 22:38:10 +03:00
|
|
|
/**
|
|
|
|
* Creates an EntityManager for testing purposes.
|
|
|
|
*
|
|
|
|
* @return Doctrine\ORM\EntityManager
|
|
|
|
*/
|
2009-02-17 15:25:03 +03:00
|
|
|
protected function _getTestEntityManager($conn = null, $conf = null, $eventManager = null)
|
2009-02-17 05:43:40 +03:00
|
|
|
{
|
2009-01-22 22:38:10 +03:00
|
|
|
$config = new \Doctrine\ORM\Configuration();
|
2009-02-04 21:03:05 +03:00
|
|
|
$config->setMetadataCacheImpl(self::getSharedMetadataCacheImpl());
|
2009-01-22 22:38:10 +03:00
|
|
|
$eventManager = new \Doctrine\Common\EventManager();
|
2009-02-17 15:25:03 +03:00
|
|
|
if (is_null($conn)) {
|
|
|
|
$conn = array(
|
2009-01-22 22:38:10 +03:00
|
|
|
'driverClass' => 'Doctrine\Tests\Mocks\DriverMock',
|
|
|
|
'wrapperClass' => 'Doctrine\Tests\Mocks\ConnectionMock',
|
|
|
|
'user' => 'john',
|
|
|
|
'password' => 'wayne'
|
2009-02-17 15:25:03 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
return \Doctrine\ORM\EntityManager::create($conn, $config, $eventManager);
|
2009-01-22 22:38:10 +03:00
|
|
|
}
|
2009-02-04 21:03:05 +03:00
|
|
|
|
|
|
|
private static function getSharedMetadataCacheImpl()
|
|
|
|
{
|
|
|
|
if (is_null(self::$_metadataCacheImpl)) {
|
|
|
|
self::$_metadataCacheImpl = new \Doctrine\ORM\Cache\ArrayCache;
|
|
|
|
}
|
|
|
|
return self::$_metadataCacheImpl;
|
|
|
|
}
|
2009-01-22 22:38:10 +03:00
|
|
|
}
|