selectedServer['auth_type'] = $type; $plugin = (new AuthenticationPluginFactory())->create(); $this->assertInstanceOf($class, $plugin); } /** @return iterable */ public static function providerForTestValidPlugins(): iterable { yield 'config plugin' => ['config', AuthenticationConfig::class]; yield 'cookie plugin' => ['Cookie', AuthenticationCookie::class]; yield 'http plugin' => ['HTTP', AuthenticationHttp::class]; yield 'sign on plugin' => ['signOn', AuthenticationSignon::class]; } public function testInvalidPlugin(): void { Config::getInstance()->selectedServer['auth_type'] = 'invalid'; $this->expectException(AuthenticationPluginException::class); $this->expectExceptionMessage('Invalid authentication method set in configuration: invalid'); (new AuthenticationPluginFactory())->create(); } public function testSameInstance(): void { $config = Config::getInstance(); $config->selectedServer['auth_type'] = 'cookie'; $factory = new AuthenticationPluginFactory(); $firstInstance = $factory->create(); $secondInstance = (new AuthenticationPluginFactory())->create(); $this->assertNotSame($firstInstance, $secondInstance); $thirdInstance = $factory->create(); $this->assertSame($firstInstance, $thirdInstance); $config->selectedServer['auth_type'] = 'config'; $forthInstance = $factory->create(); $this->assertSame($firstInstance, $forthInstance); } }