manager = $this->getMockBuilder(Manager::class)->disableOriginalConstructor()->getMock(); $this->userManager = $this->getMockBuilder(IUserManager::class)->getMock(); $this->mandatoryTwoFactor = $this->createMock(MandatoryTwoFactor::class); $this->initialState = $this->createMock(IInitialState::class); $this->admin = new Security( $this->manager, $this->userManager, $this->mandatoryTwoFactor, $this->initialState, $this->createMock(IURLGenerator::class) ); } /** * @return array */ public function encryptionSettingsProvider() { return [ [true], [false], ]; } /** * @dataProvider encryptionSettingsProvider * @param bool $enabled */ public function testGetFormWithOnlyOneBackend($enabled) { $this->manager ->expects($this->once()) ->method('isEnabled') ->willReturn($enabled); $this->manager ->expects($this->once()) ->method('isReady') ->willReturn($enabled); $this->manager ->expects($this->once()) ->method('getEncryptionModules') ->willReturn([]); $this->userManager ->expects($this->once()) ->method('getBackends') ->willReturn(['entry']); $expected = new TemplateResponse( 'settings', 'settings/admin/security', [], '' ); $this->assertEquals($expected, $this->admin->getForm()); } /** * @dataProvider encryptionSettingsProvider * @param bool $enabled */ public function testGetFormWithMultipleBackends($enabled) { $this->manager ->expects($this->once()) ->method('isEnabled') ->willReturn($enabled); $this->manager ->expects($this->once()) ->method('isReady') ->willReturn($enabled); $this->manager ->expects($this->once()) ->method('getEncryptionModules') ->willReturn([]); $this->userManager ->expects($this->once()) ->method('getBackends') ->willReturn(['entry', 'entry']); $expected = new TemplateResponse( 'settings', 'settings/admin/security', [ ], '' ); $this->assertEquals($expected, $this->admin->getForm()); } public function testGetSection() { $this->assertSame('security', $this->admin->getSection()); } public function testGetPriority() { $this->assertSame(10, $this->admin->getPriority()); } }