diff options
author | Olivier Paroz <github@oparoz.com> | 2015-08-19 02:52:12 +0300 |
---|---|---|
committer | Olivier Paroz <github@oparoz.com> | 2015-08-19 02:52:13 +0300 |
commit | 7d393650e7e231a68038ccb9fd069cd95746806b (patch) | |
tree | 1ff0b8eab9bc03c84d995269b00afd40d928e0d8 /tests/_support | |
parent | 8a002c4633c896c531d60d4042fe5276172bb157 (diff) |
Add download API
Diffstat (limited to 'tests/_support')
-rw-r--r-- | tests/_support/ApiTester.php | 30 | ||||
-rw-r--r-- | tests/_support/Helper/Api.php | 14 | ||||
-rw-r--r-- | tests/_support/Helper/DataSetup.php | 10 | ||||
-rw-r--r-- | tests/_support/Step/Api/TokenUser.php | 33 | ||||
-rw-r--r-- | tests/_support/_generated/AcceptanceTesterActions.php | 17 | ||||
-rw-r--r-- | tests/_support/_generated/ApiTesterActions.php | 33 | ||||
-rw-r--r-- | tests/_support/_generated/IntegrationTesterActions.php | 17 |
7 files changed, 138 insertions, 16 deletions
diff --git a/tests/_support/ApiTester.php b/tests/_support/ApiTester.php index b7cec20a..41210a3c 100644 --- a/tests/_support/ApiTester.php +++ b/tests/_support/ApiTester.php @@ -15,12 +15,28 @@ * @method \Codeception\Lib\Friend haveFriend($name, $actorClass = null) * * @SuppressWarnings(PHPMD) -*/ -class ApiTester extends \Codeception\Actor -{ - use _generated\ApiTesterActions; + */ +class ApiTester extends \Codeception\Actor { + use _generated\ApiTesterActions; - /** - * Define custom actions here - */ + /** + * Define custom actions here + * + * @param array $file + * @param string $filename + */ + + public function downloadAFile($file, $filename = null) { + $I = $this; + if (!$filename) { + $filename = $file['name']; + } + $filename = urlencode($filename); + $I->seeResponseCodeIs(200); + $I->seeHttpHeader('Content-type', $file['mediatype'] . '; charset=utf-8'); + $I->seeHttpHeader( + 'Content-Disposition', 'attachment; filename*=UTF-8\'\'' . $filename . '; filename="' + . $filename . '"' + ); + } } diff --git a/tests/_support/Helper/Api.php b/tests/_support/Helper/Api.php index 005d1b0b..cb8bae42 100644 --- a/tests/_support/Helper/Api.php +++ b/tests/_support/Helper/Api.php @@ -36,6 +36,18 @@ class Api extends \Codeception\Module { * @throws \Codeception\Exception\ModuleException */ public function getFilesDataForFolder($folderPath) { - return $this->getModule('\Helper\DataSetup')->getFilesDataForFolder($folderPath); + return $this->getModule('\Helper\DataSetup') + ->getFilesDataForFolder($folderPath); + } + + /** + * @return mixed + * @throws \Codeception\Exception\ModuleException + */ + public function getSharedFile() { + $sharedFile['file'] = $this->getModule('\Helper\DataSetup')->sharedFile; + $sharedFile['token'] = $this->getModule('\Helper\DataSetup')->sharedFileToken; + + return $sharedFile; } } diff --git a/tests/_support/Helper/DataSetup.php b/tests/_support/Helper/DataSetup.php index 7e2cc8a1..1d721775 100644 --- a/tests/_support/Helper/DataSetup.php +++ b/tests/_support/Helper/DataSetup.php @@ -81,14 +81,14 @@ class DataSetup extends \Codeception\Module { public $sharedFolderName = 'shared1'; /** @var string */ public $sharedFolderToken; + /** @var string */ + public $passwordForFolderShare = 'p@ssw0rd4sh@re5'; /** @var File */ public $sharedFile; /** @var string */ public $sharedFileName = 'testimage-wide.png'; /** @var string */ public $sharedFileToken; - /** @var string */ - public $passwordForShares = 'p@ssw0rd4sh@re5'; /** @var CoreTestCase */ private $coreTestCase; @@ -365,8 +365,10 @@ class DataSetup extends \Codeception\Module { $this->server->getConfig() ->setAppValue('core', 'shareapi_allow_links', 'yes'); - // Set so that this case is always covered - $shareWith = $this->passwordForShares; + // Only password protect the folders + if ($nodeType === 'folder') { + $shareWith = $this->passwordForFolderShare; + } $shareType = \OCP\Share::SHARE_TYPE_LINK; } diff --git a/tests/_support/Step/Api/TokenUser.php b/tests/_support/Step/Api/TokenUser.php new file mode 100644 index 00000000..ceb2a434 --- /dev/null +++ b/tests/_support/Step/Api/TokenUser.php @@ -0,0 +1,33 @@ +<?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 + */ + +namespace Step\Api; + +class TokenUser extends \ApiTester { + + /** + * Retrieves the shared file and its token + */ + public function getSharedFileInformation() { + $I = $this; + $sharedFile = $I->getSharedFile(); + + $fileMetaData = [ + 'name' => $sharedFile['file']->getName(), + 'mediatype' => $sharedFile['file']->getMimetype(), + 'token' => $sharedFile['token'] + ]; + + return $fileMetaData; + } + +} diff --git a/tests/_support/_generated/AcceptanceTesterActions.php b/tests/_support/_generated/AcceptanceTesterActions.php index 395ff204..2a50444f 100644 --- a/tests/_support/_generated/AcceptanceTesterActions.php +++ b/tests/_support/_generated/AcceptanceTesterActions.php @@ -1,4 +1,4 @@ -<?php //[STAMP] eea54e8c0b1094a11a5b2dda9348d860 +<?php //[STAMP] 090a923f8af576070553f88011b5ec00 namespace _generated; // This class was automatically generated by build task @@ -20,6 +20,21 @@ trait AcceptanceTesterActions /** * [!] Method is generated. Documentation taken from corresponding module. * + * Returns a list of ids available in the given folder + * + * @param string $folderPath + * + * @return array<string,int|string> + * @see \Helper\DataSetup::getFilesDataForFolder() + */ + public function getFilesDataForFolder($folderPath) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('getFilesDataForFolder', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * * Changes the subdomain for the 'url' configuration parameter. * Does not open a page; use `amOnPage` for that. * diff --git a/tests/_support/_generated/ApiTesterActions.php b/tests/_support/_generated/ApiTesterActions.php index a64a4d27..d3c031be 100644 --- a/tests/_support/_generated/ApiTesterActions.php +++ b/tests/_support/_generated/ApiTesterActions.php @@ -1,4 +1,4 @@ -<?php //[STAMP] 0f88c0cce4c0d1b1984d8ae16fa4644b +<?php //[STAMP] fca24ce90a907d625b57471272f29c22 namespace _generated; // This class was automatically generated by build task @@ -20,7 +20,9 @@ trait ApiTesterActions /** * [!] Method is generated. Documentation taken from corresponding module. * - * @return mixed + * Retrieves the user's credentials from the test data + * + * @return mixed * @throws \Codeception\Exception\ModuleException * @see \Helper\Api::getUserCredentials() */ @@ -44,6 +46,33 @@ trait ApiTesterActions /** * [!] Method is generated. Documentation taken from corresponding module. * + * Returns a list of ids available in the given folder + * + * @param string $folderPath + * + * @return array<string,int|string> + * @see \Helper\DataSetup::getFilesDataForFolder() + */ + public function getFilesDataForFolder($folderPath) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('getFilesDataForFolder', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * @return mixed + * @throws \Codeception\Exception\ModuleException + * @see \Helper\Api::getSharedFile() + */ + public function getSharedFile() { + return $this->getScenario()->runStep(new \Codeception\Step\Action('getSharedFile', func_get_args())); + } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * * Sets HTTP header * * @param $name diff --git a/tests/_support/_generated/IntegrationTesterActions.php b/tests/_support/_generated/IntegrationTesterActions.php index e60628a5..2dea9391 100644 --- a/tests/_support/_generated/IntegrationTesterActions.php +++ b/tests/_support/_generated/IntegrationTesterActions.php @@ -1,4 +1,4 @@ -<?php //[STAMP] cd0096ba11e9960cf9250dc3d5fee0ee +<?php //[STAMP] 2ab543bb9cfa3d42406c0d655af4c148 namespace _generated; // This class was automatically generated by build task @@ -346,4 +346,19 @@ trait IntegrationTesterActions public function fail($message) { return $this->getScenario()->runStep(new \Codeception\Step\Action('fail', func_get_args())); } + + + /** + * [!] Method is generated. Documentation taken from corresponding module. + * + * Returns a list of ids available in the given folder + * + * @param string $folderPath + * + * @return array<string,int|string> + * @see \Helper\DataSetup::getFilesDataForFolder() + */ + public function getFilesDataForFolder($folderPath) { + return $this->getScenario()->runStep(new \Codeception\Step\Action('getFilesDataForFolder', func_get_args())); + } } |