[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.
This commit is contained in:
parent
b276574ece
commit
59a17eb51c
@ -157,18 +157,6 @@ final class PersistentCollection implements \Doctrine\Common\Collections\Collect
|
||||
{
|
||||
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()
|
||||
{
|
||||
@ -194,6 +182,10 @@ final class PersistentCollection implements \Doctrine\Common\Collections\Collect
|
||||
// OneToMany
|
||||
$this->_typeClass->reflFields[$this->_backRefFieldName]
|
||||
->setValue($element, $this->_owner);
|
||||
$this->_em->getUnitOfWork()->setOriginalEntityProperty(
|
||||
spl_object_hash($element),
|
||||
$this->_backRefFieldName,
|
||||
$this->_owner);
|
||||
} else {
|
||||
// ManyToMany
|
||||
$this->_typeClass->reflFields[$this->_backRefFieldName]
|
||||
|
@ -13,8 +13,8 @@ class MemcacheCacheTest extends \Doctrine\Tests\DoctrineTestCase
|
||||
public function setUp()
|
||||
{
|
||||
if (extension_loaded('memcache')) {
|
||||
$memcache = new \Memcache;
|
||||
$ok = @$memcache->connect('localhost', 11211);
|
||||
$this->_memcache = new \Memcache;
|
||||
$ok = @$this->_memcache->connect('localhost', 11211);
|
||||
if (!$ok) {
|
||||
$this->markTestSkipped('The ' . __CLASS__ .' requires the use of memcache');
|
||||
}
|
||||
|
@ -3,12 +3,12 @@
|
||||
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.
|
||||
*
|
||||
* @author Roman Borschel <roman@code-factory.org>
|
||||
*/
|
||||
class HydratorMockStatement
|
||||
class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement
|
||||
{
|
||||
private $_resultSet;
|
||||
|
||||
@ -25,9 +25,6 @@ class HydratorMockStatement
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public function fetchAll($fetchStyle = null, $columnIndex = null, array $ctorArgs = null)
|
||||
@ -37,7 +34,7 @@ class HydratorMockStatement
|
||||
|
||||
public function fetchColumn($columnNumber = 0)
|
||||
{
|
||||
$row = array_shift($this->_resultSet);
|
||||
$row = current($this->_resultSet);
|
||||
if ( ! is_array($row)) return false;
|
||||
$val = array_shift($row);
|
||||
return $val !== null ? $val : false;
|
||||
@ -45,14 +42,13 @@ class HydratorMockStatement
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
public function setResultSet(array $resultSet)
|
||||
{
|
||||
reset($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()
|
||||
{
|
||||
}
|
||||
}
|
@ -560,13 +560,24 @@ class BasicFunctionalTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
$address->user = $user;
|
||||
$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->getConnection()->getConfiguration()->setSqlLogger(new \Doctrine\DBAL\Logging\EchoSqlLogger);
|
||||
|
||||
$this->_em->flush();
|
||||
$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();
|
||||
|
||||
$this->assertEquals(1, count($user2->articles));
|
||||
$this->assertTrue($user2->address instanceof CmsAddress);
|
||||
|
||||
$oldLogger = $this->_em->getConnection()->getConfiguration()->getSqlLogger();
|
||||
$debugStack = new \Doctrine\DBAL\Logging\DebugStack;
|
||||
|
Loading…
x
Reference in New Issue
Block a user