diff --git a/tests/Unit/Screen/ScreenFillPublicPropertyTest.php b/tests/Unit/Screen/ScreenFillPublicPropertyTest.php index da41f352c..fbf5def60 100644 --- a/tests/Unit/Screen/ScreenFillPublicPropertyTest.php +++ b/tests/Unit/Screen/ScreenFillPublicPropertyTest.php @@ -7,6 +7,7 @@ use Orchid\Screen\Repository; use Orchid\Screen\Screen; use Orchid\Tests\TestUnitCase; +use Orchid\Tests\Unit\Screen\Screens\ScreenWithInheritedProperties; class ScreenFillPublicPropertyTest extends TestUnitCase { @@ -73,4 +74,29 @@ public function testFillPublicPropertyWithVariousValueTypes(): void $this->assertEquals($expectedValue, $this->screen->{$property}, "Failed asserting that property '$property' is set correctly."); } } + + /** + * Tests that the `getPublicPropertyNames` method correctly returns all public properties, + * including those defined in the parent class, ensuring they are accessible for filling. + */ + public function testGetPublicPropertyNamesIncludesInheritedProperties(): void + { + $screen = new ScreenWithInheritedProperties(); + + // Use reflection to access the protected method getPublicPropertyNames + $reflection = new \ReflectionClass($screen); + $method = $reflection->getMethod('getPublicPropertyNames'); + $method->setAccessible(true); + + // Invoke the protected method and get the result + $result = $method->invoke($screen); + + // Assert that the result contains all public properties, including those from the parent class + $this->assertEquals($result->all(), [ + 'childProperty1', + 'childProperty2', + 'parentProperty1', + 'parentProperty2', + ]); + } } diff --git a/tests/Unit/Screen/Screens/ParentScreen.php b/tests/Unit/Screen/Screens/ParentScreen.php new file mode 100644 index 000000000..ec92b6f15 --- /dev/null +++ b/tests/Unit/Screen/Screens/ParentScreen.php @@ -0,0 +1,16 @@ +