Missing test of Reflection::getConstants() method

This commit is contained in:
Meritoo
2019-08-11 12:24:55 +02:00
parent a86a10c51e
commit 462625caff

View File

@@ -458,6 +458,17 @@ class ReflectionTest extends BaseTestCase
static::assertNull(Reflection::getConstantValue(H::class, 'users')); 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() public function testGetConstantValue()
{ {
static::assertSame(H::LOREM, Reflection::getConstantValue(H::class, 'LOREM')); 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,
],
];
}
} }