Skip to content

Commit fd0de48

Browse files
authored
chore(tests): Test to close #176 (#675)
1 parent 3043372 commit fd0de48

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/src/integration/class/class.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,17 @@
3333
$class->booleanProp = false;
3434
assert($class->booleanProp === false);
3535

36+
// Test Issue #176 - getter/setter methods should NOT be exposed, properties SHOULD be
37+
$testClassReflection = new ReflectionClass(TestClass::class);
38+
$methodNames = array_map(fn($m) => $m->getName(), $testClassReflection->getMethods());
39+
$propertyNames = array_map(fn($p) => $p->getName(), $testClassReflection->getProperties());
40+
assert(!in_array('get_string', $methodNames) && !in_array('getString', $methodNames), 'Getter methods should NOT appear in reflection');
41+
assert(!in_array('set_string', $methodNames) && !in_array('setString', $methodNames), 'Setter methods should NOT appear in reflection');
42+
assert(in_array('string', $propertyNames), 'Property "string" from getter/setter SHOULD appear in reflection');
43+
assert(in_array('number', $propertyNames), 'Property "number" from getter/setter SHOULD appear in reflection');
44+
assert(in_array('booleanProp', $propertyNames), 'Property "booleanProp" from #[php(prop)] SHOULD appear in reflection');
45+
assert($testClassReflection->getProperty('string')->isPublic(), 'Property "string" should be public');
46+
3647
// Call regular from object
3748
assert($class->staticCall('Php') === 'Hello Php');
3849

0 commit comments

Comments
 (0)