/**
  * @param ArrayNodeDefinition $nodeDefinition
  * @return ArrayNodeDefinition
  *
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function addTriggerNodes(ArrayNodeDefinition $nodeDefinition)
 {
     $nodeDefinition->children()->enumNode('event')->defaultNull()->values(ProcessTrigger::getAllowedEvents())->end()->scalarNode('field')->defaultNull()->end()->integerNode('priority')->defaultValue(Job::PRIORITY_DEFAULT)->end()->booleanNode('queued')->defaultFalse()->end()->scalarNode('time_shift')->defaultNull()->validate()->always(function ($value) {
         // if value is an integer value
         $integerValue = filter_var($value, FILTER_VALIDATE_INT);
         if (false !== $integerValue) {
             return $integerValue;
         }
         // if value is DateInterval spec
         try {
             return ProcessTrigger::convertDateIntervalToSeconds(new \DateInterval($value));
         } catch (\Exception $e) {
             throw new \LogicException(sprintf('Time shift "%s" is not compatible with DateInterval', $value));
         }
     })->end()->end()->scalarNode('cron')->defaultNull()->validate()->always(function ($value) {
         if ($value !== null) {
             // validate expression string
             CronExpression::factory($value);
         }
         return $value;
     })->end()->end()->end()->validate()->always(function ($data) {
         if ($data['event'] && $data['cron']) {
             throw new \LogicException('Only one child node "event" or "cron" must be configured.');
         }
         if ($data['cron'] && ($data['field'] || $data['queued'] || $data['time_shift'])) {
             throw new \LogicException('Nodes "field", "queued" and "time_shift" are only allowed with event node.');
         }
         if ($data['field'] && $data['event'] !== ProcessTrigger::EVENT_UPDATE) {
             throw new \LogicException('Field is only allowed for update event');
         }
         return $data;
     })->end();
     return $nodeDefinition;
 }
 public function testSetGetTimeShiftInterval()
 {
     $this->assertNull($this->entity->getTimeShift());
     $this->assertNull($this->entity->getTimeShiftInterval());
     $this->entity->setTimeShiftInterval(new \DateInterval('PT1H'));
     $this->assertEquals(3600, $this->entity->getTimeShift());
     $this->assertEquals(3600, ProcessTrigger::convertDateIntervalToSeconds($this->entity->getTimeShiftInterval()));
     $this->entity->setTimeShiftInterval(null);
     $this->assertNull($this->entity->getTimeShift());
     $this->assertNull($this->entity->getTimeShiftInterval());
 }