Phockito::spy_class PHP Method

spy_class() static public method

static public spy_class ( $class )
    static function spy_class($class)
    {
        $spyClass = self::build_test_double(true, $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($spyClass, $class, self::$_is_interface[$class]);
        }
        return $spyClass;
    }

Usage Example

 function testImplementsInjectionOfAClassDouble()
 {
     global $_PSST_ALL_CLASSES;
     $class = Phockito::spy_class('PhockitoSilverStripeTest_Implementor');
     $this->assertTrue(array_key_exists($class, $_PSST_ALL_CLASSES['implementors']['PhockitoSilverStripeTest_Interface']));
 }