From bb9f5686543531ccb55a59eb003cd6f83991b398 Mon Sep 17 00:00:00 2001 From: Sergio Bertolin Date: Tue, 6 Oct 2015 16:37:55 +0000 Subject: [PATCH 1/4] lists getting ready --- .../features/bootstrap/FeatureContext.php | 37 +++++++++++++++++++ .../features/provisioning-v1.feature | 7 ++++ 2 files changed, 44 insertions(+) diff --git a/build/integration/features/bootstrap/FeatureContext.php b/build/integration/features/bootstrap/FeatureContext.php index 9676fc8ca40..99d030fa6fc 100644 --- a/build/integration/features/bootstrap/FeatureContext.php +++ b/build/integration/features/bootstrap/FeatureContext.php @@ -58,6 +58,43 @@ class FeatureContext extends BehatContext { return $response->xml()->meta[0]->statuscode; } + /** + * Parses the xml answer to get the array of users returned. + */ + public function getArrayOfUsersResponded($resp) { + $listCheckedElements = $resp->xml()->data[0]->users[0]->element; + $extractedElementsArray = json_decode( json_encode($listCheckedElements) , 1); + return $extractedElementsArray; + } + + + /** + * Parses the xml answer to get the array of groups returned. + */ + /* + public function getArrayOfGroupsResponded(){ + $listCheckedElements = $this->$response->xml()->data[0]->groups[0]->element; + $extractedElementsArray = json_decode( json_encode($listCheckedElements) , 1); + return $extractedElementsArray; + } + */ + + + + /** + * @Then /^users returned are$/ + * @param \Behat\Gherkin\Node\TableNode|null $formData + */ + public function theUsersShouldBe($usersList) { + if ($usersList instanceof \Behat\Gherkin\Node\TableNode) { + $users = $usersList->getRows()[0]; + $respondedArray = $this->getArrayOfUsersResponded($this->response); + PHPUnit_Framework_Assert::assertEquals($users, $respondedArray); + } + + } + + /** * @Then /^the OCS status code should be "([^"]*)"$/ */ diff --git a/build/integration/features/provisioning-v1.feature b/build/integration/features/provisioning-v1.feature index 823fd823c5e..448c06b8b51 100644 --- a/build/integration/features/provisioning-v1.feature +++ b/build/integration/features/provisioning-v1.feature @@ -40,6 +40,13 @@ Feature: provisioning And the HTTP status code should be "200" + Scenario: Getting all users + Given As an "admin" + When sending "GET" to "/cloud/users" + And users returned are + | brand-new-user | ser507 | + + Scenario: Edit a user Given As an "admin" And user "brand-new-user" exists From 1b0e128b4407fefe9ff7be7366bacbac94d101c9 Mon Sep 17 00:00:00 2001 From: Sergio Bertolin Date: Wed, 7 Oct 2015 09:03:00 +0000 Subject: [PATCH 2/4] checking users and groups --- .../features/bootstrap/FeatureContext.php | 24 ++++++++++++------- .../features/provisioning-v1.feature | 9 ++++++- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/build/integration/features/bootstrap/FeatureContext.php b/build/integration/features/bootstrap/FeatureContext.php index 99d030fa6fc..a09e74de57c 100644 --- a/build/integration/features/bootstrap/FeatureContext.php +++ b/build/integration/features/bootstrap/FeatureContext.php @@ -49,7 +49,6 @@ class FeatureContext extends BehatContext { $this->sendingToWith($verb, $url, null); } - /** * Parses the xml answer to get ocs response which doesn't match with * http one in v1 of the api. @@ -67,19 +66,14 @@ class FeatureContext extends BehatContext { return $extractedElementsArray; } - /** * Parses the xml answer to get the array of groups returned. */ - /* - public function getArrayOfGroupsResponded(){ - $listCheckedElements = $this->$response->xml()->data[0]->groups[0]->element; + public function getArrayOfGroupsResponded($resp) { + $listCheckedElements = $resp->xml()->data[0]->groups[0]->element; $extractedElementsArray = json_decode( json_encode($listCheckedElements) , 1); return $extractedElementsArray; } - */ - - /** * @Then /^users returned are$/ @@ -93,8 +87,20 @@ class FeatureContext extends BehatContext { } } - + /** + * @Then /^groups returned are$/ + * @param \Behat\Gherkin\Node\TableNode|null $formData + */ + public function theGroupsShouldBe($groupsList) { + if ($groupsList instanceof \Behat\Gherkin\Node\TableNode) { + $groups = $groupsList->getRows()[0]; + $respondedArray = $this->getArrayOfGroupsResponded($this->response); + PHPUnit_Framework_Assert::assertEquals($groups, $respondedArray); + } + + } + /** * @Then /^the OCS status code should be "([^"]*)"$/ */ diff --git a/build/integration/features/provisioning-v1.feature b/build/integration/features/provisioning-v1.feature index 448c06b8b51..ad6841142a9 100644 --- a/build/integration/features/provisioning-v1.feature +++ b/build/integration/features/provisioning-v1.feature @@ -44,7 +44,7 @@ Feature: provisioning Given As an "admin" When sending "GET" to "/cloud/users" And users returned are - | brand-new-user | ser507 | + | brand-new-user | admin | Scenario: Edit a user @@ -81,6 +81,13 @@ Feature: provisioning And group "new-group" exists + Scenario: Getting all users + Given As an "admin" + When sending "GET" to "/cloud/groups" + And groups returned are + | admin | new-group | + + Scenario: Delete a group Given As an "admin" And group "new-group" exists From 957d60cd0a30fae7fcdca63d73da5965545efed2 Mon Sep 17 00:00:00 2001 From: Sergio Bertolin Date: Wed, 7 Oct 2015 09:24:12 +0000 Subject: [PATCH 3/4] ordering arrays before comparing --- build/integration/features/bootstrap/FeatureContext.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/integration/features/bootstrap/FeatureContext.php b/build/integration/features/bootstrap/FeatureContext.php index a09e74de57c..70424b1d24c 100644 --- a/build/integration/features/bootstrap/FeatureContext.php +++ b/build/integration/features/bootstrap/FeatureContext.php @@ -83,7 +83,7 @@ class FeatureContext extends BehatContext { if ($usersList instanceof \Behat\Gherkin\Node\TableNode) { $users = $usersList->getRows()[0]; $respondedArray = $this->getArrayOfUsersResponded($this->response); - PHPUnit_Framework_Assert::assertEquals($users, $respondedArray); + PHPUnit_Framework_Assert::assertEquals(asort($users), asort($respondedArray)); } } @@ -96,7 +96,7 @@ class FeatureContext extends BehatContext { if ($groupsList instanceof \Behat\Gherkin\Node\TableNode) { $groups = $groupsList->getRows()[0]; $respondedArray = $this->getArrayOfGroupsResponded($this->response); - PHPUnit_Framework_Assert::assertEquals($groups, $respondedArray); + PHPUnit_Framework_Assert::assertEquals(asort($groups), asort($respondedArray)); } } From 8f91426e0af32aa4007d9f3b4749a78261a44279 Mon Sep 17 00:00:00 2001 From: Sergio Bertolin Date: Wed, 7 Oct 2015 11:09:01 +0000 Subject: [PATCH 4/4] changing indentation, vertical elements and previous existance of users and groups --- .../features/bootstrap/FeatureContext.php | 38 +++++++++---------- .../features/provisioning-v1.feature | 12 ++++-- 2 files changed, 28 insertions(+), 22 deletions(-) diff --git a/build/integration/features/bootstrap/FeatureContext.php b/build/integration/features/bootstrap/FeatureContext.php index 70424b1d24c..f440aece603 100644 --- a/build/integration/features/bootstrap/FeatureContext.php +++ b/build/integration/features/bootstrap/FeatureContext.php @@ -58,22 +58,22 @@ class FeatureContext extends BehatContext { } /** - * Parses the xml answer to get the array of users returned. - */ - public function getArrayOfUsersResponded($resp) { - $listCheckedElements = $resp->xml()->data[0]->users[0]->element; - $extractedElementsArray = json_decode( json_encode($listCheckedElements) , 1); - return $extractedElementsArray; - } + * Parses the xml answer to get the array of users returned. + */ + public function getArrayOfUsersResponded($resp) { + $listCheckedElements = $resp->xml()->data[0]->users[0]->element; + $extractedElementsArray = json_decode( json_encode($listCheckedElements) , 1); + return $extractedElementsArray; + } - /** - * Parses the xml answer to get the array of groups returned. - */ - public function getArrayOfGroupsResponded($resp) { - $listCheckedElements = $resp->xml()->data[0]->groups[0]->element; - $extractedElementsArray = json_decode( json_encode($listCheckedElements) , 1); - return $extractedElementsArray; - } + /** + * Parses the xml answer to get the array of groups returned. + */ + public function getArrayOfGroupsResponded($resp) { + $listCheckedElements = $resp->xml()->data[0]->groups[0]->element; + $extractedElementsArray = json_decode( json_encode($listCheckedElements) , 1); + return $extractedElementsArray; + } /** * @Then /^users returned are$/ @@ -82,8 +82,8 @@ class FeatureContext extends BehatContext { public function theUsersShouldBe($usersList) { if ($usersList instanceof \Behat\Gherkin\Node\TableNode) { $users = $usersList->getRows()[0]; - $respondedArray = $this->getArrayOfUsersResponded($this->response); - PHPUnit_Framework_Assert::assertEquals(asort($users), asort($respondedArray)); + $respondedArray = $this->getArrayOfUsersResponded($this->response); + PHPUnit_Framework_Assert::assertEquals(asort($users), asort($respondedArray)); } } @@ -95,8 +95,8 @@ class FeatureContext extends BehatContext { public function theGroupsShouldBe($groupsList) { if ($groupsList instanceof \Behat\Gherkin\Node\TableNode) { $groups = $groupsList->getRows()[0]; - $respondedArray = $this->getArrayOfGroupsResponded($this->response); - PHPUnit_Framework_Assert::assertEquals(asort($groups), asort($respondedArray)); + $respondedArray = $this->getArrayOfGroupsResponded($this->response); + PHPUnit_Framework_Assert::assertEquals(asort($groups), asort($respondedArray)); } } diff --git a/build/integration/features/provisioning-v1.feature b/build/integration/features/provisioning-v1.feature index ad6841142a9..d865ee687ed 100644 --- a/build/integration/features/provisioning-v1.feature +++ b/build/integration/features/provisioning-v1.feature @@ -42,9 +42,12 @@ Feature: provisioning Scenario: Getting all users Given As an "admin" + And user "brand-new-user" exists + And user "admin" exists When sending "GET" to "/cloud/users" And users returned are - | brand-new-user | admin | + | brand-new-user | + | admin | Scenario: Edit a user @@ -81,11 +84,14 @@ Feature: provisioning And group "new-group" exists - Scenario: Getting all users + Scenario: Getting all groups Given As an "admin" + And group "new-group" exists + And group "admin" exists When sending "GET" to "/cloud/groups" And groups returned are - | admin | new-group | + | admin | + | new-group | Scenario: Delete a group