Ejemplo n.º 1
0
 /**
  * Process given arguments, prepare arguments of custom type.
  * @param array $arguments
  * @throws InvalidArgumentException
  * @return array
  */
 public function process(array $arguments)
 {
     $processedArguments = array();
     foreach ($arguments as $argumentKey => $argumentValue) {
         $value = isset($argumentValue['value']) ? $argumentValue['value'] : null;
         if (true == isset($argumentValue['type']) && false == empty($argumentValue['type'])) {
             if (true == empty($value)) {
                 throw new InvalidArgumentException('Argument value is required for type ' . $argumentValue['type']);
             }
             $handler = $this->_getArgumentHandler($argumentValue['type']);
             $value = $handler->process($value);
         }
         if (true == isset($argumentValue['updater']) && false == empty($argumentValue['updater'])) {
             $value = $this->_argumentUpdater->applyUpdaters($value, $argumentValue['updater']);
         }
         $processedArguments[$argumentKey] = $value;
     }
     return $processedArguments;
 }
Ejemplo n.º 2
0
 /**
  * @expectedException InvalidArgumentException
  */
 public function testApplyUpdatersWithInvalidUpdaters()
 {
     $this->_objectManagerMock->expects($this->once())->method('create')->with('Dummy_Updater_1')->will($this->returnValue(new StdClass()));
     $updaters = array('Dummy_Updater_1', 'Dummy_Updater_2');
     $this->_model->applyUpdaters(1, $updaters);
 }