Skip to content
Snippets Groups Projects
Unverified Commit ff3f63fd authored by Roeland Jago Douma's avatar Roeland Jago Douma
Browse files

Fix PublicPreviewControllerTests

parent 20e51469
No related branches found
No related tags found
No related merge requests found
...@@ -33,6 +33,7 @@ use OCP\Files\NotFoundException; ...@@ -33,6 +33,7 @@ use OCP\Files\NotFoundException;
use OCP\Files\SimpleFS\ISimpleFile; use OCP\Files\SimpleFS\ISimpleFile;
use OCP\IPreview; use OCP\IPreview;
use OCP\IRequest; use OCP\IRequest;
use OCP\ISession;
use OCP\Share\Exceptions\ShareNotFound; use OCP\Share\Exceptions\ShareNotFound;
use OCP\Share\IManager; use OCP\Share\IManager;
use OCP\Share\IShare; use OCP\Share\IShare;
...@@ -60,26 +61,27 @@ class PublicPreviewControllerTest extends TestCase { ...@@ -60,26 +61,27 @@ class PublicPreviewControllerTest extends TestCase {
'files_sharing', 'files_sharing',
$this->createMock(IRequest::class), $this->createMock(IRequest::class),
$this->shareManager, $this->shareManager,
$this->createMock(ISession::class),
$this->previewManager $this->previewManager
); );
} }
public function testInvalidToken() { public function testInvalidToken() {
$res = $this->controller->getPreview('file', 10, 10, ''); $res = $this->controller->getPreview('', 'file', 10, 10, '');
$expected = new DataResponse([], Http::STATUS_BAD_REQUEST); $expected = new DataResponse([], Http::STATUS_BAD_REQUEST);
$this->assertEquals($expected, $res); $this->assertEquals($expected, $res);
} }
public function testInvalidWidth() { public function testInvalidWidth() {
$res = $this->controller->getPreview('file', 0); $res = $this->controller->getPreview('token', 'file', 0);
$expected = new DataResponse([], Http::STATUS_BAD_REQUEST); $expected = new DataResponse([], Http::STATUS_BAD_REQUEST);
$this->assertEquals($expected, $res); $this->assertEquals($expected, $res);
} }
public function testInvalidHeight() { public function testInvalidHeight() {
$res = $this->controller->getPreview('file', 10, 0); $res = $this->controller->getPreview('token', 'file', 10, 0);
$expected = new DataResponse([], Http::STATUS_BAD_REQUEST); $expected = new DataResponse([], Http::STATUS_BAD_REQUEST);
$this->assertEquals($expected, $res); $this->assertEquals($expected, $res);
...@@ -90,7 +92,7 @@ class PublicPreviewControllerTest extends TestCase { ...@@ -90,7 +92,7 @@ class PublicPreviewControllerTest extends TestCase {
->with($this->equalTo('token')) ->with($this->equalTo('token'))
->willThrowException(new ShareNotFound()); ->willThrowException(new ShareNotFound());
$res = $this->controller->getPreview('file', 10, 10, 'token'); $res = $this->controller->getPreview('token', 'file', 10, 10);
$expected = new DataResponse([], Http::STATUS_NOT_FOUND); $expected = new DataResponse([], Http::STATUS_NOT_FOUND);
$this->assertEquals($expected, $res); $this->assertEquals($expected, $res);
...@@ -105,7 +107,7 @@ class PublicPreviewControllerTest extends TestCase { ...@@ -105,7 +107,7 @@ class PublicPreviewControllerTest extends TestCase {
$share->method('getPermissions') $share->method('getPermissions')
->willReturn(0); ->willReturn(0);
$res = $this->controller->getPreview('file', 10, 10, 'token'); $res = $this->controller->getPreview('token', 'file', 10, 10);
$expected = new DataResponse([], Http::STATUS_FORBIDDEN); $expected = new DataResponse([], Http::STATUS_FORBIDDEN);
$this->assertEquals($expected, $res); $this->assertEquals($expected, $res);
...@@ -132,7 +134,7 @@ class PublicPreviewControllerTest extends TestCase { ...@@ -132,7 +134,7 @@ class PublicPreviewControllerTest extends TestCase {
$preview->method('getMimeType') $preview->method('getMimeType')
->willReturn('myMime'); ->willReturn('myMime');
$res = $this->controller->getPreview('file', 10, 10, 'token', true); $res = $this->controller->getPreview('token', 'file', 10, 10, true);
$expected = new FileDisplayResponse($preview, Http::STATUS_OK, ['Content-Type' => 'myMime']); $expected = new FileDisplayResponse($preview, Http::STATUS_OK, ['Content-Type' => 'myMime']);
$this->assertEquals($expected, $res); $this->assertEquals($expected, $res);
} }
...@@ -154,7 +156,7 @@ class PublicPreviewControllerTest extends TestCase { ...@@ -154,7 +156,7 @@ class PublicPreviewControllerTest extends TestCase {
->with($this->equalTo('file')) ->with($this->equalTo('file'))
->willThrowException(new NotFoundException()); ->willThrowException(new NotFoundException());
$res = $this->controller->getPreview('file', 10, 10, 'token', true); $res = $this->controller->getPreview('token', 'file', 10, 10, true);
$expected = new DataResponse([], Http::STATUS_NOT_FOUND); $expected = new DataResponse([], Http::STATUS_NOT_FOUND);
$this->assertEquals($expected, $res); $this->assertEquals($expected, $res);
} }
...@@ -186,7 +188,7 @@ class PublicPreviewControllerTest extends TestCase { ...@@ -186,7 +188,7 @@ class PublicPreviewControllerTest extends TestCase {
$preview->method('getMimeType') $preview->method('getMimeType')
->willReturn('myMime'); ->willReturn('myMime');
$res = $this->controller->getPreview('file', 10, 10, 'token', true); $res = $this->controller->getPreview('token', 'file', 10, 10, true);
$expected = new FileDisplayResponse($preview, Http::STATUS_OK, ['Content-Type' => 'myMime']); $expected = new FileDisplayResponse($preview, Http::STATUS_OK, ['Content-Type' => 'myMime']);
$this->assertEquals($expected, $res); $this->assertEquals($expected, $res);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment