Fix doc blocks

This commit is contained in:
Joas Schilling 2015-11-18 12:53:20 +01:00
parent 6efa72867a
commit fbcdf17089
1 changed files with 42 additions and 34 deletions

View File

@ -60,6 +60,8 @@ class FeatureContext implements Context, SnippetAcceptingContext {
/** /**
* Parses the xml answer to get ocs response which doesn't match with * Parses the xml answer to get ocs response which doesn't match with
* http one in v1 of the api. * http one in v1 of the api.
* @param ResponseInterface $response
* @return string
*/ */
public function getOCSResponse($response) { public function getOCSResponse($response) {
return $response->xml()->meta[0]->statuscode; return $response->xml()->meta[0]->statuscode;
@ -67,6 +69,8 @@ class FeatureContext implements Context, SnippetAcceptingContext {
/** /**
* Parses the xml answer to get the array of users returned. * Parses the xml answer to get the array of users returned.
* @param ResponseInterface $resp
* @return array
*/ */
public function getArrayOfUsersResponded($resp) { public function getArrayOfUsersResponded($resp) {
$listCheckedElements = $resp->xml()->data[0]->users[0]->element; $listCheckedElements = $resp->xml()->data[0]->users[0]->element;
@ -76,6 +80,8 @@ class FeatureContext implements Context, SnippetAcceptingContext {
/** /**
* Parses the xml answer to get the array of groups returned. * Parses the xml answer to get the array of groups returned.
* @param ResponseInterface $resp
* @return array
*/ */
public function getArrayOfGroupsResponded($resp) { public function getArrayOfGroupsResponded($resp) {
$listCheckedElements = $resp->xml()->data[0]->groups[0]->element; $listCheckedElements = $resp->xml()->data[0]->groups[0]->element;
@ -85,6 +91,8 @@ class FeatureContext implements Context, SnippetAcceptingContext {
/** /**
* Parses the xml answer to get the array of subadmins returned. * Parses the xml answer to get the array of subadmins returned.
* @param ResponseInterface $resp
* @return array
*/ */
public function getArrayOfSubadminsResponded($resp) { public function getArrayOfSubadminsResponded($resp) {
$listCheckedElements = $resp->xml()->data[0]->element; $listCheckedElements = $resp->xml()->data[0]->element;
@ -94,6 +102,8 @@ class FeatureContext implements Context, SnippetAcceptingContext {
/** /**
* Parses the xml answer to get the array of apps returned. * Parses the xml answer to get the array of apps returned.
* @param ResponseInterface $resp
* @return array
*/ */
public function getArrayOfAppsResponded($resp) { public function getArrayOfAppsResponded($resp) {
$listCheckedElements = $resp->xml()->data[0]->apps[0]->element; $listCheckedElements = $resp->xml()->data[0]->apps[0]->element;
@ -108,10 +118,10 @@ class FeatureContext implements Context, SnippetAcceptingContext {
$a = array_map(function($subArray) { return $subArray[0]; }, $arrayOfArrays); $a = array_map(function($subArray) { return $subArray[0]; }, $arrayOfArrays);
return $a; return $a;
} }
/** /**
* @Then /^users returned are$/ * @Then /^users returned are$/
* @param \Behat\Gherkin\Node\TableNode|null $formData * @param \Behat\Gherkin\Node\TableNode|null $usersList
*/ */
public function theUsersShouldBe($usersList) { public function theUsersShouldBe($usersList) {
if ($usersList instanceof \Behat\Gherkin\Node\TableNode) { if ($usersList instanceof \Behat\Gherkin\Node\TableNode) {
@ -125,7 +135,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
/** /**
* @Then /^groups returned are$/ * @Then /^groups returned are$/
* @param \Behat\Gherkin\Node\TableNode|null $formData * @param \Behat\Gherkin\Node\TableNode|null $groupsList
*/ */
public function theGroupsShouldBe($groupsList) { public function theGroupsShouldBe($groupsList) {
if ($groupsList instanceof \Behat\Gherkin\Node\TableNode) { if ($groupsList instanceof \Behat\Gherkin\Node\TableNode) {
@ -139,7 +149,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
/** /**
* @Then /^subadmin groups returned are$/ * @Then /^subadmin groups returned are$/
* @param \Behat\Gherkin\Node\TableNode|null $formData * @param \Behat\Gherkin\Node\TableNode|null $groupsList
*/ */
public function theSubadminGroupsShouldBe($groupsList) { public function theSubadminGroupsShouldBe($groupsList) {
if ($groupsList instanceof \Behat\Gherkin\Node\TableNode) { if ($groupsList instanceof \Behat\Gherkin\Node\TableNode) {
@ -153,7 +163,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
/** /**
* @Then /^subadmin users returned are$/ * @Then /^subadmin users returned are$/
* @param \Behat\Gherkin\Node\TableNode|null $formData * @param \Behat\Gherkin\Node\TableNode|null $groupsList
*/ */
public function theSubadminUsersShouldBe($groupsList) { public function theSubadminUsersShouldBe($groupsList) {
$this->theSubadminGroupsShouldBe($groupsList); $this->theSubadminGroupsShouldBe($groupsList);
@ -161,7 +171,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
/** /**
* @Then /^apps returned are$/ * @Then /^apps returned are$/
* @param \Behat\Gherkin\Node\TableNode|null $formData * @param \Behat\Gherkin\Node\TableNode|null $appList
*/ */
public function theAppsShouldBe($appList) { public function theAppsShouldBe($appList) {
if ($appList instanceof \Behat\Gherkin\Node\TableNode) { if ($appList instanceof \Behat\Gherkin\Node\TableNode) {
@ -206,7 +216,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
*/ */
public function assureUserExists($user) { public function assureUserExists($user) {
try { try {
$this->userExists($user); $this->userExists($user);
} catch (\GuzzleHttp\Exception\ClientException $ex) { } catch (\GuzzleHttp\Exception\ClientException $ex) {
$previous_user = $this->currentUser; $previous_user = $this->currentUser;
$this->currentUser = "admin"; $this->currentUser = "admin";
@ -276,7 +286,6 @@ class FeatureContext implements Context, SnippetAcceptingContext {
} }
$this->response = $client->get($fullUrl, $options); $this->response = $client->get($fullUrl, $options);
$subadmins = array($user);
$respondedArray = $this->getArrayOfSubadminsResponded($this->response); $respondedArray = $this->getArrayOfSubadminsResponded($this->response);
sort($respondedArray); sort($respondedArray);
PHPUnit_Framework_Assert::assertContains($user, $respondedArray); PHPUnit_Framework_Assert::assertContains($user, $respondedArray);
@ -295,7 +304,6 @@ class FeatureContext implements Context, SnippetAcceptingContext {
} }
$this->response = $client->get($fullUrl, $options); $this->response = $client->get($fullUrl, $options);
$subadmins = array($user);
$respondedArray = $this->getArrayOfSubadminsResponded($this->response); $respondedArray = $this->getArrayOfSubadminsResponded($this->response);
sort($respondedArray); sort($respondedArray);
PHPUnit_Framework_Assert::assertNotContains($user, $respondedArray); PHPUnit_Framework_Assert::assertNotContains($user, $respondedArray);
@ -498,7 +506,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
*/ */
public function assureGroupExists($group) { public function assureGroupExists($group) {
try { try {
$this->groupExists($group); $this->groupExists($group);
} catch (\GuzzleHttp\Exception\ClientException $ex) { } catch (\GuzzleHttp\Exception\ClientException $ex) {
$previous_user = $this->currentUser; $previous_user = $this->currentUser;
$this->currentUser = "admin"; $this->currentUser = "admin";
@ -608,8 +616,8 @@ class FeatureContext implements Context, SnippetAcceptingContext {
$fileinfo = $finfo->file("./$filename", FILEINFO_MIME_TYPE); $fileinfo = $finfo->file("./$filename", FILEINFO_MIME_TYPE);
PHPUnit_Framework_Assert::assertEquals($fileinfo, "text/plain"); PHPUnit_Framework_Assert::assertEquals($fileinfo, "text/plain");
if (file_exists("./$filename")) { if (file_exists("./$filename")) {
unlink("./$filename"); unlink("./$filename");
} }
} }
/** /**
@ -624,7 +632,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
else{ else{
$token = $this->lastShareData->data->token; $token = $this->lastShareData->data->token;
} }
$fullUrl = substr($this->baseUrl, 0, -4) . "public.php/webdav"; $fullUrl = substr($this->baseUrl, 0, -4) . "public.php/webdav";
$options['auth'] = [$token, $password]; $options['auth'] = [$token, $password];
$options['save_to'] = "./$filename"; $options['save_to'] = "./$filename";
@ -633,8 +641,8 @@ class FeatureContext implements Context, SnippetAcceptingContext {
$fileinfo = $finfo->file("./$filename", FILEINFO_MIME_TYPE); $fileinfo = $finfo->file("./$filename", FILEINFO_MIME_TYPE);
PHPUnit_Framework_Assert::assertEquals($fileinfo, "text/plain"); PHPUnit_Framework_Assert::assertEquals($fileinfo, "text/plain");
if (file_exists("./$filename")) { if (file_exists("./$filename")) {
unlink("./$filename"); unlink("./$filename");
} }
} }
/** /**
@ -658,7 +666,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
/** /**
* @When /^Updating last share with$/ * @When /^Updating last share with$/
* @param \Behat\Gherkin\Node\TableNode|null $formData * @param \Behat\Gherkin\Node\TableNode|null $body
*/ */
public function updatingLastShare($body) { public function updatingLastShare($body) {
$share_id = $this->lastShareData->data[0]->id; $share_id = $this->lastShareData->data[0]->id;
@ -691,11 +699,11 @@ class FeatureContext implements Context, SnippetAcceptingContext {
public function createShare($user, public function createShare($user,
$path = null, $path = null,
$shareType = null, $shareType = null,
$shareWith = null, $shareWith = null,
$publicUpload = null, $publicUpload = null,
$password = null, $password = null,
$permissions = null){ $permissions = null){
$fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/apps/files_sharing/api/v{$this->sharingApiVersion}/shares"; $fullUrl = $this->baseUrl . "v{$this->apiVersion}.php/apps/files_sharing/api/v{$this->sharingApiVersion}/shares";
$client = new Client(); $client = new Client();
@ -708,26 +716,26 @@ class FeatureContext implements Context, SnippetAcceptingContext {
} }
$fd = []; $fd = [];
if (!is_null($path)){ if (!is_null($path)){
$fd['path'] = $path; $fd['path'] = $path;
} }
if (!is_null($shareType)){ if (!is_null($shareType)){
$fd['shareType'] = $shareType; $fd['shareType'] = $shareType;
} }
if (!is_null($shareWith)){ if (!is_null($shareWith)){
$fd['shareWith'] = $shareWith; $fd['shareWith'] = $shareWith;
} }
if (!is_null($publicUpload)){ if (!is_null($publicUpload)){
$fd['publicUpload'] = $publicUpload; $fd['publicUpload'] = $publicUpload;
} }
if (!is_null($password)){ if (!is_null($password)){
$fd['password'] = $password; $fd['password'] = $password;
} }
if (!is_null($permissions)){ if (!is_null($permissions)){
$fd['permissions'] = $permissions; $fd['permissions'] = $permissions;
} }
$options['body'] = $fd; $options['body'] = $fd;
try { try {
$this->response = $client->send($client->createRequest("POST", $fullUrl, $options)); $this->response = $client->send($client->createRequest("POST", $fullUrl, $options));
$this->lastShareData = $this->response->xml(); $this->lastShareData = $this->response->xml();
@ -740,7 +748,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
public function isExpectedUrl($possibleUrl, $finalPart){ public function isExpectedUrl($possibleUrl, $finalPart){
$baseUrlChopped = substr($this->baseUrl, 0, -4); $baseUrlChopped = substr($this->baseUrl, 0, -4);
$endCharacter = strlen($baseUrlChopped) + strlen($finalPart); $endCharacter = strlen($baseUrlChopped) + strlen($finalPart);
return (substr($possibleUrl,0,$endCharacter) == "$baseUrlChopped" . "$finalPart"); return (substr($possibleUrl,0,$endCharacter) == "$baseUrlChopped" . "$finalPart");
} }
public function isFieldInResponse($field, $contentExpected){ public function isFieldInResponse($field, $contentExpected){
@ -877,7 +885,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
public static function removeFile($path, $filename){ public static function removeFile($path, $filename){
if (file_exists("$path" . "$filename")) { if (file_exists("$path" . "$filename")) {
unlink("$path" . "$filename"); unlink("$path" . "$filename");
} }
} }
/** /**
@ -888,7 +896,7 @@ class FeatureContext implements Context, SnippetAcceptingContext {
file_put_contents("../../core/skeleton/" . "textfile" . "$i" . ".txt", "ownCloud test text file\n"); file_put_contents("../../core/skeleton/" . "textfile" . "$i" . ".txt", "ownCloud test text file\n");
} }
if (!file_exists("../../core/skeleton/FOLDER")) { if (!file_exists("../../core/skeleton/FOLDER")) {
mkdir("../../core/skeleton/FOLDER", 0777, true); mkdir("../../core/skeleton/FOLDER", 0777, true);
} }
} }
@ -899,9 +907,9 @@ class FeatureContext implements Context, SnippetAcceptingContext {
public static function removeFilesFromSkeleton(){ public static function removeFilesFromSkeleton(){
for ($i=0; $i<5; $i++){ for ($i=0; $i<5; $i++){
self::removeFile("../../core/skeleton/", "textfile" . "$i" . ".txt"); self::removeFile("../../core/skeleton/", "textfile" . "$i" . ".txt");
} }
if (!is_dir("../../core/skeleton/FOLDER")) { if (!is_dir("../../core/skeleton/FOLDER")) {
rmdir("../../core/skeleton/FOLDER"); rmdir("../../core/skeleton/FOLDER");
} }
} }