Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/gallery.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorOlivier Paroz <github@oparoz.com>2015-12-29 01:43:26 +0300
committerOlivier Paroz <github@oparoz.com>2016-03-11 21:22:19 +0300
commiteb217735509ac2b7d5020b31a6d936d376093848 (patch)
tree523dae0a1f680a11228fcd9c9a3f18151f9827c8 /tests
parent7055f6d64037852333c8f10fcacd436da2866800 (diff)
Add uploading support for registered users
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/GalleryUnitTest.php15
-rw-r--r--tests/unit/controller/PageControllerTest.php13
-rw-r--r--tests/unit/service/SearchMediaServiceTest.php62
3 files changed, 86 insertions, 4 deletions
diff --git a/tests/unit/GalleryUnitTest.php b/tests/unit/GalleryUnitTest.php
index 44b75913..625eecc7 100644
--- a/tests/unit/GalleryUnitTest.php
+++ b/tests/unit/GalleryUnitTest.php
@@ -93,7 +93,9 @@ abstract class GalleryUnitTest extends \Test\TestCase {
*
* @return \PHPUnit_Framework_MockObject_MockObject
*/
- protected function mockFile($fileId, $storageId = 'home::user', $isReadable = true, $path = ''
+ protected function mockFile(
+ $fileId, $storageId = 'home::user', $isReadable = true, $path = '',
+ $etag = "8603c11cd6c5d739f2c156c38b8db8c4", $size = 1024
) {
$storage = $this->mockGetStorage($storageId);
$file = $this->getMockBuilder('OCP\Files\File')
@@ -109,12 +111,19 @@ abstract class GalleryUnitTest extends \Test\TestCase {
->willReturn($isReadable);
$file->method('getPath')
->willReturn($path);
+ $file->method('getEtag')
+ ->willReturn($etag);
+ $file->method('getSize')
+ ->willReturn($size);
return $file;
}
- protected function mockJpgFile($fileId) {
- $file = $this->mockFile($fileId);
+ protected function mockJpgFile(
+ $fileId, $storageId = 'home::user', $isReadable = true, $path = '',
+ $etag = "8603c11cd6c5d739f2c156c38b8db8c4", $size = 1024
+ ) {
+ $file = $this->mockFile($fileId, $storageId, $isReadable, $path, $etag, $size);
$this->mockJpgFileMethods($file);
return $file;
diff --git a/tests/unit/controller/PageControllerTest.php b/tests/unit/controller/PageControllerTest.php
index 5eb0e6b0..d4612004 100644
--- a/tests/unit/controller/PageControllerTest.php
+++ b/tests/unit/controller/PageControllerTest.php
@@ -69,7 +69,12 @@ class PageControllerTest extends \Test\TestCase {
public function testIndex() {
- $params = ['appName' => $this->appName];
+ $url = 'http://owncloud/ajax/upload.php';
+ $this->mockUrlToUploadEndpoint($url);
+ $params = [
+ 'appName' => $this->appName,
+ 'uploadUrl' => $url
+ ];
$template = new TemplateResponse($this->appName, 'index', $params);
$response = $this->controller->index();
@@ -239,4 +244,10 @@ class PageControllerTest extends \Test\TestCase {
->willReturn($value);
}
+ private function mockUrlToUploadEndpoint($url) {
+ $this->urlGenerator->expects($this->once())
+ ->method('linkTo')
+ ->with('files', 'ajax/upload.php')
+ ->willReturn($url);
+ }
}
diff --git a/tests/unit/service/SearchMediaServiceTest.php b/tests/unit/service/SearchMediaServiceTest.php
index d22e3695..7e8b22d3 100644
--- a/tests/unit/service/SearchMediaServiceTest.php
+++ b/tests/unit/service/SearchMediaServiceTest.php
@@ -205,6 +205,68 @@ class SearchMediaServiceTest extends \Test\GalleryUnitTest {
$this->assertSame($result, sizeof($response));
}
+ public function providesFolderWithFilesData() {
+ $isReadable = true;
+ $mounted = false;
+ $mount = null;
+ $query = '.nomedia';
+ $queryResult = false;
+
+ $file1 = [
+ 'fileid' => 11111,
+ 'storageId' => 'home::user',
+ 'isReadable' => true,
+ 'path' => null,
+ 'etag' => "8603c11cd6c5d739f2c156c38b8db8c4",
+ 'size' => 1024,
+ 'mimetype' => 'image/jpeg'
+ ];
+
+
+ $folder1 = $this->mockFolder(
+ 'home::user', 545454, [
+ $this->mockJpgFile(
+ $file1['fileid'], $file1['storageId'], $file1['isReadable'], $file1['path'],
+ $file1['etag'], $file1['size']
+ )
+ ], $isReadable, $mounted, $mount, $query, $queryResult
+ );
+
+ return [
+ [
+ $folder1, [
+ [
+ 'path' => $file1['path'],
+ 'fileid' => $file1['fileid'],
+ 'mimetype' => $file1['mimetype'],
+ 'mtime' => null,
+ 'etag' => $file1['etag'],
+ 'size' => $file1['size']
+ ]
+ ]
+ ]
+ ];
+ }
+
+ /**
+ * @dataProvider providesFolderWithFilesData
+ *
+ * @param array $topFolder
+ * @param int $result
+ */
+ public function testPropertiesOfGetMediaFiles($topFolder, $result) {
+ $supportedMediaTypes = [
+ 'image/png',
+ 'image/jpeg',
+ 'image/gif'
+ ];
+ $features = [];
+
+ $response = $this->service->getMediaFiles($topFolder, $supportedMediaTypes, $features);
+
+ $this->assertSame($result, $response);
+ }
+
/**
* @expectedException \OCA\Gallery\Service\NotFoundServiceException
*/