BetterReflectionTest\Reflection\ReflectionClassTest::testIsSubclassOf PHP Method

testIsSubclassOf() public method

public testIsSubclassOf ( )
    public function testIsSubclassOf()
    {
        $sourceLocator = new SingleFileSourceLocator(__DIR__ . '/../Fixture/ClassWithInterfaces.php');
        $subExampleClass = (new ClassReflector($sourceLocator))->reflect(ClassWithInterfaces\SubExampleClass::class);
        $this->assertFalse($subExampleClass->isSubclassOf(ClassWithInterfaces\SubExampleClass::class), 'Not a subclass of itself');
        $this->assertFalse($subExampleClass->isSubclassOf(ClassWithInterfaces\SubSubExampleClass::class), 'Not a subclass of a child class');
        $this->assertFalse($subExampleClass->isSubclassOf(\stdClass::class), 'Not a subclass of a unrelated');
        $this->assertTrue($subExampleClass->isSubclassOf(ClassWithInterfaces\ExampleClass::class), 'A subclass of a parent class');
        $this->assertTrue($subExampleClass->isSubclassOf('\\' . ClassWithInterfaces\ExampleClass::class), 'A subclass of a parent class (considering eventual backslashes upfront)');
        $this->expectException(NotAString::class);
        $subExampleClass->isSubclassOf($this);
    }
ReflectionClassTest