public function testValidateWithTypeRegistered()
 {
     $value = 'foobar';
     $this->registry->expects($this->once())->method('has')->with($value)->willReturn(true);
     $this->context->expects($this->never())->method('buildViolation');
     $this->subject->validate($value, new Type());
 }
 /**
  * {@inheritDoc}
  */
 public final function process(ScheduleIteratorInterface $iterator)
 {
     $numOfProcessed = 0;
     $exceptions = array();
     foreach ($iterator as $schedule) {
         $this->logger->debug('Process schedule {schedule}', array('schedule' => $schedule));
         try {
             /**
              * @var ScheduleInterface $schedule
              */
             if ($this->registry->get($schedule->getType())->process($schedule)) {
                 $schedule->setScheduledAt(new \DateTime());
                 $iterator->getManager()->save($schedule);
                 $this->dispatcher->dispatch(SchedulerEvents::SCHEDULE, new SchedulerEvent($schedule));
                 $numOfProcessed++;
             }
         } catch (\Exception $e) {
             $this->logger->error('Failed to process schedule {schedule} ({exception})', array('schedule' => $schedule, 'exception' => $e));
             $exceptions[] = new ScheduleException($schedule, $e);
         }
     }
     if (count($exceptions) > 0) {
         throw new SchedulerException($numOfProcessed, $exceptions);
     }
     return $numOfProcessed;
 }
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     $this->dispatcher = $this->createMock(EventDispatcherInterface::class);
     $this->manager = $this->createMock(ScheduleManagerInterface::class);
     $this->processor = $this->createMock(ProcessorInterface::class);
     $this->registry = new ProcessorRegistry();
     $this->registry->register('type', $this->processor);
     $this->subject = new Scheduler($this->registry, $this->dispatcher);
 }
 /**
  * {@inheritdoc}
  */
 public function validate($value, Constraint $constraint)
 {
     if (null === $value) {
         return;
     }
     if (!$this->registry->has($value)) {
         $this->context->buildViolation($constraint->message)->setParameter('{{string}}', $value)->addViolation();
     }
 }