示例#1
0
 private function getValueFromProvider(ReflectionParameter $param, $callable)
 {
     $parameterValue = new ParameterValue($param);
     foreach ($this->providers as $providers) {
         foreach ($providers as $provider) {
             /* @var $provider IParameterValueProvider */
             $provider->provideParameterValue($parameterValue);
             if ($parameterValue->isProcessed()) {
                 return $parameterValue->getValue();
             }
         }
     }
     throw new UnableToMatchParameterException(UnableToMatchParameterException::formatMessage($callable, $param->name));
 }
示例#2
0
 /**
  * @dataProvider provideTestInvoke
  */
 public function testInvoke($callable, $parameters = array(), $expectedResult = null, $expectExceptionOnParameter = null)
 {
     try {
         $result = $this->invoker->invoke($callable, $parameters);
     } catch (UnableToMatchParameterException $e) {
         if (!$expectExceptionOnParameter) {
             throw $e;
         }
         $this->assertEquals(UnableToMatchParameterException::formatMessage($callable, $expectExceptionOnParameter), $e->getMessage());
         return;
     }
     if ($expectExceptionOnParameter) {
         $this->fail('A exception of type [\\Nucleus\\Invoker\\UnableToMatchParameterException] should have been thrown');
     }
     $this->assertEquals($expectedResult, $result);
 }