/** * @inheritdoc */ public function validate($value, Constraint $constraint) { if (!$constraint instanceof EventValue) { throw new UnexpectedTypeException($constraint, sprintf('%s\\EventValue', __NAMESPACE__)); } if (!$value instanceof Event) { throw new UnexpectedTypeException($value, 'AppBundle\\Entity\\Event'); } switch ($value->getType()) { case Event::TYPE_SHOT: $this->coordsManager->validateCoords($value->getValue()); break; default: break; } }
/** * @expectedException \AppBundle\Exception\InvalidCoordinatesException * @expectedExceptionMessage Invalid coordinates provided * @dataProvider incorrectCoordsProvider * @param string $coords */ public function testValidateCoordsIncorrect($coords) { $this->coordsManager->validateCoords($coords); }