Controller = new Controller(); } /** * tearDown method * * @return void */ public function tearDown(): void { unset($this->Controller, $this->Component); parent::tearDown(); } /** * Data provider for testInitialization * * @return array */ public function dataProviderInitialization() { return [ [true, true, true], [false, true, true], [true, false, true], [true, true, false], [false, false, false], ]; } /** * Test initial setup * * @param bool $authentication Should use authentication component * @param booll $authorization Should use authorization component * @param booll $oneTimePass Should use OneTimePassword component * @throws \Exception * @dataProvider dataProviderInitialization * @return void */ public function testInitialization($authentication, $authorization, $oneTimePass) { Configure::write('Auth.AuthenticationComponent.load', $authentication); Configure::write('Auth.AuthorizationComponent.enable', $authorization); Configure::write('OneTimePasswordAuthenticator.login', $oneTimePass); $registry = new ComponentRegistry($this->Controller); $this->Component = new SetupComponent($registry); $this->Component->initialize([]); $this->assertSame($authentication, $this->Controller->components()->has('Authentication')); $this->assertSame($authorization, $this->Controller->components()->has('Authorization')); $this->assertSame($oneTimePass, $this->Controller->components()->has('OneTimePasswordAuthenticator')); } }