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

LazyDoubleSpec.php (2786B)


      1 <?php
      2 
      3 namespace spec\Prophecy\Doubler;
      4 
      5 use PhpSpec\ObjectBehavior;
      6 
      7 class LazyDoubleSpec extends ObjectBehavior
      8 {
      9     /**
     10      * @param \Prophecy\Doubler\Doubler $doubler
     11      */
     12     function let($doubler)
     13     {
     14         $this->beConstructedWith($doubler);
     15     }
     16 
     17     /**
     18      * @param \Prophecy\Prophecy\ProphecySubjectInterface $double
     19      */
     20     function it_returns_anonymous_double_instance_by_default($doubler, $double)
     21     {
     22         $doubler->double(null, array())->willReturn($double);
     23 
     24         $this->getInstance()->shouldReturn($double);
     25     }
     26 
     27     /**
     28      * @param \Prophecy\Prophecy\ProphecySubjectInterface $double
     29      * @param \ReflectionClass                            $class
     30      */
     31     function it_returns_class_double_instance_if_set($doubler, $double, $class)
     32     {
     33         $doubler->double($class, array())->willReturn($double);
     34 
     35         $this->setParentClass($class);
     36 
     37         $this->getInstance()->shouldReturn($double);
     38     }
     39 
     40     /**
     41      * @param \Prophecy\Prophecy\ProphecySubjectInterface $double1
     42      * @param \Prophecy\Prophecy\ProphecySubjectInterface $double2
     43      */
     44     function it_returns_same_double_instance_if_called_2_times(
     45         $doubler, $double1, $double2
     46     )
     47     {
     48         $doubler->double(null, array())->willReturn($double1);
     49         $doubler->double(null, array())->willReturn($double2);
     50 
     51         $this->getInstance()->shouldReturn($double2);
     52         $this->getInstance()->shouldReturn($double2);
     53     }
     54 
     55     function its_setParentClass_throws_ClassNotFoundException_if_class_not_found()
     56     {
     57         $this->shouldThrow('Prophecy\Exception\Doubler\ClassNotFoundException')
     58             ->duringSetParentClass('SomeUnexistingClass');
     59     }
     60 
     61     /**
     62      * @param \Prophecy\Prophecy\ProphecySubjectInterface $double
     63      */
     64     function its_setParentClass_throws_exception_if_prophecy_is_already_created(
     65         $doubler, $double
     66     )
     67     {
     68         $doubler->double(null, array())->willReturn($double);
     69 
     70         $this->getInstance();
     71 
     72         $this->shouldThrow('Prophecy\Exception\Doubler\DoubleException')
     73             ->duringSetParentClass('stdClass');
     74     }
     75 
     76     function its_addInterface_throws_InterfaceNotFoundException_if_no_interface_found()
     77     {
     78         $this->shouldThrow('Prophecy\Exception\Doubler\InterfaceNotFoundException')
     79             ->duringAddInterface('SomeUnexistingInterface');
     80     }
     81 
     82     /**
     83      * @param \Prophecy\Prophecy\ProphecySubjectInterface $double
     84      */
     85     function its_addInterface_throws_exception_if_prophecy_is_already_created(
     86         $doubler, $double
     87     )
     88     {
     89         $doubler->double(null, array())->willReturn($double);
     90 
     91         $this->getInstance();
     92 
     93         $this->shouldThrow('Prophecy\Exception\Doubler\DoubleException')
     94             ->duringAddInterface('ArrayAccess');
     95     }
     96 }