Permalink
Browse files

Code optimizations. Fixed unused argument in OrmTestCase as referred …

…in DDC-766.
  • Loading branch information...
guilhermeblanco committed Oct 16, 2011
1 parent 33bcf7a commit eeba947ea7f0f5f18672c368398f105a93e58545
Showing with 27 additions and 26 deletions.
  1. +12 −15 lib/Doctrine/ORM/Query/Parser.php
  2. +15 −11 tests/Doctrine/Tests/OrmTestCase.php
@@ -1328,18 +1328,18 @@ public function GroupByItem()
// We need to check if we are in a IdentificationVariable or SingleValuedPathExpression
$glimpse = $this->_lexer->glimpse();
- if ($glimpse['type'] != Lexer::T_DOT) {
- $token = $this->_lexer->lookahead;
- $identVariable = $this->IdentificationVariable();
-
- if (!isset($this->_queryComponents[$identVariable])) {
- $this->semanticalError('Cannot group by undefined identification variable.');
- }
+ if ($glimpse['type'] == Lexer::T_DOT) {
+ return $this->SingleValuedPathExpression();
+ }
+
+ $token = $this->_lexer->lookahead;
+ $identVariable = $this->IdentificationVariable();
- return $identVariable;
+ if (!isset($this->_queryComponents[$identVariable])) {
+ $this->semanticalError('Cannot group by undefined identification variable.');
}
- return $this->SingleValuedPathExpression();
+ return $identVariable;
}
/**
@@ -1354,12 +1354,9 @@ public function OrderByItem()
// We need to check if we are in a ResultVariable or StateFieldPathExpression
$glimpse = $this->_lexer->glimpse();
- if ($glimpse['type'] != Lexer::T_DOT) {
- $token = $this->_lexer->lookahead;
- $expr = $this->ResultVariable();
- } else {
- $expr = $this->SingleValuedPathExpression();
- }
+ $expr = ($glimpse['type'] != Lexer::T_DOT)
+ ? $this->ResultVariable()
+ : $this->SingleValuedPathExpression();
$item = new AST\OrderByItem($expr);
@@ -11,6 +11,7 @@
{
/** The metadata cache that is shared between all ORM tests (except functional tests). */
private static $_metadataCacheImpl = null;
+
/** The query cache that is shared between all ORM tests (except functional tests). */
private static $_queryCacheImpl = null;
@@ -66,30 +67,31 @@ protected function createAnnotationDriver($paths = array(), $alias = null)
*/
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();
- if($withSharedMetadata) {
- $config->setMetadataCacheImpl(self::getSharedMetadataCacheImpl());
- } else {
- $config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache);
- }
-
+
+ $config->setMetadataCacheImpl($metadataCache);
$config->setMetadataDriverImpl($config->newDefaultAnnotationDriver());
-
$config->setQueryCacheImpl(self::getSharedQueryCacheImpl());
$config->setProxyDir(__DIR__ . '/Proxies');
$config->setProxyNamespace('Doctrine\Tests\Proxies');
- $eventManager = new \Doctrine\Common\EventManager();
+
if ($conn === null) {
$conn = array(
- 'driverClass' => 'Doctrine\Tests\Mocks\DriverMock',
+ 'driverClass' => 'Doctrine\Tests\Mocks\DriverMock',
'wrapperClass' => 'Doctrine\Tests\Mocks\ConnectionMock',
- 'user' => 'john',
- 'password' => 'wayne'
+ 'user' => 'john',
+ 'password' => 'wayne'
);
}
+
if (is_array($conn)) {
$conn = \Doctrine\DBAL\DriverManager::getConnection($conn, $config, $eventManager);
}
+
return \Doctrine\Tests\Mocks\EntityManagerMock::create($conn, $config, $eventManager);
}
@@ -98,6 +100,7 @@ private static function getSharedMetadataCacheImpl()
if (self::$_metadataCacheImpl === null) {
self::$_metadataCacheImpl = new \Doctrine\Common\Cache\ArrayCache;
}
+
return self::$_metadataCacheImpl;
}
@@ -106,6 +109,7 @@ private static function getSharedQueryCacheImpl()
if (self::$_queryCacheImpl === null) {
self::$_queryCacheImpl = new \Doctrine\Common\Cache\ArrayCache;
}
+
return self::$_queryCacheImpl;
}
}

0 comments on commit eeba947

Please sign in to comment.