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
|
|
|
|
*/
|
|
|
|
protected function _getTestEntityManager($conf = null, $eventManager = null) {
|
|
|
|
$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();
|
|
|
|
$connectionOptions = array(
|
|
|
|
'driverClass' => 'Doctrine\Tests\Mocks\DriverMock',
|
|
|
|
'wrapperClass' => 'Doctrine\Tests\Mocks\ConnectionMock',
|
|
|
|
'user' => 'john',
|
|
|
|
'password' => 'wayne'
|
|
|
|
);
|
|
|
|
return \Doctrine\ORM\EntityManager::create($connectionOptions, 'mockEM', $config, $eventManager);
|
|
|
|
}
|
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
|
|
|
}
|