/** * @param string $classname * @param array $arguments * * @throws \PhpSpec\Exception\Wrapper\SubjectException */ public function beAnInstanceOf($classname, array $arguments = array()) { if (!is_string($classname)) { throw new SubjectException(sprintf('Behavior subject classname should be a string, %s given.', $this->presenter->presentValue($classname))); } $this->classname = $classname; $unwrapper = new Unwrapper(); $this->arguments = $unwrapper->unwrapAll($arguments); $this->isInstantiated = false; }
/** * @param string $name * @param mixed $subject * @param array $arguments * * @return Matcher */ private function findMatcher($name, $subject, array $arguments = array()) { $unwrapper = new Unwrapper(); $arguments = $unwrapper->unwrapAll($arguments); return $this->matchers->find($name, $subject, $arguments); }
/** * @param string $property * @param mixed $value * * @return mixed * * @throws \PhpSpec\Exception\Wrapper\SubjectException * @throws \PhpSpec\Exception\Fracture\PropertyNotFoundException */ public function set($property, $value = null) { if (null === $this->getWrappedObject()) { throw $this->settingPropertyOnNonObject($property); } $unwrapper = new Unwrapper(); $value = $unwrapper->unwrapOne($value); if ($this->isObjectPropertyAccessible($property, true)) { return $this->getWrappedObject()->{$property} = $value; } throw $this->propertyNotFound($property); }
/** * * @param string $alias * @param mixed $subject * @param array $arguments * * @return mixed */ public function match($alias, $subject, array $arguments = array()) { $arguments = $this->unwrapper->unwrapAll($arguments); return $this->getExpectation()->match($alias, $subject, $arguments); }
/** * @param callable|string|null $factoryMethod * @param array $arguments */ public function beConstructedThrough($factoryMethod, array $arguments = array()) { if (is_string($factoryMethod) && false === strpos($factoryMethod, '::') && method_exists($this->classname, $factoryMethod)) { $factoryMethod = array($this->classname, $factoryMethod); } if ($this->isInstantiated()) { throw new SubjectException('You can not change object construction method when it is already instantiated'); } $this->factoryMethod = $factoryMethod; $unwrapper = new Unwrapper(); $this->arguments = $unwrapper->unwrapAll($arguments); }
/** * @param string|integer $key */ public function offsetUnset($key) { $unwrapper = new Unwrapper(); $subject = $this->caller->getWrappedObject(); $key = $unwrapper->unwrapOne($key); $this->checkIfSubjectImplementsArrayAccess($subject); unset($subject[$key]); }
function let(Unwrapper $unwrapper, Presenter $presenter, ReflectionFactory $factory) { $unwrapper->unwrapAll(Argument::any())->willReturnArgument(); $presenter->presentValue(Argument::any())->willReturn('val1', 'val2'); $this->beConstructedWith($unwrapper, $presenter, $factory); }
function let(Unwrapper $unwrapper) { $unwrapper->unwrapAll(Argument::any())->willReturnArgument(); $this->beConstructedWith($unwrapper); }