/** * @param \Prophecy\Argument\Token\TokenInterface $token1 * @param \Prophecy\Argument\Token\TokenInterface $token2 */ function it_does_not_score_if_either_of_tokens_does_not_score($token1, $token2) { $token1->scoreArgument(1)->willReturn(10); $token1->scoreArgument(2)->willReturn(false); $token2->scoreArgument(1)->willReturn(false); $token2->scoreArgument(2)->willReturn(10); $this->beConstructedWith(array($token1, $token2)); $this->scoreArgument(1)->shouldReturn(false); $this->scoreArgument(2)->shouldReturn(false); }
function it_should_calculate_score_until_last_token(TokenInterface $token1, TokenInterface $token2, TokenInterface $token3) { $token1->scoreArgument('one')->willReturn(3); $token1->isLast()->willReturn(false); $token2->scoreArgument(2)->willReturn(7); $token2->isLast()->willReturn(true); $token3->scoreArgument($obj = new \stdClass())->willReturn(10); $token3->isLast()->willReturn(false); $this->beConstructedWith(array($token1, $token2, $token3)); $this->scoreArguments(array('one', 2, $obj))->shouldReturn(10); }
function it_scores_traversable_object_from_value_token(TokenInterface $value, \Iterator $object) { $object->current()->will(function ($args, $object) { $object->valid()->willReturn(false); return 'value'; }); $object->key()->willReturn('key'); $object->rewind()->willReturn(null); $object->next()->willReturn(null); $object->valid()->willReturn(true); $value->scoreArgument('value')->willReturn(2); $this->scoreArgument($object)->shouldBe(2); }
/** * @param \Prophecy\Argument\Token\ExactValueToken $key * @param \Prophecy\Argument\Token\TokenInterface $value * @param \ArrayAccess $object */ function it_does_not_score_array_accessible_object_if_key_and_value_tokens_do_not_score_same_entry($key, $value, $object) { $object->offsetExists('key')->willReturn(true); $object->offsetGet('key')->willReturn('value'); $key->getValue()->willReturn('key'); $value->scoreArgument('value')->willReturn(false); $key->scoreArgument('key')->willReturn(true); $this->scoreArgument($object)->shouldBe(false); }
/** * Scores 4 when preset token does not match the argument. * * @param $argument * * @return bool|int */ public function scoreArgument($argument) { return false === $this->token->scoreArgument($argument) ? 4 : false; }
/** * @param \Prophecy\Argument\Token\TokenInterface $value * @param \Iterator $object */ function it_scores_traversable_object_from_value_token($value, $object) { $object->current()->will(function ($args, $object) { $object->valid()->willReturn(FALSE); return 'value'; }); $object->key()->willReturn('key'); $object->rewind()->willReturn(NULL); $object->next()->willReturn(NULL); $object->valid()->willReturn(TRUE); $value->scoreArgument('value')->willReturn(2); $this->scoreArgument($object)->shouldBe(2); }
/** * Scores 4 when preset token does not match the argument. * * @param $argument * * @return bool|int */ public function scoreArgument($argument) { return FALSE === $this->token->scoreArgument($argument) ? 4 : FALSE; }