예제 #1
0
 public function testMock()
 {
     $manager = ClassManager::getInstance();
     $manager->register('StaticMock\\MethodReplacer\\A', 'a', function () {
         return 3;
     });
     $manager->register('StaticMock\\MethodReplacer\\B', 'b', function () {
         return 4;
     });
     $this->assertEquals(3, A::a());
     $this->assertEquals(4, B::b());
     $manager->deregister('StaticMock\\MethodReplacer\\A', 'a');
     $manager->deregister('StaticMock\\MethodReplacer\\B', 'b');
     $this->assertEquals(1, A::a());
     $this->assertEquals(2, B::b());
 }
 /**
  * Replace the method implementation
  *
  * @param string $class_name
  * @param string $method_name
  * @param callable $callable
  */
 public function replace($class_name, $method_name, \Closure $callable)
 {
     ClassManager::getInstance()->register($class_name, $method_name, $callable);
     $this->class_and_methods[] = array($class_name, $method_name);
 }