-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
DDC3123Test.php
49 lines (38 loc) · 1.24 KB
/
DDC3123Test.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
declare(strict_types=1);
namespace Doctrine\Tests\ORM\Functional\Ticket;
use Doctrine\ORM\Events;
use Doctrine\Tests\Models\CMS\CmsUser;
use Doctrine\Tests\OrmFunctionalTestCase;
use stdClass;
/**
* @group DDC-3123
*/
class DDC3123Test extends OrmFunctionalTestCase
{
protected function setUp() : void
{
$this->useModelSet('cms');
parent::setUp();
}
public function testIssue() : void
{
$user = new CmsUser();
$uow = $this->em->getUnitOfWork();
$user->name = 'Marco';
$user->username = 'ocramius';
$this->em->persist($user);
$uow->scheduleExtraUpdate($user, ['name' => 'changed name']);
$listener = $this->getMockBuilder(stdClass::class)
->setMethods([Events::postFlush])
->getMock();
$listener
->expects($this->once())
->method(Events::postFlush)
->will($this->returnCallback(static function () use ($uow) {
self::assertAttributeEmpty('extraUpdates', $uow, 'ExtraUpdates are reset before postFlush');
}));
$this->em->getEventManager()->addEventListener(Events::postFlush, $listener);
$this->em->flush();
}
}