diff options
author | Olivier Paroz <github@oparoz.com> | 2015-08-18 04:16:49 +0300 |
---|---|---|
committer | Olivier Paroz <github@oparoz.com> | 2015-08-18 04:16:49 +0300 |
commit | a5c1eb0a9b46c2463011f27a3edd58fbf4f32876 (patch) | |
tree | 589bbde528de6a725669693847e4a63fc5e37c6d /tests/api | |
parent | b9035581998136c19cf4bcb31fedd7f244d48bec (diff) |
Add Thumbnails API
Diffstat (limited to 'tests/api')
-rw-r--r-- | tests/api/GetThumbnailsCest.php | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/tests/api/GetThumbnailsCest.php b/tests/api/GetThumbnailsCest.php new file mode 100644 index 00000000..f81e647a --- /dev/null +++ b/tests/api/GetThumbnailsCest.php @@ -0,0 +1,80 @@ +<?php +/** + * ownCloud - gallery + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Olivier Paroz <owncloud@interfasys.ch> + * + * @copyright Olivier Paroz 2015 + */ + +use Page\Gallery as GalleryApp; + +/** + * Class GetThumbnailsCest + */ +class GetThumbnailsCest { + + private $apiUrl; + private $params = [ + 'square' => false, + 'scale' => 2.5 + ]; + + /** + * Sets up the environment for this series of tests + * + * @param ApiTester $I + */ + public function _before(ApiTester $I) { + $this->apiUrl = GalleryApp::$URL . 'api/thumbnails'; + } + + public function _after(ApiTester $I) { + } + + /** + * Connects to the API as an anonymous user + * + * @param \Step\Api\Anonymous $I + */ + public function unauthorizedAccess(\Step\Api\Anonymous $I) { + $I->connectToTheApi($this->apiUrl, 'the thumbnails API'); + } + + public function getFilesThumbnails(\Step\Api\User $I) { + $I->am('an app'); + $I->wantTo('get the thumbnails for the files in this folder'); + + $I->getUserCredentialsAndUseHttpAuthentication(); + $I->haveHttpHeader('Accept', 'text/event-stream'); + $data = $I->getFilesDataForFolder(''); + $id1 = $data[0]['id']; + $id2 = $data[1]['id']; + $this->params['ids'] = $id1.';'.$id2; + + $I->sendGET($this->apiUrl, $this->params); + $I->seeResponseCodeIs(200); + $I->seeHttpHeader('Content-type', 'text/event-stream;charset=UTF-8'); + $I->seeResponseContains('"status":200'); + $I->seeResponseContains('"fileid":"' . $id1 . '","status":200'); + $I->seeResponseContains('"fileid":"' . $id2 . '","status":200'); + + } + + public function getFileNotFoundCode(\Step\Api\User $I) { + $I->am('an app'); + $I->wantTo('receive 404 events when I send the wrong IDs'); + $I->getUserCredentialsAndUseHttpAuthentication(); + $I->haveHttpHeader('Accept', 'text/event-stream'); + $this->params['ids'] = '0;1'; + $I->sendGET($this->apiUrl, $this->params); + $I->seeResponseCodeIs(200); + $I->seeHttpHeader('Content-type', 'text/event-stream;charset=UTF-8'); + $I->seeResponseContains('"fileid":"0","status":404'); + $I->seeResponseContains('"fileid":"1","status":404'); + } + +} |