Kahlan\Plugin\Stub::registered PHP Method

registered() public static method

Checks if a stub has been registered for a hash
public static registered ( mixed $hash = null ) : boolean | array
$hash mixed An instance hash or a fully namespaced class name.
return boolean | array
    public static function registered($hash = null)
    {
        if (!func_num_args()) {
            return array_keys(static::$_registered);
        }
        return isset(static::$_registered[$hash]);
    }

Usage Example

Beispiel #1
0
     });
 });
 describe("::reset()", function () {
     beforeEach(function () {
         Stub::on('kahlan\\spec\\fixture\\plugin\\pointcut\\Foo')->method('foo', function () {
         });
         Stub::on('kahlan\\spec\\fixture\\plugin\\pointcut\\Bar')->method('bar', function () {
         });
     });
     it("clears all stubs", function () {
         Stub::reset();
         expect(Stub::registered())->toBe([]);
     });
     it("clears one stub", function () {
         Stub::reset('kahlan\\spec\\fixture\\plugin\\pointcut\\Foo');
         expect(Stub::registered())->toBe(['kahlan\\spec\\fixture\\plugin\\pointcut\\Bar']);
     });
 });
 describe("::_generateAbstractMethods()", function () {
     it("throws an exception when called with a non-existing class", function () {
         expect(function () {
             $stub = Stub::classname(['extends' => 'kahlan\\plugin\\Stub', 'methods' => ['::generateAbstractMethods']]);
             Stub::on($stub)->method('::generateAbstractMethods', function ($class) {
                 return static::_generateAbstractMethods($class);
             });
             $stub::generateAbstractMethods('some\\unexisting\\Class');
         })->toThrow(new IncompleteException('Unexisting parent class `some\\unexisting\\Class`'));
     });
 });
 describe("::create()", function () {
     before(function () {
All Usage Examples Of Kahlan\Plugin\Stub::registered