Exemple #1
0
 /**
  * Get argument handler by type
  *
  * @param string $type
  * @throws InvalidArgumentException
  * @return Mage_Core_Model_Layout_Argument_HandlerInterface
  */
 protected function _getArgumentHandler($type)
 {
     if (isset($this->_argumentHandlers[$type])) {
         return $this->_argumentHandlers[$type];
     }
     $handlerFactory = $this->_config->getArgumentHandlerFactoryByType($type);
     if (false === $handlerFactory instanceof Mage_Core_Model_Layout_Argument_HandlerFactoryInterface) {
         throw new InvalidArgumentException('Incorrect handler factory');
     }
     /** @var $handler Mage_Core_Model_Layout_Argument_HandlerInterface */
     $handler = $handlerFactory->createHandler();
     if (false === $handler instanceof Mage_Core_Model_Layout_Argument_HandlerInterface) {
         throw new InvalidArgumentException($type . ' type handler should implement Mage_Core_Model_Layout_Argument_HandlerInterface');
     }
     $this->_argumentHandlers[$type] = $handler;
     return $handler;
 }
 /**
  * @param string $type
  * @param string $className
  * @dataProvider getArgumentHandlerFactoryByTypeWithValidTypeDataProvider
  */
 public function testGetArgumentHandlerFactoryByTypeWithValidType($type, $className)
 {
     $factoryMock = $this->getMock('Mage_Core_Model_Layout_Argument_HandlerFactoryInterface', array(), array(), $className, false);
     $this->_objectFactoryMock->expects($this->once())->method('getModelInstance')->with($className)->will($this->returnValue($factoryMock));
     $this->assertInstanceOf($className, $this->_model->getArgumentHandlerFactoryByType($type));
 }