gluon-web-remote

Web remote Administration for big size of gluon routers
git clone git://archive.git.mtrnord.blog/MTRNord/gluon-web-remote.git
Log | Files | Refs | README

ArgumentsWildcardSpec.php (5532B)


      1 <?php
      2 
      3 namespace spec\Prophecy\Argument;
      4 
      5 use PhpSpec\ObjectBehavior;
      6 use Prophecy\Argument\Token\TokenInterface;
      7 
      8 class ArgumentsWildcardSpec extends ObjectBehavior
      9 {
     10     /**
     11      * @param \stdClass $object
     12      */
     13     function it_wraps_non_token_arguments_into_ExactValueToken($object)
     14     {
     15         $this->beConstructedWith(array(42, 'zet', $object));
     16 
     17         $class = get_class($object->getWrappedObject());
     18         $hash  = spl_object_hash($object->getWrappedObject());
     19 
     20         $this->__toString()->shouldReturn("exact(42), exact(\"zet\"), exact($class:$hash Object (\n    'objectProphecy' => Prophecy\Prophecy\ObjectProphecy Object (*Prophecy*)\n))");
     21     }
     22 
     23     /**
     24      * @param \Prophecy\Argument\Token\TokenInterface $token1
     25      * @param \Prophecy\Argument\Token\TokenInterface $token2
     26      * @param \Prophecy\Argument\Token\TokenInterface $token3
     27      */
     28     function it_generates_string_representation_from_all_tokens_imploded($token1, $token2, $token3)
     29     {
     30         $token1->__toString()->willReturn('token_1');
     31         $token2->__toString()->willReturn('token_2');
     32         $token3->__toString()->willReturn('token_3');
     33 
     34         $this->beConstructedWith(array($token1, $token2, $token3));
     35         $this->__toString()->shouldReturn('token_1, token_2, token_3');
     36     }
     37 
     38     /**
     39      * @param \Prophecy\Argument\Token\TokenInterface $token
     40      */
     41     function it_exposes_list_of_tokens($token)
     42     {
     43         $this->beConstructedWith(array($token));
     44 
     45         $this->getTokens()->shouldReturn(array($token));
     46     }
     47 
     48     function it_returns_score_of_1_if_there_are_no_tokens_and_arguments()
     49     {
     50         $this->beConstructedWith(array());
     51 
     52         $this->scoreArguments(array())->shouldReturn(1);
     53     }
     54 
     55     /**
     56      * @param \Prophecy\Argument\Token\TokenInterface $token1
     57      * @param \Prophecy\Argument\Token\TokenInterface $token2
     58      * @param \Prophecy\Argument\Token\TokenInterface $token3
     59      */
     60     function it_should_return_match_score_based_on_all_tokens_score($token1, $token2, $token3)
     61     {
     62         $token1->scoreArgument('one')->willReturn(3);
     63         $token1->isLast()->willReturn(false);
     64         $token2->scoreArgument(2)->willReturn(5);
     65         $token2->isLast()->willReturn(false);
     66         $token3->scoreArgument($obj = new \stdClass())->willReturn(10);
     67         $token3->isLast()->willReturn(false);
     68 
     69         $this->beConstructedWith(array($token1, $token2, $token3));
     70         $this->scoreArguments(array('one', 2, $obj))->shouldReturn(18);
     71     }
     72 
     73     /**
     74      * @param \Prophecy\Argument\Token\TokenInterface $token1
     75      * @param \Prophecy\Argument\Token\TokenInterface $token2
     76      * @param \Prophecy\Argument\Token\TokenInterface $token3
     77      */
     78     function it_returns_false_if_there_is_less_arguments_than_tokens($token1, $token2, $token3)
     79     {
     80         $token1->scoreArgument('one')->willReturn(3);
     81         $token1->isLast()->willReturn(false);
     82         $token2->scoreArgument(2)->willReturn(5);
     83         $token2->isLast()->willReturn(false);
     84         $token3->scoreArgument(null)->willReturn(false);
     85         $token3->isLast()->willReturn(false);
     86 
     87         $this->beConstructedWith(array($token1, $token2, $token3));
     88         $this->scoreArguments(array('one', 2))->shouldReturn(false);
     89     }
     90 
     91     /**
     92      * @param \Prophecy\Argument\Token\TokenInterface $token1
     93      * @param \Prophecy\Argument\Token\TokenInterface $token2
     94      * @param \Prophecy\Argument\Token\TokenInterface $token3
     95      */
     96     function it_returns_false_if_there_is_less_tokens_than_arguments($token1, $token2, $token3)
     97     {
     98         $token1->scoreArgument('one')->willReturn(3);
     99         $token1->isLast()->willReturn(false);
    100         $token2->scoreArgument(2)->willReturn(5);
    101         $token2->isLast()->willReturn(false);
    102         $token3->scoreArgument($obj = new \stdClass())->willReturn(10);
    103         $token3->isLast()->willReturn(false);
    104 
    105         $this->beConstructedWith(array($token1, $token2, $token3));
    106         $this->scoreArguments(array('one', 2, $obj, 4))->shouldReturn(false);
    107     }
    108 
    109     /**
    110      * @param \Prophecy\Argument\Token\TokenInterface $token1
    111      * @param \Prophecy\Argument\Token\TokenInterface $token2
    112      * @param \Prophecy\Argument\Token\TokenInterface $token3
    113      */
    114     function it_should_return_false_if_one_of_the_tokens_returns_false($token1, $token2, $token3)
    115     {
    116         $token1->scoreArgument('one')->willReturn(3);
    117         $token1->isLast()->willReturn(false);
    118         $token2->scoreArgument(2)->willReturn(false);
    119         $token2->isLast()->willReturn(false);
    120         $token3->scoreArgument($obj = new \stdClass())->willReturn(10);
    121         $token3->isLast()->willReturn(false);
    122 
    123         $this->beConstructedWith(array($token1, $token2, $token3));
    124         $this->scoreArguments(array('one', 2, $obj))->shouldReturn(false);
    125     }
    126 
    127     /**
    128      * @param \Prophecy\Argument\Token\TokenInterface $token1
    129      * @param \Prophecy\Argument\Token\TokenInterface $token2
    130      * @param \Prophecy\Argument\Token\TokenInterface $token3
    131      */
    132     function it_should_calculate_score_until_last_token($token1, $token2, $token3)
    133     {
    134         $token1->scoreArgument('one')->willReturn(3);
    135         $token1->isLast()->willReturn(false);
    136 
    137         $token2->scoreArgument(2)->willReturn(7);
    138         $token2->isLast()->willReturn(true);
    139 
    140         $token3->scoreArgument($obj = new \stdClass())->willReturn(10);
    141         $token3->isLast()->willReturn(false);
    142 
    143         $this->beConstructedWith(array($token1, $token2, $token3));
    144         $this->scoreArguments(array('one', 2, $obj))->shouldReturn(10);
    145     }
    146 }