예제 #1
0
 public function testDownloadWithWrongId()
 {
     $fileId = 99999;
     $filename = null;
     $this->mockGetResourceFromId($fileId, false);
     $redirect = new RedirectResponse($this->urlGenerator->linkToRoute($this->appName . '.page.error_page'));
     $response = $this->controller->download($fileId, $filename);
     $this->assertEquals($redirect->getRedirectURL(), $response->getRedirectURL());
 }
예제 #2
0
 public function testDownloadWithWrongId()
 {
     $fileId = 99999;
     $filename = null;
     $status = Http::STATUS_NOT_FOUND;
     $exception = new NotFoundServiceException('Not found');
     $this->mockGetResourceFromIdWithBadFile($this->downloadService, $fileId, $exception);
     $redirectUrl = '/index.php/app/error';
     $this->mockUrlToErrorPage($status, $redirectUrl);
     /** @type RedirectResponse $response */
     $response = $this->controller->download($fileId, $filename);
     $this->assertEquals($redirectUrl, $response->getRedirectURL());
     $this->assertEquals(Http::STATUS_TEMPORARY_REDIRECT, $response->getStatus());
     $this->assertEquals($exception->getMessage(), $response->getCookies()['galleryErrorMessage']['value']);
 }