assertTrue(is_callable($factory) || $factory instanceof LocatorInterface); } /** * Test get nonexistent factory */ public function testGetNonExistent(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Unknown repository type `Test`. Make sure you register a type before trying to use it.'); FactoryLocator::get('Test'); } /** * test add() */ public function testAdd(): void { FactoryLocator::add('MyType', new StubFactory()); $this->assertInstanceOf(LocatorInterface::class, FactoryLocator::get('MyType')); } /** * test drop() */ public function testDrop(): void { $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('Unknown repository type `Test`. Make sure you register a type before trying to use it.'); FactoryLocator::drop('Test'); FactoryLocator::get('Test'); } public function tearDown(): void { FactoryLocator::drop('Test'); FactoryLocator::drop('MyType'); parent::tearDown(); } }