Phockito::mock_class PHP Method

mock_class() static public method

Given a class name as a string, return a new class name as a string which acts as a mock of the passed class name. Probably not useful by itself until we start supporting static method stubbing
static public mock_class ( string $class ) : string
$class string - The class to mock
return string - The class that acts as a Phockito mock of the passed class
    static function mock_class($class)
    {
        $mockClass = self::build_test_double(false, $class);
        // If we've been given a type registrar, call it (we need to do this even if class exists, since PHPUnit resets globals, possibly de-registering between tests)
        $type_registrar = self::$type_registrar;
        if ($type_registrar) {
            $type_registrar::register_double($mockClass, $class, self::$_is_interface[$class]);
        }
        return $mockClass;
    }

Usage Example

Ejemplo n.º 1
0
 function testCanCreateMockOfStatic()
 {
     $mock = Phockito::mock_class('PhockitoTest_FooIsStatic');
     $this->assertNull($mock::Foo());
 }
All Usage Examples Of Phockito::mock_class