/** * @param string $method * @param array $arguments * @return \PhpSpec\Exception\Fracture\MethodNotFoundException|\PhpSpec\Exception\Fracture\MethodNotVisibleException */ private function methodNotFound($method, array $arguments = array()) { $className = $this->wrappedObject->getClassName(); if (!method_exists($className, $method)) { return $this->exceptionFactory->methodNotFound($className, $method, $arguments); } return $this->exceptionFactory->methodNotVisible($className, $method, $arguments); }
function it_delegates_throwing_method_not_visible_exception(WrappedObject $wrappedObject, ExceptionFactory $exceptions) { $obj = new ExampleClass(); $wrappedObject->isInstantiated()->willReturn(true); $wrappedObject->getInstance()->willReturn($obj); $wrappedObject->getClassName()->willReturn('spec\\PhpSpec\\Wrapper\\Subject\\ExampleClass'); $exceptions->methodNotVisible('spec\\PhpSpec\\Wrapper\\Subject\\ExampleClass', 'privateMethod', array())->willReturn(new \PhpSpec\Exception\Fracture\MethodNotVisibleException('Method "privateMethod" not visible.', $obj, '"ExampleClass::privateMethod"', array()))->shouldBeCalled(); $this->shouldThrow('\\PhpSpec\\Exception\\Fracture\\MethodNotVisibleException')->duringCall('privateMethod'); }