From 462625caff7978477176ed9354b001503c82b5aa Mon Sep 17 00:00:00 2001 From: Meritoo Date: Sun, 11 Aug 2019 12:24:55 +0200 Subject: [PATCH] Missing test of Reflection::getConstants() method --- tests/Utilities/ReflectionTest.php | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/Utilities/ReflectionTest.php b/tests/Utilities/ReflectionTest.php index edf5344..44186d5 100644 --- a/tests/Utilities/ReflectionTest.php +++ b/tests/Utilities/ReflectionTest.php @@ -458,6 +458,17 @@ class ReflectionTest extends BaseTestCase static::assertNull(Reflection::getConstantValue(H::class, 'users')); } + /** + * @param object|string $class The object or name of object's class + * @param array $expected Expected constants + * + * @dataProvider provideClassToGetConstants + */ + public function testGetConstants($class, array $expected): void + { + static::assertSame($expected, Reflection::getConstants($class)); + } + public function testGetConstantValue() { static::assertSame(H::LOREM, Reflection::getConstantValue(H::class, 'LOREM')); @@ -749,4 +760,27 @@ class ReflectionTest extends BaseTestCase ], ]; } + + public function provideClassToGetConstants(): ?Generator + { + yield[ + new \stdClass(), + [], + ]; + + yield[ + \stdClass::class, + [], + ]; + + yield[ + H::class, + [ + 'DOLOR' => 'sit', + 'LOREM' => 'ipsum', + 'MAX_USERS' => 5, + 'MIN_USERS' => 2, + ], + ]; + } }