1
0
mirror of synced 2025-01-18 14:31:40 +03:00

Code optimizations. Fixed unused argument in OrmTestCase as referred in DDC-766.

This commit is contained in:
Guilherme Blanco 2011-10-16 02:10:59 -02:00
parent 33bcf7ad6f
commit eeba947ea7
2 changed files with 27 additions and 26 deletions

View File

@ -1328,18 +1328,18 @@ class Parser
// We need to check if we are in a IdentificationVariable or SingleValuedPathExpression // We need to check if we are in a IdentificationVariable or SingleValuedPathExpression
$glimpse = $this->_lexer->glimpse(); $glimpse = $this->_lexer->glimpse();
if ($glimpse['type'] != Lexer::T_DOT) { if ($glimpse['type'] == Lexer::T_DOT) {
$token = $this->_lexer->lookahead; return $this->SingleValuedPathExpression();
$identVariable = $this->IdentificationVariable(); }
$token = $this->_lexer->lookahead;
$identVariable = $this->IdentificationVariable();
if (!isset($this->_queryComponents[$identVariable])) { if (!isset($this->_queryComponents[$identVariable])) {
$this->semanticalError('Cannot group by undefined identification variable.'); $this->semanticalError('Cannot group by undefined identification variable.');
}
return $identVariable;
} }
return $this->SingleValuedPathExpression(); return $identVariable;
} }
/** /**
@ -1354,12 +1354,9 @@ class Parser
// We need to check if we are in a ResultVariable or StateFieldPathExpression // We need to check if we are in a ResultVariable or StateFieldPathExpression
$glimpse = $this->_lexer->glimpse(); $glimpse = $this->_lexer->glimpse();
if ($glimpse['type'] != Lexer::T_DOT) { $expr = ($glimpse['type'] != Lexer::T_DOT)
$token = $this->_lexer->lookahead; ? $this->ResultVariable()
$expr = $this->ResultVariable(); : $this->SingleValuedPathExpression();
} else {
$expr = $this->SingleValuedPathExpression();
}
$item = new AST\OrderByItem($expr); $item = new AST\OrderByItem($expr);

View File

@ -11,6 +11,7 @@ abstract class OrmTestCase extends DoctrineTestCase
{ {
/** The metadata cache that is shared between all ORM tests (except functional tests). */ /** The metadata cache that is shared between all ORM tests (except functional tests). */
private static $_metadataCacheImpl = null; private static $_metadataCacheImpl = null;
/** The query cache that is shared between all ORM tests (except functional tests). */ /** The query cache that is shared between all ORM tests (except functional tests). */
private static $_queryCacheImpl = null; private static $_queryCacheImpl = null;
@ -66,30 +67,31 @@ abstract class OrmTestCase extends DoctrineTestCase
*/ */
protected function _getTestEntityManager($conn = null, $conf = null, $eventManager = null, $withSharedMetadata = true) protected function _getTestEntityManager($conn = null, $conf = null, $eventManager = null, $withSharedMetadata = true)
{ {
$metadataCache = $withSharedMetadata
? self::getSharedMetadataCacheImpl()
: new \Doctrine\Common\Cache\ArrayCache;
$config = new \Doctrine\ORM\Configuration(); $config = new \Doctrine\ORM\Configuration();
if($withSharedMetadata) {
$config->setMetadataCacheImpl(self::getSharedMetadataCacheImpl()); $config->setMetadataCacheImpl($metadataCache);
} else {
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache);
}
$config->setMetadataDriverImpl($config->newDefaultAnnotationDriver()); $config->setMetadataDriverImpl($config->newDefaultAnnotationDriver());
$config->setQueryCacheImpl(self::getSharedQueryCacheImpl()); $config->setQueryCacheImpl(self::getSharedQueryCacheImpl());
$config->setProxyDir(__DIR__ . '/Proxies'); $config->setProxyDir(__DIR__ . '/Proxies');
$config->setProxyNamespace('Doctrine\Tests\Proxies'); $config->setProxyNamespace('Doctrine\Tests\Proxies');
$eventManager = new \Doctrine\Common\EventManager();
if ($conn === null) { if ($conn === null) {
$conn = array( $conn = array(
'driverClass' => 'Doctrine\Tests\Mocks\DriverMock', 'driverClass' => 'Doctrine\Tests\Mocks\DriverMock',
'wrapperClass' => 'Doctrine\Tests\Mocks\ConnectionMock', 'wrapperClass' => 'Doctrine\Tests\Mocks\ConnectionMock',
'user' => 'john', 'user' => 'john',
'password' => 'wayne' 'password' => 'wayne'
); );
} }
if (is_array($conn)) { if (is_array($conn)) {
$conn = \Doctrine\DBAL\DriverManager::getConnection($conn, $config, $eventManager); $conn = \Doctrine\DBAL\DriverManager::getConnection($conn, $config, $eventManager);
} }
return \Doctrine\Tests\Mocks\EntityManagerMock::create($conn, $config, $eventManager); return \Doctrine\Tests\Mocks\EntityManagerMock::create($conn, $config, $eventManager);
} }
@ -98,6 +100,7 @@ abstract class OrmTestCase extends DoctrineTestCase
if (self::$_metadataCacheImpl === null) { if (self::$_metadataCacheImpl === null) {
self::$_metadataCacheImpl = new \Doctrine\Common\Cache\ArrayCache; self::$_metadataCacheImpl = new \Doctrine\Common\Cache\ArrayCache;
} }
return self::$_metadataCacheImpl; return self::$_metadataCacheImpl;
} }
@ -106,6 +109,7 @@ abstract class OrmTestCase extends DoctrineTestCase
if (self::$_queryCacheImpl === null) { if (self::$_queryCacheImpl === null) {
self::$_queryCacheImpl = new \Doctrine\Common\Cache\ArrayCache; self::$_queryCacheImpl = new \Doctrine\Common\Cache\ArrayCache;
} }
return self::$_queryCacheImpl; return self::$_queryCacheImpl;
} }
} }