From fcc2a0c8304020ce040a421472dc0c9e722e2bc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Thu, 29 Oct 2015 15:13:29 +0100 Subject: [PATCH] Upgrade behat to 3.0.x and use @BeforeScenario and @AfterScenario to clean up users --- build/integration/composer.json | 3 +- build/integration/config/behat.yml | 33 ++++++++--------- .../features/bootstrap/FeatureContext.php | 36 ++++++++++++------- build/integration/features/sharing-v1.feature | 8 ----- build/integration/run.sh | 2 +- 5 files changed, 43 insertions(+), 39 deletions(-) diff --git a/build/integration/composer.json b/build/integration/composer.json index 98b2f294c7..2f0f8a815c 100644 --- a/build/integration/composer.json +++ b/build/integration/composer.json @@ -1,7 +1,8 @@ { "require-dev": { "phpunit/phpunit": "~4.6", + "behat/behat": "^3.0", "guzzlehttp/guzzle": "~5.0", - "behat/behat": "2.4.*@stable" + "jarnaiz/behat-junit-formatter": "^1.3" } } diff --git a/build/integration/config/behat.yml b/build/integration/config/behat.yml index 8b6699cb08..c9d6754a0f 100644 --- a/build/integration/config/behat.yml +++ b/build/integration/config/behat.yml @@ -1,18 +1,19 @@ default: - paths: - features: ../features - bootstrap: %behat.paths.features%/bootstrap + autoload: + '': %paths.base%/../features/bootstrap + suites: + default: + paths: + - %paths.base%/../features + contexts: + - FeatureContext: + baseUrl: http://localhost:8080/ocs/ + admin: + - admin + - admin + regular_user_password: 123456 - context: - parameters: - baseUrl: http://localhost:8080/ocs/ - admin: - - admin - - admin - regular_user_password: 123456 - -ci: - formatter: - name: pretty,junit - parameters: - output_path: null,./output + extensions: + jarnaiz\JUnitFormatter\JUnitFormatterExtension: + filename: report.xml + outputDir: %paths.base%/../output/ diff --git a/build/integration/features/bootstrap/FeatureContext.php b/build/integration/features/bootstrap/FeatureContext.php index df4b853edd..8633727ee0 100644 --- a/build/integration/features/bootstrap/FeatureContext.php +++ b/build/integration/features/bootstrap/FeatureContext.php @@ -1,6 +1,7 @@ baseUrl = $parameters['baseUrl']; - $this->adminUser = $parameters['admin']; - $this->regularUser = $parameters['regular_user_password']; + $this->baseUrl = $baseUrl; + $this->adminUser = $admin; + $this->regularUser = $regular_user_password; // in case of ci deployment we take the server url from the environment $testServerUrl = getenv('TEST_SERVER_URL'); @@ -389,7 +387,7 @@ class FeatureContext extends BehatContext { ]; $this->response = $client->send($client->createRequest("POST", $fullUrl, $options)); - + $this->createdUsers[$user] = $user; } /** @@ -604,4 +602,16 @@ class FeatureContext extends BehatContext { $this->response = $client->send($client->createRequest("PUT", $fullUrl, $options)); PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode()); } + + /** + * @BeforeScenario + * @AfterScenario + */ + public function cleanupUsers() + { + foreach($this->createdUsers as $user) { + $this->deleteUser($user); + } + } + } diff --git a/build/integration/features/sharing-v1.feature b/build/integration/features/sharing-v1.feature index ed5ac8930a..abf9fe1c8d 100644 --- a/build/integration/features/sharing-v1.feature +++ b/build/integration/features/sharing-v1.feature @@ -12,8 +12,6 @@ Feature: sharing | shareType | 0 | Then the OCS status code should be "100" And the HTTP status code should be "200" - And user "user0" does not exist - And user "user1" does not exist Scenario: Creating a share with a group Given user "user0" exists @@ -26,9 +24,6 @@ Feature: sharing | shareType | 1 | Then the OCS status code should be "100" And the HTTP status code should be "200" - And user "user0" does not exist - And user "user1" does not exist - And group "sharing-group" does not exist Scenario: Creating a new public share Given user "user0" exists @@ -39,7 +34,6 @@ Feature: sharing Then the OCS status code should be "100" And the HTTP status code should be "200" And Public shared file "welcome.txt" can be downloaded - And user "user0" does not exist Scenario: Creating a new public share with password Given user "user0" exists @@ -51,7 +45,6 @@ Feature: sharing Then the OCS status code should be "100" And the HTTP status code should be "200" And Public shared file "welcome.txt" with password "publicpw" can be downloaded - And user "user0" does not exist Scenario: Creating a new public share with password and adding an expiration date Given user "user0" exists @@ -64,5 +57,4 @@ Feature: sharing Then the OCS status code should be "100" And the HTTP status code should be "200" And Public shared file "welcome.txt" with password "publicpw" can be downloaded - And user "user0" does not exist diff --git a/build/integration/run.sh b/build/integration/run.sh index 08f10b86c5..5456a78440 100755 --- a/build/integration/run.sh +++ b/build/integration/run.sh @@ -14,6 +14,6 @@ PHPPID=$! echo $PHPPID export TEST_SERVER_URL="http://localhost:$PORT/ocs/" -vendor/bin/behat --profile ci +vendor/bin/behat -f junit -f pretty kill $PHPPID