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

namespaced_class.phpt (2963B)


      1 --TEST--
      2 PHPUnit_Framework_MockObject_Generator::generate('NS\Foo', array(), 'MockFoo', TRUE, TRUE)
      3 --FILE--
      4 <?php
      5 namespace NS;
      6 
      7 class Foo
      8 {
      9     public function bar(Foo $foo)
     10     {
     11     }
     12 
     13     public function baz(Foo $foo)
     14     {
     15     }
     16 }
     17 
     18 require __DIR__ . '/../../vendor/autoload.php';
     19 
     20 $generator = new \PHPUnit_Framework_MockObject_Generator;
     21 
     22 $mock = $generator->generate(
     23   'NS\Foo',
     24   array(),
     25   'MockFoo',
     26   TRUE,
     27   TRUE
     28 );
     29 
     30 print $mock['code'];
     31 ?>
     32 --EXPECTF--
     33 class MockFoo extends NS\Foo implements PHPUnit_Framework_MockObject_MockObject
     34 {
     35     private $__phpunit_invocationMocker;
     36     private $__phpunit_originalObject;
     37 
     38     public function __clone()
     39     {
     40         $this->__phpunit_invocationMocker = clone $this->__phpunit_getInvocationMocker();
     41     }
     42 
     43     public function bar(NS\Foo $foo)
     44     {
     45         $arguments = array($foo);
     46         $count     = func_num_args();
     47 
     48         if ($count > 1) {
     49             $_arguments = func_get_args();
     50 
     51             for ($i = 1; $i < $count; $i++) {
     52                 $arguments[] = $_arguments[$i];
     53             }
     54         }
     55 
     56         $result = $this->__phpunit_getInvocationMocker()->invoke(
     57           new PHPUnit_Framework_MockObject_Invocation_Object(
     58             'NS\Foo', 'bar', $arguments, $this, TRUE
     59           )
     60         );
     61 
     62         return $result;
     63     }
     64 
     65     public function baz(NS\Foo $foo)
     66     {
     67         $arguments = array($foo);
     68         $count     = func_num_args();
     69 
     70         if ($count > 1) {
     71             $_arguments = func_get_args();
     72 
     73             for ($i = 1; $i < $count; $i++) {
     74                 $arguments[] = $_arguments[$i];
     75             }
     76         }
     77 
     78         $result = $this->__phpunit_getInvocationMocker()->invoke(
     79           new PHPUnit_Framework_MockObject_Invocation_Object(
     80             'NS\Foo', 'baz', $arguments, $this, TRUE
     81           )
     82         );
     83 
     84         return $result;
     85     }
     86 
     87     public function expects(PHPUnit_Framework_MockObject_Matcher_Invocation $matcher)
     88     {
     89         return $this->__phpunit_getInvocationMocker()->expects($matcher);
     90     }
     91 
     92     public function method()
     93     {
     94         $any = new PHPUnit_Framework_MockObject_Matcher_AnyInvokedCount;
     95         $expects = $this->expects($any);
     96         return call_user_func_array(array($expects, 'method'), func_get_args());
     97     }
     98 
     99     public function __phpunit_setOriginalObject($originalObject)
    100     {
    101         $this->__phpunit_originalObject = $originalObject;
    102     }
    103 
    104     public function __phpunit_getInvocationMocker()
    105     {
    106         if ($this->__phpunit_invocationMocker === NULL) {
    107             $this->__phpunit_invocationMocker = new PHPUnit_Framework_MockObject_InvocationMocker;
    108         }
    109 
    110         return $this->__phpunit_invocationMocker;
    111     }
    112 
    113     public function __phpunit_hasMatchers()
    114     {
    115         return $this->__phpunit_getInvocationMocker()->hasMatchers();
    116     }
    117 
    118     public function __phpunit_verify()
    119     {
    120         $this->__phpunit_getInvocationMocker()->verify();
    121         $this->__phpunit_invocationMocker = NULL;
    122     }
    123 }