diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2017-04-23 18:40:58 +0200 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2017-04-24 11:33:07 +0200 |
commit | 13c84f66294034fe17f806d3db6ddc770c8158e9 (patch) | |
tree | 968c84d3ebe4768b56bac574391a393dba22b528 | |
parent | 8a1d3c7e877f143d211af259d08737c0d9aa8cfe (diff) | |
download | nextcloud-server-13c84f66294034fe17f806d3db6ddc770c8158e9.tar.gz nextcloud-server-13c84f66294034fe17f806d3db6ddc770c8158e9.zip |
Add system to share data between acceptance test steps
The data storage (the "notebook") is shared between all the actors, so
the data can be stored and retrieved between different steps by any
actor in the same scenario.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
-rw-r--r-- | tests/acceptance/features/core/Actor.php | 22 | ||||
-rw-r--r-- | tests/acceptance/features/core/ActorContext.php | 10 |
2 files changed, 29 insertions, 3 deletions
diff --git a/tests/acceptance/features/core/Actor.php b/tests/acceptance/features/core/Actor.php index a27e8e6a015..0c23b5f7a40 100644 --- a/tests/acceptance/features/core/Actor.php +++ b/tests/acceptance/features/core/Actor.php @@ -48,6 +48,10 @@ * before giving up without modifying the tests themselves. Note that the * multiplier affects the timeout, but not the timeout step; the rate at which * find() will try again to find the element does not change. + * + * All actors share a notebook in which data can be annotated. This makes + * possible to share data between different test steps, no matter which Actor + * performs them. */ class Actor { @@ -67,15 +71,22 @@ class Actor { private $findTimeoutMultiplier; /** + * @var array + */ + private $sharedNotebook; + + /** * Creates a new Actor. * * @param \Behat\Mink\Session $session the Mink Session used to control its * web browser. * @param string $baseUrl the base URL used when solving relative URLs. + * @param array $sharedNotebook the notebook shared between all actors. */ - public function __construct(\Behat\Mink\Session $session, $baseUrl) { + public function __construct(\Behat\Mink\Session $session, $baseUrl, &$sharedNotebook) { $this->session = $session; $this->baseUrl = $baseUrl; + $this->sharedNotebook = &$sharedNotebook; $this->findTimeoutMultiplier = 1; } @@ -221,4 +232,13 @@ class Actor { return $ancestorElement; } + /** + * Returns the shared notebook of the Actors. + * + * @return array the shared notebook of the Actors. + */ + public function &getSharedNotebook() { + return $this->sharedNotebook; + } + } diff --git a/tests/acceptance/features/core/ActorContext.php b/tests/acceptance/features/core/ActorContext.php index 9667ef2f01c..86fe3832f66 100644 --- a/tests/acceptance/features/core/ActorContext.php +++ b/tests/acceptance/features/core/ActorContext.php @@ -54,6 +54,11 @@ class ActorContext extends RawMinkContext { private $actors; /** + * @var array + */ + private $sharedNotebook; + + /** * @var Actor */ private $currentActor; @@ -102,8 +107,9 @@ class ActorContext extends RawMinkContext { */ public function initializeActors() { $this->actors = array(); + $this->sharedNotebook = array(); - $this->actors["default"] = new Actor($this->getSession(), $this->getMinkParameter("base_url")); + $this->actors["default"] = new Actor($this->getSession(), $this->getMinkParameter("base_url"), $this->sharedNotebook); $this->actors["default"]->setFindTimeoutMultiplier($this->actorFindTimeoutMultiplier); $this->currentActor = $this->actors["default"]; @@ -127,7 +133,7 @@ class ActorContext extends RawMinkContext { */ public function iActAs($actorName) { if (!array_key_exists($actorName, $this->actors)) { - $this->actors[$actorName] = new Actor($this->getSession($actorName), $this->getMinkParameter("base_url")); + $this->actors[$actorName] = new Actor($this->getSession($actorName), $this->getMinkParameter("base_url"), $this->sharedNotebook); $this->actors[$actorName]->setFindTimeoutMultiplier($this->actorFindTimeoutMultiplier); } |