DDC-2173 - Add Test for new OnFlush or PreFlush behavior and update UPGRADE.md
This commit is contained in:
parent
1e669132c2
commit
512a001e8c
@ -1,3 +1,11 @@
|
||||
# Upgrade to 2.4
|
||||
|
||||
## OnFlush and PreFlush event always called
|
||||
|
||||
Before 2.4 the preFlush and onFlush events were only called when there were
|
||||
actually entities that changed. Now these events are called no matter if there
|
||||
are entities in the UoW or changes are found.
|
||||
|
||||
# Upgrade to 2.3
|
||||
|
||||
## EntityManager#find() not calls EntityRepository#find() anymore
|
||||
|
@ -48,6 +48,26 @@ class FlushEventTest extends \Doctrine\Tests\OrmFunctionalTestCase
|
||||
//echo "SECOND FLUSH";
|
||||
//$this->_em->flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* @group DDC-2173
|
||||
*/
|
||||
public function testPreAndOnFlushCalledAlways()
|
||||
{
|
||||
$listener = new OnFlushCalledListener();
|
||||
$this->_em->getEventManager()->addEventListener(Events::onFlush, $listener);
|
||||
$this->_em->getEventManager()->addEventListener(Events::preFlush, $listener);
|
||||
|
||||
$this->_em->flush();
|
||||
|
||||
$this->assertEquals(1, $listener->preFlush);
|
||||
$this->assertEquals(1, $listener->onFlush);
|
||||
|
||||
$this->_em->flush();
|
||||
|
||||
$this->assertEquals(2, $listener->preFlush);
|
||||
$this->assertEquals(2, $listener->onFlush);
|
||||
}
|
||||
}
|
||||
|
||||
class OnFlushListener
|
||||
@ -91,4 +111,18 @@ class OnFlushListener
|
||||
}
|
||||
}
|
||||
|
||||
class OnFlushCalledListener
|
||||
{
|
||||
public $preFlush = 0;
|
||||
public $onFlush = 0;
|
||||
|
||||
public function preFlush($args)
|
||||
{
|
||||
$this->preFlush++;
|
||||
}
|
||||
|
||||
public function onFlush($args)
|
||||
{
|
||||
$this->onFlush++;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user