Upgrade behat to 3.0.x and use @BeforeScenario and @AfterScenario to clean up users
This commit is contained in:
parent
d11b69bfb9
commit
fcc2a0c830
|
@ -1,7 +1,8 @@
|
||||||
{
|
{
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "~4.6",
|
"phpunit/phpunit": "~4.6",
|
||||||
|
"behat/behat": "^3.0",
|
||||||
"guzzlehttp/guzzle": "~5.0",
|
"guzzlehttp/guzzle": "~5.0",
|
||||||
"behat/behat": "2.4.*@stable"
|
"jarnaiz/behat-junit-formatter": "^1.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
default:
|
default:
|
||||||
paths:
|
autoload:
|
||||||
features: ../features
|
'': %paths.base%/../features/bootstrap
|
||||||
bootstrap: %behat.paths.features%/bootstrap
|
suites:
|
||||||
|
default:
|
||||||
|
paths:
|
||||||
|
- %paths.base%/../features
|
||||||
|
contexts:
|
||||||
|
- FeatureContext:
|
||||||
|
baseUrl: http://localhost:8080/ocs/
|
||||||
|
admin:
|
||||||
|
- admin
|
||||||
|
- admin
|
||||||
|
regular_user_password: 123456
|
||||||
|
|
||||||
context:
|
extensions:
|
||||||
parameters:
|
jarnaiz\JUnitFormatter\JUnitFormatterExtension:
|
||||||
baseUrl: http://localhost:8080/ocs/
|
filename: report.xml
|
||||||
admin:
|
outputDir: %paths.base%/../output/
|
||||||
- admin
|
|
||||||
- admin
|
|
||||||
regular_user_password: 123456
|
|
||||||
|
|
||||||
ci:
|
|
||||||
formatter:
|
|
||||||
name: pretty,junit
|
|
||||||
parameters:
|
|
||||||
output_path: null,./output
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Behat\Behat\Context\BehatContext;
|
use Behat\Behat\Context\Context;
|
||||||
|
use Behat\Behat\Context\SnippetAcceptingContext;
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use GuzzleHttp\Message\ResponseInterface;
|
use GuzzleHttp\Message\ResponseInterface;
|
||||||
|
|
||||||
|
@ -9,7 +10,7 @@ require __DIR__ . '/../../vendor/autoload.php';
|
||||||
/**
|
/**
|
||||||
* Features context.
|
* Features context.
|
||||||
*/
|
*/
|
||||||
class FeatureContext extends BehatContext {
|
class FeatureContext implements Context, SnippetAcceptingContext {
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $baseUrl = '';
|
private $baseUrl = '';
|
||||||
|
@ -26,18 +27,15 @@ class FeatureContext extends BehatContext {
|
||||||
/** @var SimpleXMLElement */
|
/** @var SimpleXMLElement */
|
||||||
private $lastShareData = null;
|
private $lastShareData = null;
|
||||||
|
|
||||||
/**
|
/** @var array */
|
||||||
* Initializes context.
|
private $createdUsers = [];
|
||||||
* Every scenario gets it's own context object.
|
|
||||||
*
|
public function __construct($baseUrl, $admin, $regular_user_password) {
|
||||||
* @param array $parameters context parameters (set them up through behat.yml)
|
|
||||||
*/
|
|
||||||
public function __construct(array $parameters) {
|
|
||||||
|
|
||||||
// Initialize your context here
|
// Initialize your context here
|
||||||
$this->baseUrl = $parameters['baseUrl'];
|
$this->baseUrl = $baseUrl;
|
||||||
$this->adminUser = $parameters['admin'];
|
$this->adminUser = $admin;
|
||||||
$this->regularUser = $parameters['regular_user_password'];
|
$this->regularUser = $regular_user_password;
|
||||||
|
|
||||||
// in case of ci deployment we take the server url from the environment
|
// in case of ci deployment we take the server url from the environment
|
||||||
$testServerUrl = getenv('TEST_SERVER_URL');
|
$testServerUrl = getenv('TEST_SERVER_URL');
|
||||||
|
@ -389,7 +387,7 @@ class FeatureContext extends BehatContext {
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->response = $client->send($client->createRequest("POST", $fullUrl, $options));
|
$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));
|
$this->response = $client->send($client->createRequest("PUT", $fullUrl, $options));
|
||||||
PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode());
|
PHPUnit_Framework_Assert::assertEquals(200, $this->response->getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BeforeScenario
|
||||||
|
* @AfterScenario
|
||||||
|
*/
|
||||||
|
public function cleanupUsers()
|
||||||
|
{
|
||||||
|
foreach($this->createdUsers as $user) {
|
||||||
|
$this->deleteUser($user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,6 @@ Feature: sharing
|
||||||
| shareType | 0 |
|
| shareType | 0 |
|
||||||
Then the OCS status code should be "100"
|
Then the OCS status code should be "100"
|
||||||
And the HTTP status code should be "200"
|
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
|
Scenario: Creating a share with a group
|
||||||
Given user "user0" exists
|
Given user "user0" exists
|
||||||
|
@ -26,9 +24,6 @@ Feature: sharing
|
||||||
| shareType | 1 |
|
| shareType | 1 |
|
||||||
Then the OCS status code should be "100"
|
Then the OCS status code should be "100"
|
||||||
And the HTTP status code should be "200"
|
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
|
Scenario: Creating a new public share
|
||||||
Given user "user0" exists
|
Given user "user0" exists
|
||||||
|
@ -39,7 +34,6 @@ Feature: sharing
|
||||||
Then the OCS status code should be "100"
|
Then the OCS status code should be "100"
|
||||||
And the HTTP status code should be "200"
|
And the HTTP status code should be "200"
|
||||||
And Public shared file "welcome.txt" can be downloaded
|
And Public shared file "welcome.txt" can be downloaded
|
||||||
And user "user0" does not exist
|
|
||||||
|
|
||||||
Scenario: Creating a new public share with password
|
Scenario: Creating a new public share with password
|
||||||
Given user "user0" exists
|
Given user "user0" exists
|
||||||
|
@ -51,7 +45,6 @@ Feature: sharing
|
||||||
Then the OCS status code should be "100"
|
Then the OCS status code should be "100"
|
||||||
And the HTTP status code should be "200"
|
And the HTTP status code should be "200"
|
||||||
And Public shared file "welcome.txt" with password "publicpw" can be downloaded
|
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
|
Scenario: Creating a new public share with password and adding an expiration date
|
||||||
Given user "user0" exists
|
Given user "user0" exists
|
||||||
|
@ -64,5 +57,4 @@ Feature: sharing
|
||||||
Then the OCS status code should be "100"
|
Then the OCS status code should be "100"
|
||||||
And the HTTP status code should be "200"
|
And the HTTP status code should be "200"
|
||||||
And Public shared file "welcome.txt" with password "publicpw" can be downloaded
|
And Public shared file "welcome.txt" with password "publicpw" can be downloaded
|
||||||
And user "user0" does not exist
|
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,6 @@ PHPPID=$!
|
||||||
echo $PHPPID
|
echo $PHPPID
|
||||||
|
|
||||||
export TEST_SERVER_URL="http://localhost:$PORT/ocs/"
|
export TEST_SERVER_URL="http://localhost:$PORT/ocs/"
|
||||||
vendor/bin/behat --profile ci
|
vendor/bin/behat -f junit -f pretty
|
||||||
|
|
||||||
kill $PHPPID
|
kill $PHPPID
|
||||||
|
|
Loading…
Reference in New Issue