public function testDispatchInternal() { //$app = $this->getMock( 'WikiaApp' ); $response = $this->object->dispatch(F::build('App'), new WikiaRequest(array('controller' => 'Test', 'method' => 'sendTest'))); $this->assertTrue($response->hasException()); $this->assertInstanceOf('WikiaException', $response->getException()); $this->assertEquals(WikiaResponse::RESPONSE_CODE_ERROR, $response->getCode()); }
public function testPermissionsException() { $this->mockGlobalVariable("wgNirvanaAccessRules", [["class" => "TestController", "method" => "index", "requiredPermissions" => ["write"]]]); $userMock = $this->getMockBuilder("User")->disableOriginalConstructor()->getMock(); $userMock->expects($this->once())->method("isAllowed")->with("write")->will($this->returnValue(false)); $this->mockGlobalVariable("wgUser", $userMock); $response = $this->object->dispatch(F::app(), new WikiaRequest(array('controller' => 'Test', 'method' => 'index'))); $this->assertNotNull($response->getException()); $this->assertInstanceOf("PermissionsException", $response->getException()); $this->assertEquals("Current User don't have required permissions: write", $response->getException()->getDetails()); }