public function testValidateWithType() { $value = new \Abc\Bundle\SchedulerBundle\Model\Schedule(); $value->setType('foobar'); $value->setExpression('ScheduleExpression'); $validator = $this->createMock(ValidatorInterface::class); $contextualValidator = $this->createMock(ContextualValidatorInterface::class); $this->context->expects($this->once())->method('getValidator')->willReturn($validator); $validator->expects($this->once())->method('inContext')->with($this->context)->willReturn($contextualValidator); $contextualValidator->expects($this->once())->method('atPath')->with('expression')->willReturn($contextualValidator); $contextualValidator->expects($this->once())->method('validate')->with('ScheduleExpression', new Expression(['type' => $value->getType()])); $this->subject->validate($value, new Schedule()); }
public function testCastsSchedulesBeforeSave() { $schedule = new \Abc\Bundle\SchedulerBundle\Model\Schedule(); $schedule->setType('ScheduleType'); $schedule->setExpression('ScheduleExpression'); $job = $this->subject->create('JobType'); $job->setStatus(Status::REQUESTED()); $job->addSchedule($schedule); $this->subject->save($job); $this->assertCount(1, $this->subject->findAll()); }