コード例 #1
0
 /**
  * After entity with reminders was loaded, load reminders
  *
  * @param LifecycleEventArgs $args
  */
 public function postLoad(LifecycleEventArgs $args)
 {
     $entity = $args->getEntity();
     if ($entity instanceof RemindableInterface) {
         $this->reminderManager->loadReminders($entity);
     }
 }
コード例 #2
0
 public function testLoadReminders()
 {
     $entityId = 101;
     $entity = $this->getMock('Oro\\Bundle\\ReminderBundle\\Entity\\RemindableInterface');
     $entityClass = get_class($entity);
     $this->expectGetEntityIdentifier($entity, $entityId);
     $repository = $this->getMockBuilder('Oro\\Bundle\\ReminderBundle\\Entity\\Repository\\ReminderRepository')->disableOriginalConstructor()->getMock();
     $this->entityManager->expects($this->once())->method('getRepository')->with('OroReminderBundle:Reminder')->will($this->returnValue($repository));
     $entity->expects($this->once())->method('setReminders')->with($this->callback(function ($reminders) use($repository, $entityId, $entityClass) {
         $this->assertInstanceOf('Oro\\Bundle\\ReminderBundle\\Entity\\Collection\\RemindersPersistentCollection', $reminders);
         $this->assertAttributeEquals($entityClass, 'className', $reminders);
         $this->assertAttributeEquals($entityId, 'identifier', $reminders);
         return true;
     }));
     $this->manager->loadReminders($entity);
 }
コード例 #3
0
 public function testLoadReminders()
 {
     $entityId = 101;
     /** @var \PHPUnit_Framework_MockObject_MockObject|RemindableInterface $entity */
     $entity = $this->getMock('Oro\\Bundle\\ReminderBundle\\Entity\\RemindableInterface');
     $entityClass = get_class($entity);
     $repository = $this->getReminderRepository();
     $this->entityManager->expects($this->once())->method('getRepository')->with('OroReminderBundle:Reminder')->will($this->returnValue($repository));
     $this->doctrineHelper->expects($this->once())->method('getSingleEntityIdentifier')->will($this->returnValue($entityId));
     $this->doctrineHelper->expects($this->once())->method('getEntityClass')->will($this->returnValue($entityClass));
     $entity->expects($this->once())->method('setReminders')->with($this->callback(function ($reminders) use($repository, $entityId, $entityClass) {
         $this->assertInstanceOf('Oro\\Bundle\\ReminderBundle\\Entity\\Collection\\RemindersPersistentCollection', $reminders);
         $this->assertAttributeEquals($entityClass, 'className', $reminders);
         $this->assertAttributeEquals($entityId, 'identifier', $reminders);
         return true;
     }));
     $this->manager->loadReminders($entity);
 }