示例#1
0
 /**
  * @param ConfigUpdateEvent $event
  */
 public function onConfigUpdate(ConfigUpdateEvent $event)
 {
     if (!$event->isChanged('oro_locale.timezone')) {
         return;
     }
     $this->metricStateManager->resetMetrics();
     $this->metricStateManager->scheduleRecalculation();
 }
 public function testSuccessChange()
 {
     /** @var \PHPUnit_Framework_MockObject_MockObject|ConfigUpdateEvent $event */
     $event = $this->getMockBuilder('Oro\\Bundle\\ConfigBundle\\Event\\ConfigUpdateEvent')->disableOriginalConstructor()->getMock();
     $event->expects($this->once())->method('isChanged')->with('oro_locale.timezone')->will($this->returnValue(true));
     $this->manager->expects($this->once())->method('resetMetrics');
     $this->manager->expects($this->once())->method('scheduleRecalculation');
     $this->manager->expects($this->once())->method('resetMetrics');
     $this->manager->expects($this->once())->method('scheduleRecalculation');
     $this->listener->onConfigUpdate($event);
 }
示例#3
0
 /**
  * @param ChannelSaveEvent $event
  */
 public function onChannelSucceedSave(ChannelSaveEvent $event)
 {
     foreach ($this->channelsToDrop as $channel) {
         $this->metricStateManager->resetMetrics($channel);
     }
     foreach ($this->channelsToRecalculate as $channel) {
         if (array_key_exists(spl_object_hash($channel), $this->channelsToDrop)) {
             continue;
         }
         $this->metricStateManager->resetMetrics($channel);
         $this->metricStateManager->scheduleRecalculation($channel);
     }
     $this->channelsToDrop = [];
     $this->channelsToRecalculate = [];
 }
示例#4
0
 /**
  * @param array $updateEntities
  * @param array $insertEntities
  * @param array $deleteEntities
  * @param int $expectedResetMetrics
  * @param int $expectedScheduleRecalculation
  *
  * @dataProvider entitiesDataProvider
  */
 public function testEvents(array $updateEntities, array $insertEntities, array $deleteEntities, $expectedResetMetrics = 0, $expectedScheduleRecalculation = 0)
 {
     /** @var \PHPUnit_Framework_MockObject_MockObject|EntityManager $em */
     $em = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $uow = $this->getMockBuilder('Doctrine\\ORM\\UnitOfWork')->disableOriginalConstructor()->getMock();
     $em->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($uow));
     $uow->expects($this->once())->method('getScheduledEntityInsertions')->will($this->returnValue($updateEntities));
     $uow->expects($this->once())->method('getScheduledEntityUpdates')->will($this->returnValue($insertEntities));
     $uow->expects($this->once())->method('getScheduledEntityDeletions')->will($this->returnValue($deleteEntities));
     $this->manager->expects($this->exactly($expectedResetMetrics))->method('resetMetrics');
     $this->manager->expects($this->exactly($expectedScheduleRecalculation))->method('scheduleRecalculation');
     $args = new OnFlushEventArgs($em);
     $this->listener->onFlush($args);
     $event = new ChannelSaveEvent(new Channel());
     $this->listener->onChannelSucceedSave($event);
 }