Commit 59a17eb5 authored by romanb's avatar romanb

[2.0][DDC-171] Fixed (second attempt). Some other cleanups. Performance fix...

[2.0][DDC-171] Fixed (second attempt). Some other cleanups. Performance fix for mock Statement used in hydration performance tests for more accurate and better results.
parent b276574e
...@@ -158,18 +158,6 @@ final class PersistentCollection implements \Doctrine\Common\Collections\Collect ...@@ -158,18 +158,6 @@ final class PersistentCollection implements \Doctrine\Common\Collections\Collect
return $this->_owner; return $this->_owner;
} }
/**
* Gets the class descriptor for the owning entity class.
*
* @return Doctrine\ORM\Mapping\ClassMetadata
* @deprecated
* @todo Remove
*/
public function getOwnerClass()
{
return $this->_typeClass;
}
public function getTypeClass() public function getTypeClass()
{ {
return $this->_typeClass; return $this->_typeClass;
...@@ -194,6 +182,10 @@ final class PersistentCollection implements \Doctrine\Common\Collections\Collect ...@@ -194,6 +182,10 @@ final class PersistentCollection implements \Doctrine\Common\Collections\Collect
// OneToMany // OneToMany
$this->_typeClass->reflFields[$this->_backRefFieldName] $this->_typeClass->reflFields[$this->_backRefFieldName]
->setValue($element, $this->_owner); ->setValue($element, $this->_owner);
$this->_em->getUnitOfWork()->setOriginalEntityProperty(
spl_object_hash($element),
$this->_backRefFieldName,
$this->_owner);
} else { } else {
// ManyToMany // ManyToMany
$this->_typeClass->reflFields[$this->_backRefFieldName] $this->_typeClass->reflFields[$this->_backRefFieldName]
......
...@@ -13,8 +13,8 @@ class MemcacheCacheTest extends \Doctrine\Tests\DoctrineTestCase ...@@ -13,8 +13,8 @@ class MemcacheCacheTest extends \Doctrine\Tests\DoctrineTestCase
public function setUp() public function setUp()
{ {
if (extension_loaded('memcache')) { if (extension_loaded('memcache')) {
$memcache = new \Memcache; $this->_memcache = new \Memcache;
$ok = @$memcache->connect('localhost', 11211); $ok = @$this->_memcache->connect('localhost', 11211);
if (!$ok) { if (!$ok) {
$this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache'); $this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache');
} }
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
namespace Doctrine\Tests\Mocks; namespace Doctrine\Tests\Mocks;
/** /**
* This class is a mock of the PDOStatement class that can be passed in to the Hydrator * This class is a mock of the Statement interface that can be passed in to the Hydrator
* to test the hydration standalone with faked result sets. * to test the hydration standalone with faked result sets.
* *
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
*/ */
class HydratorMockStatement class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement
{ {
private $_resultSet; private $_resultSet;
...@@ -25,9 +25,6 @@ class HydratorMockStatement ...@@ -25,9 +25,6 @@ class HydratorMockStatement
/** /**
* Fetches all rows from the result set. * Fetches all rows from the result set.
* *
* NOTE: Must adhere to the PDOStatement::fetchAll() signature that looks as follows:
* array fetchAll ([ int $fetch_style [, int $column_index [, array $ctor_args ]]] )
*
* @return array * @return array
*/ */
public function fetchAll($fetchStyle = null, $columnIndex = null, array $ctorArgs = null) public function fetchAll($fetchStyle = null, $columnIndex = null, array $ctorArgs = null)
...@@ -37,7 +34,7 @@ class HydratorMockStatement ...@@ -37,7 +34,7 @@ class HydratorMockStatement
public function fetchColumn($columnNumber = 0) public function fetchColumn($columnNumber = 0)
{ {
$row = array_shift($this->_resultSet); $row = current($this->_resultSet);
if ( ! is_array($row)) return false; if ( ! is_array($row)) return false;
$val = array_shift($row); $val = array_shift($row);
return $val !== null ? $val : false; return $val !== null ? $val : false;
...@@ -46,13 +43,12 @@ class HydratorMockStatement ...@@ -46,13 +43,12 @@ class HydratorMockStatement
/** /**
* Fetches the next row in the result set. * Fetches the next row in the result set.
* *
* NOTE: Must adhere to the PDOStatement::fetch() signature that looks as follows:
* mixed fetch ([ int $fetch_style [, int $cursor_orientation [, int $cursor_offset ]]] )
*
*/ */
public function fetch($fetchStyle = null, $cursorOrientation = null, $cursorOffset = null) public function fetch($fetchStyle = null)
{ {
return array_shift($this->_resultSet); $current = current($this->_resultSet);
next($this->_resultSet);
return $current;
} }
/** /**
...@@ -67,6 +63,39 @@ class HydratorMockStatement ...@@ -67,6 +63,39 @@ class HydratorMockStatement
public function setResultSet(array $resultSet) public function setResultSet(array $resultSet)
{ {
reset($resultSet);
$this->_resultSet = $resultSet; $this->_resultSet = $resultSet;
} }
public function bindColumn($column, &$param, $type = null)
{
}
public function bindValue($param, $value, $type = null)
{
}
public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array())
{
}
public function columnCount()
{
}
public function errorCode()
{
}
public function errorInfo()
{
}
public function execute($params = array())
{
}
public function rowCount()
{
}
} }
\ No newline at end of file
...@@ -560,14 +560,25 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase ...@@ -560,14 +560,25 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
$address->user = $user; $address->user = $user;
$user->address = $address; $user->address = $address;
$article = new \Doctrine\Tests\Models\CMS\CmsArticle();
$article->text = "Lorem ipsum dolor sunt.";
$article->topic = "A Test Article!";
$article->setAuthor($user);
$this->_em->persist($article);
$this->_em->persist($user); $this->_em->persist($user);
//$this->_em->getConnection()->getConfiguration()->setSqlLogger(new \Doctrine\DBAL\Logging\EchoSqlLogger);
$this->_em->flush(); $this->_em->flush();
$this->_em->clear(); $this->_em->clear();
$query = $this->_em->createQuery('select u, a from Doctrine\Tests\Models\CMS\CmsUser u join u.address a'); $query = $this->_em->createQuery('select u,a,ad from Doctrine\Tests\Models\CMS\CmsUser u join u.articles a join u.address ad');
$user2 = $query->getSingleResult(); $user2 = $query->getSingleResult();
$this->assertEquals(1, count($user2->articles));
$this->assertTrue($user2->address instanceof CmsAddress);
$oldLogger = $this->_em->getConnection()->getConfiguration()->getSqlLogger(); $oldLogger = $this->_em->getConnection()->getConfiguration()->getSqlLogger();
$debugStack = new \Doctrine\DBAL\Logging\DebugStack; $debugStack = new \Doctrine\DBAL\Logging\DebugStack;
$this->_em->getConnection()->getConfiguration()->setSqlLogger($debugStack); $this->_em->getConnection()->getConfiguration()->setSqlLogger($debugStack);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment