sessionMock = $this->getMockBuilder(Session::class) ->disableOriginalConstructor()->getMock(); $this->requestMock = $this->createMock(IRequest::class); $this->l10nMock = $this->getMockBuilder(IL10N::class) ->disableOriginalConstructor()->getMock(); $this->l10nMock->expects($this->any()) ->method('t') ->willReturnCallback(function ($message) { return $message; }); $this->encryptionManagerMock = $this->createMock(IManager::class); $this->controller = new StatusController('encryptionTest', $this->requestMock, $this->l10nMock, $this->sessionMock, $this->encryptionManagerMock); } /** * @dataProvider dataTestGetStatus * * @param string $status * @param string $expectedStatus */ public function testGetStatus($status, $expectedStatus) { $this->sessionMock->expects($this->once()) ->method('getStatus')->willReturn($status); $result = $this->controller->getStatus(); $data = $result->getData(); $this->assertSame($expectedStatus, $data['status']); } public function dataTestGetStatus() { return [ [Session::INIT_EXECUTED, 'interactionNeeded'], [Session::INIT_SUCCESSFUL, 'success'], [Session::NOT_INITIALIZED, 'interactionNeeded'], ['unknown', 'error'], ]; } }