* @copyright Meritoo * * @internal * @covers \Meritoo\Common\Exception\Reflection\MissingChildClassesException */ class MissingChildClassesExceptionTest extends BaseTestCase { /** * Provides name of class that hasn't child classes, but it should, and expected exception's message * * @return Generator */ public function provideParentClass(): ?Generator { $template = 'The \'%s\' class requires one child class at least who will extend her (maybe is an abstract' .' class), but the child classes are missing. Did you forget to extend this class?'; yield [ MissingChildClassesException::class, sprintf($template, MissingChildClassesException::class), ]; yield [ [ new stdClass(), new stdClass(), ], sprintf($template, stdClass::class), ]; } public function testConstructorVisibilityAndArguments(): void { static::assertConstructorVisibilityAndArguments( MissingChildClassesException::class, OopVisibilityType::IS_PUBLIC, 3 ); } /** * @param array|object|string $parentClass Class that hasn't child classes, but it should. An array of objects, * strings, object or string. * @param string $expectedMessage Expected exception's message * * @dataProvider provideParentClass */ public function testCreate($parentClass, string $expectedMessage): void { $exception = MissingChildClassesException::create($parentClass); static::assertSame($expectedMessage, $exception->getMessage()); } }