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