/** * @expectedException ABK\QueryBundle\Filter\Exceptions\InvalidArgumentException */ public function testGetHandlerThrowsExceptionWithNotRegisteredHandlers() { $this->operatorMock = $this->getMockBuilder('ABK\\QueryBundle\\Filter\\Operators\\OperatorInterface')->disableOriginalConstructor()->getMock(); $this->operatorMock->expects($this->any())->method('getName')->will($this->returnValue('FALSE_NAME')); $this->operatorMock->expects($this->any())->method('getType')->will($this->returnValue('FALSE_TYPE')); $this->subject->getHandler($this->operatorMock); }
/** * @param OperatorInterface $operator * @return HandlerInterface * @throws \ABK\QueryBundle\Filter\Exceptions\InvalidArgumentException */ public function getHandler(OperatorInterface $operator) { $name = $operator->getName(); $type = $operator->getType(); if (!isset($this->registeredHandlers[$type]) || !in_array($name, $this->registeredHandlers[$type])) { throw new InvalidArgumentException('The given operator "' . $name . '" does not have an implemented handler for type ' . $type . '.'); } if ($operator instanceof ComparisonOperatorInterface) { return $this->getComparisonOperatorHandlerInstance($operator); } return null; }
/** * @param OperatorInterface $operator */ public function addOperator(OperatorInterface $operator) { $this->operators[] = $operator; $operator->setParent($this); }