Skip to content

Commit

Permalink
Improved ReflectorCompatibilityTest
Browse files Browse the repository at this point in the history
  • Loading branch information
vudaltsov committed Mar 3, 2024
1 parent 3398f97 commit 9aa53c0
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions tests/Reflection/ReflectorCompatibilityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ private function assertClassEquals(\ReflectionClass $native, ClassReflection $ty
self::assertSame($native->name, $typhoon->name, 'class.name');
self::assertSame($native->__toString(), $typhoon->__toString(), 'class.__toString()');
self::assertAttributesEqual($native->getAttributes(), $typhoon->getAttributes(), 'class.getAttributes()');
// getConstant() see below
// getConstants() see below
self::assertSame($native->getConstructor()?->name, $typhoon->getConstructor()?->name, 'class.getConstructor().name');
self::assertSame($native->getDefaultProperties(), $typhoon->getDefaultProperties(), 'class.getDefaultProperties()');
self::assertSame($native->getDocComment(), $typhoon->getDocComment(), 'class.getDocComment()');
Expand All @@ -73,26 +71,17 @@ private function assertClassEquals(\ReflectionClass $native, ClassReflection $ty
self::assertSame($native->getFileName(), $typhoon->getFileName(), 'class.getFileName()');
self::assertSame($native->getInterfaceNames(), $typhoon->getInterfaceNames(), 'class.getInterfaceNames()');
$this->assertSameNames($native->getInterfaces(), $typhoon->getInterfaces(), 'class.getInterfaces().name');
// getMethods() see below
// getMethod() see below
self::assertSame($native->getModifiers(), $typhoon->getModifiers(), 'class.getModifiers()');
self::assertSame($native->getName(), $typhoon->getName(), 'class.getName()');
self::assertSame($native->getNamespaceName(), $typhoon->getNamespaceName(), 'class.getNamespaceName()');
self::assertSame(($native->getParentClass() ?: null)?->name, ($typhoon->getParentClass() ?: null)?->name, 'class.getParentClass().name');
// getProperties() see below
// getProperty() see below
// getReflectionConstant() see below
// getReflectionConstants() see below
self::assertSame($native->getShortName(), $typhoon->getShortName(), 'class.getShortName()');
self::assertSame($native->getStartLine(), $typhoon->getStartLine(), 'class.getStartLine()');
self::assertSame($native->getStaticProperties(), $typhoon->getStaticProperties(), 'class.getStaticProperties()');
// getStaticPropertyValue()
// TODO getStaticPropertyValue()
self::assertSame($native->getTraitAliases(), $typhoon->getTraitAliases(), 'class.getTraitAliases()');
self::assertSame($native->getTraitNames(), $typhoon->getTraitNames(), 'class.getTraitNames()');
$this->assertSameNames($native->getTraits(), $typhoon->getTraits(), 'class.getTraits().name');
// hasConstant() see below
// hasMethod() see below
// hasProperty() see below
foreach ($this->getClasses($native) as $class) {
$this->assertResultOrExceptionEqual(
native: static fn(): bool => $native->implementsInterface($class),
Expand Down Expand Up @@ -133,6 +122,8 @@ private function assertClassEquals(\ReflectionClass $native, ClassReflection $ty
}
// TODO setStaticPropertyValue()

// CONSTANTS

self::assertSame($native->getConstants(), $typhoon->getConstants(), 'class.getConstants().name');
self::assertSame($native->getConstants(\ReflectionClassConstant::IS_PUBLIC), $typhoon->getConstants(PropertyReflection::IS_PUBLIC), 'class.getConstants(IS_PUBLIC).name');
self::assertSame($native->getConstants(\ReflectionClassConstant::IS_PROTECTED), $typhoon->getConstants(PropertyReflection::IS_PROTECTED), 'class.getConstants(IS_PROTECTED).name');
Expand All @@ -153,6 +144,8 @@ private function assertClassEquals(\ReflectionClass $native, ClassReflection $ty
$this->assertConstantEquals($nativeConstant, $typhoonConstant, "class.getReflectionConstant({$nativeConstant->name})");
}

// PROPERTIES

$this->assertSameNames($native->getProperties(), $typhoon->getProperties(), 'class.getProperties().name');
$this->assertSameNames($native->getProperties(\ReflectionProperty::IS_PUBLIC), $typhoon->getProperties(PropertyReflection::IS_PUBLIC), 'class.getProperties(IS_PUBLIC).name');
$this->assertSameNames($native->getProperties(\ReflectionProperty::IS_PROTECTED), $typhoon->getProperties(PropertyReflection::IS_PROTECTED), 'class.getProperties(IS_PROTECTED).name');
Expand All @@ -165,6 +158,8 @@ private function assertClassEquals(\ReflectionClass $native, ClassReflection $ty
$this->assertPropertyEquals($nativeProperty, $typhoon->getProperty($nativeProperty->name), "class.getProperty({$nativeProperty->name})");
}

// METHODS

$this->assertSameNames($native->getMethods(), $typhoon->getMethods(), 'class.getMethods().name');
$this->assertSameNames($native->getMethods(\ReflectionMethod::IS_FINAL), $typhoon->getMethods(MethodReflection::IS_FINAL), 'class.getMethods(IS_FINAL).name');
$this->assertSameNames($native->getMethods(\ReflectionMethod::IS_ABSTRACT), $typhoon->getMethods(MethodReflection::IS_ABSTRACT), 'class.getMethods(IS_ABSTRACT).name');
Expand Down

0 comments on commit 9aa53c0

Please sign in to comment.