public transform ( Imbo\EventManager\EventInterface $event ) | ||
$event | Imbo\EventManager\EventInterface | The event instance |
public function transform(EventInterface $event)
{
$params = $event->getArgument('params');
if (empty($params['level'])) {
throw new TransformationException('Missing required parameter: level', 400);
}
$this->level = (int) $params['level'];
if ($this->level < 0 || $this->level > 100) {
throw new TransformationException('level must be between 0 and 100', 400);
}
}
/** * @expectedException Imbo\Exception\TransformationException * @expectedExceptionMessage level must be between 0 and 100 * @expectedExceptionCode 400 */ public function testThrowsExceptionOnInvalidLevel() { $event = $this->getMock('Imbo\\EventManager\\Event'); $event->expects($this->once())->method('getArgument')->with('params')->will($this->returnValue(['level' => 200])); $this->transformation->transform($event); }