annotate vendor/phpspec/prophecy/spec/Prophecy/Argument/Token/LogicalAndTokenSpec.php @ 5:c69a71b4f40f

Add slideshow module
author Chris Cannam
date Thu, 07 Dec 2017 14:46:23 +0000
parents 4c8ae668cc8c
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 namespace spec\Prophecy\Argument\Token;
Chris@0 4
Chris@0 5 use PhpSpec\ObjectBehavior;
Chris@0 6 use Prophecy\Argument;
Chris@0 7 use Prophecy\Argument\Token\TokenInterface;
Chris@0 8
Chris@0 9 class LogicalAndTokenSpec extends ObjectBehavior
Chris@0 10 {
Chris@0 11 function it_implements_TokenInterface()
Chris@0 12 {
Chris@0 13 $this->beConstructedWith(array());
Chris@0 14 $this->shouldBeAnInstanceOf('Prophecy\Argument\Token\TokenInterface');
Chris@0 15 }
Chris@0 16
Chris@0 17 function it_is_not_last()
Chris@0 18 {
Chris@0 19 $this->beConstructedWith(array());
Chris@0 20 $this->shouldNotBeLast();
Chris@0 21 }
Chris@0 22
Chris@0 23 function it_generates_string_representation_from_all_tokens_imploded(
Chris@0 24 TokenInterface $token1,
Chris@0 25 TokenInterface $token2,
Chris@0 26 TokenInterface $token3
Chris@0 27 ) {
Chris@0 28 $token1->__toString()->willReturn('token_1');
Chris@0 29 $token2->__toString()->willReturn('token_2');
Chris@0 30 $token3->__toString()->willReturn('token_3');
Chris@0 31
Chris@0 32 $this->beConstructedWith(array($token1, $token2, $token3));
Chris@0 33 $this->__toString()->shouldReturn('bool(token_1 AND token_2 AND token_3)');
Chris@0 34 }
Chris@0 35
Chris@0 36 function it_wraps_non_token_arguments_into_ExactValueToken()
Chris@0 37 {
Chris@0 38 $this->beConstructedWith(array(15, '1985'));
Chris@0 39 $this->__toString()->shouldReturn("bool(exact(15) AND exact(\"1985\"))");
Chris@0 40 }
Chris@0 41
Chris@0 42 function it_scores_the_maximum_score_from_all_scores_returned_by_tokens(TokenInterface $token1, TokenInterface $token2)
Chris@0 43 {
Chris@0 44 $token1->scoreArgument(1)->willReturn(10);
Chris@0 45 $token2->scoreArgument(1)->willReturn(5);
Chris@0 46 $this->beConstructedWith(array($token1, $token2));
Chris@0 47 $this->scoreArgument(1)->shouldReturn(10);
Chris@0 48 }
Chris@0 49
Chris@0 50 function it_does_not_score_if_there_are_no_arguments_or_tokens()
Chris@0 51 {
Chris@0 52 $this->beConstructedWith(array());
Chris@0 53 $this->scoreArgument('any')->shouldReturn(false);
Chris@0 54 }
Chris@0 55
Chris@0 56 function it_does_not_score_if_either_of_tokens_does_not_score(TokenInterface $token1, TokenInterface $token2)
Chris@0 57 {
Chris@0 58 $token1->scoreArgument(1)->willReturn(10);
Chris@0 59 $token1->scoreArgument(2)->willReturn(false);
Chris@0 60
Chris@0 61 $token2->scoreArgument(1)->willReturn(false);
Chris@0 62 $token2->scoreArgument(2)->willReturn(10);
Chris@0 63
Chris@0 64 $this->beConstructedWith(array($token1, $token2));
Chris@0 65
Chris@0 66 $this->scoreArgument(1)->shouldReturn(false);
Chris@0 67 $this->scoreArgument(2)->shouldReturn(false);
Chris@0 68 }
Chris@0 69 }