/** * @param ExampleNode $example * @param SpecificationInterface $context * @param MatcherManager $matchers * @param CollaboratorManager $collaborators */ public function prepare(ExampleNode $example, SpecificationInterface $context, MatcherManager $matchers, CollaboratorManager $collaborators) { $matchers->add(new Matcher\IdentityMatcher($this->presenter)); $matchers->add(new Matcher\ComparisonMatcher($this->presenter)); $matchers->add(new Matcher\ThrowMatcher($this->unwrapper, $this->presenter)); $matchers->add(new Matcher\TypeMatcher($this->presenter)); $matchers->add(new Matcher\ObjectStateMatcher($this->presenter)); $matchers->add(new Matcher\ScalarMatcher($this->presenter)); $matchers->add(new Matcher\ArrayCountMatcher($this->presenter)); $matchers->add(new Matcher\ArrayKeyMatcher($this->presenter)); $matchers->add(new Matcher\ArrayContainMatcher($this->presenter)); $matchers->add(new Matcher\StringStartMatcher($this->presenter)); $matchers->add(new Matcher\StringEndMatcher($this->presenter)); $matchers->add(new Matcher\StringRegexMatcher($this->presenter)); if (!$context instanceof Matcher\MatchersProviderInterface) { return; } foreach ($context->getMatchers() as $name => $matcher) { if ($matcher instanceof Matcher\MatcherInterface) { $matchers->add($matcher); } else { $matchers->add(new Matcher\CallbackMatcher($name, $matcher, $this->presenter)); } } }
/** * @param ExampleNode $example * @param SpecificationInterface $context * @param MatcherManager $matchers * @param CollaboratorManager $collaborators */ public function prepare(ExampleNode $example, SpecificationInterface $context, MatcherManager $matchers, CollaboratorManager $collaborators) { $subjectFactory = new Wrapper($matchers, $this->presenter, $this->dispatcher, $example, $this->accessInspector); $subject = $subjectFactory->wrap(null); $subject->beAnInstanceOf($example->getSpecification()->getResource()->getSrcClassname()); $context->setSpecificationSubject($subject); }
/** * * @param ExampleNode $example * @param SpecificationInterface $context * @param MatcherManager $matchers * @param CollaboratorManager $collaborators */ public function prepare(ExampleNode $example, SpecificationInterface $context, MatcherManager $matchers, CollaboratorManager $collaborators) { $matchers->replace($this->defaultMatchers); if (!$context instanceof Matcher\MatchersProviderInterface) { return; } foreach ($context->getMatchers() as $name => $matcher) { if ($matcher instanceof Matcher\MatcherInterface) { $matchers->add($matcher); } else { $matchers->add(new Matcher\CallbackMatcher($name, $matcher, $this->presenter)); } } }