public function testShowAuthenticate() { $linkItem = \OCP\Share::getShareByToken($this->token, false); // Test without being authenticated $response = $this->shareController->showAuthenticate($this->token); $expectedResponse = new TemplateResponse($this->container['AppName'], 'authenticate', array(), 'guest'); $this->assertEquals($expectedResponse, $response); // Test with being authenticated for another file \OC::$server->getSession()->set('public_link_authenticated', $linkItem['id'] - 1); $response = $this->shareController->showAuthenticate($this->token); $expectedResponse = new TemplateResponse($this->container['AppName'], 'authenticate', array(), 'guest'); $this->assertEquals($expectedResponse, $response); // Test with being authenticated for the correct file \OC::$server->getSession()->set('public_link_authenticated', $linkItem['id']); $response = $this->shareController->showAuthenticate($this->token); $expectedResponse = new RedirectResponse($this->urlGenerator->linkToRoute('files_sharing.sharecontroller.showShare', array('token' => $this->token))); $this->assertEquals($expectedResponse, $response); }
public function testShowAuthenticateCorrectShare() { $share = \OC::$server->getShareManager()->newShare(); $share->setId(1); $this->shareManager->expects($this->once())->method('getShareByToken')->with('token')->willReturn($share); $this->session->method('exists')->with('public_link_authenticated')->willReturn(true); $this->session->method('get')->with('public_link_authenticated')->willReturn('1'); $this->urlGenerator->expects($this->once())->method('linkToRoute')->with('files_sharing.sharecontroller.showShare', ['token' => 'token'])->willReturn('redirect'); $response = $this->shareController->showAuthenticate('token'); $expectedResponse = new RedirectResponse('redirect'); $this->assertEquals($expectedResponse, $response); }