getArguments() публичный Метод

public getArguments ( ) : array
Результат array
Пример #1
0
 function it_delegates_throwing_method_not_found_exception_for_constructor(WrappedObject $wrappedObject, ExceptionFactory $exceptions, \stdClass $argument)
 {
     $obj = new ExampleClass();
     $wrappedObject->isInstantiated()->willReturn(false);
     $wrappedObject->getInstance()->willReturn(null);
     $wrappedObject->getArguments()->willReturn(array($argument));
     $wrappedObject->getClassName()->willReturn('spec\\PhpSpec\\Wrapper\\Subject\\ExampleClass');
     $exceptions->methodNotFound('spec\\PhpSpec\\Wrapper\\Subject\\ExampleClass', '__construct', array($argument))->willReturn(new \PhpSpec\Exception\Fracture\MethodNotFoundException('Method "__construct" not found.', $obj, '"ExampleClass::__construct"', array()))->shouldBeCalled();
     $this->shouldThrow('\\PhpSpec\\Exception\\Fracture\\MethodNotFoundException')->duringCall('__construct');
 }
Пример #2
0
 /**
  * @return mixed
  * @throws \PhpSpec\Exception\Fracture\MethodNotFoundException
  */
 private function newInstanceWithFactoryMethod()
 {
     $method = $this->wrappedObject->getFactoryMethod();
     if (!is_array($method)) {
         $className = $this->wrappedObject->getClassName();
         if (!method_exists($className, $method)) {
             throw $this->namedConstructorNotFound($method, $this->wrappedObject->getArguments());
         }
     }
     return call_user_func_array($method, $this->wrappedObject->getArguments());
 }
Пример #3
0
 /**
  * @param  ReflectionClass                                       $reflection
  * @return object
  * @throws \PhpSpec\Exception\Fracture\MethodNotFoundException
  * @throws \PhpSpec\Exception\Fracture\MethodNotVisibleException
  * @throws \Exception
  * @throws \ReflectionException
  */
 private function newInstanceWithArguments(ReflectionClass $reflection)
 {
     try {
         return $reflection->newInstanceArgs($this->wrappedObject->getArguments());
     } catch (ReflectionException $e) {
         if ($this->detectMissingConstructorMessage($e)) {
             throw $this->methodNotFound('__construct', $this->wrappedObject->getArguments());
         }
         throw $e;
     }
 }
Пример #4
0
 /**
  * @return mixed
  */
 public function duringInstantiation()
 {
     if ($factoryMethod = $this->wrappedObject->getFactoryMethod()) {
         $method = is_array($factoryMethod) ? $factoryMethod[1] : $factoryMethod;
     } else {
         $method = '__construct';
     }
     $instantiator = new Instantiator();
     $object = $instantiator->instantiate($this->wrappedObject->getClassName());
     return $this->runDuring($object, $method, $this->wrappedObject->getArguments());
 }
Пример #5
0
 function it_delegates_throwing_named_constructor_not_found_exception(WrappedObject $wrappedObject, ExceptionFactory $exceptions)
 {
     $obj = new \ArrayObject();
     $arguments = array('firstname', 'lastname');
     $wrappedObject->isInstantiated()->willReturn(false);
     $wrappedObject->getInstance()->willReturn(null);
     $wrappedObject->getClassName()->willReturn('ArrayObject');
     $wrappedObject->getFactoryMethod()->willReturn('register');
     $wrappedObject->getArguments()->willReturn($arguments);
     $exceptions->namedConstructorNotFound('ArrayObject', 'register', $arguments)->willReturn(new \PhpSpec\Exception\Fracture\NamedConstructorNotFoundException('Named constructor "register" not found.', $obj, '"ArrayObject::register"', array()))->shouldBeCalled();
     $this->shouldThrow('\\PhpSpec\\Exception\\Fracture\\NamedConstructorNotFoundException')->duringCall('foo');
 }
Пример #6
0
 /**
  * @return object
  */
 private function newInstanceWithFactoryMethod()
 {
     return call_user_func_array($this->wrappedObject->getFactoryMethod(), $this->wrappedObject->getArguments());
 }