for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\Events;
use Doctrine\Tests\OrmFunctionalTestCase;
use stdClass;
/**
* @group 6884
*/
final class GH6884Test extends OrmFunctionalTestCase
{
* {@inheritdoc}
protected function setUp(): void
parent::setUp();
$this->_schemaTool->createSchema(
_schemaTool
Doctrine\Tests\ORM\Functional\Ticket\GH6884Test
schemaTool
[
$this->_em->getClassMetadata(GH6884Person::class)
_em
]
);
$listener = $this->createPartialMock(stdClass::class, ['preUpdate']);
$listener->expects($this->exactly(3))->method('preUpdate');
$this->_em->getEventManager()->addEventListener([Events::preUpdate], $listener);
->addEntityListener(Events::postUpdate, GH6884Person::class, 'onPostUpdate');
}
public function testIssue(): void
$person = new GH6884Person();
$person2 = new GH6884Person();
$this->_em->persist($person);
$this->_em->persist($person2);
$this->_em->flush();
$person->isAlive = true;
$person2->isAlive = true;
* @Entity()
class GH6884Person
/** @Id() @Column(type="integer") @GeneratedValue() */
public $id;
/** @Column(type="boolean", nullable=false) */
public $isAlive = false;
/** @var bool */
public $nonOrmProperty = false;
public function onPostUpdate(GH6884Person $person, LifecycleEventArgs $eventArgs): void
$person->nonOrmProperty = true;
$eventArgs->getEntityManager()->flush();