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

abstract_class.phpt (3465B)


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