/** * @depends testListenerCanBeCreated */ public function testOnFlush(DeprecatedAuditDataListener $deprecatedAuditDataListener) { $audit = new Audit(); $audit->setObjectClass('class'); $audit->setData(['stringField' => ['old' => 'oldValue', 'new' => 'newValue'], 'intField' => ['old' => ['value' => 3], 'new' => ['value' => 5]]]); $this->uow->expects($this->once())->method('getScheduledEntityInsertions')->will($this->returnValue([$audit])); $this->uow->expects($this->once())->method('getScheduledEntityUpdates')->will($this->returnValue([])); $onFlushEventArgs = new OnFlushEventArgs($this->em); $deprecatedAuditDataListener->onFlush($onFlushEventArgs); return $audit; }
/** * {@inheritdoc} */ public function load(ObjectManager $manager) { /** @var User $user */ $user = $manager->getRepository('OroUserBundle:User')->findOneBy(['username' => 'admin']); $logEntry = new Audit(); $logEntry->setAction('update'); $logEntry->setObjectClass('Oro\\Bundle\\UserBundle\\Entity\\User'); $logEntry->setLoggedAt(); $logEntry->setUser($user); $logEntry->setOrganization($user->getOrganization()); $logEntry->setObjectName('test_user'); $logEntry->setObjectId($user->getId()); $logEntry->createField('username', 'text', 'new_value', 'old_value'); $logEntry->setVersion(1); $manager->persist($logEntry); $manager->flush(); $this->setReference('audit_log_entry', $logEntry); }