Store the name of the actor in the Actor object
This is needed to be able to easily use the actor as a key in an array. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
This commit is contained in:
parent
c62c7dda82
commit
292e95566e
|
@ -60,6 +60,11 @@
|
|||
*/
|
||||
class Actor {
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @var \Behat\Mink\Session
|
||||
*/
|
||||
|
@ -83,18 +88,29 @@ class Actor {
|
|||
/**
|
||||
* Creates a new Actor.
|
||||
*
|
||||
* @param string $name the name of the 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, &$sharedNotebook) {
|
||||
public function __construct($name, \Behat\Mink\Session $session, $baseUrl, &$sharedNotebook) {
|
||||
$this->name = $name;
|
||||
$this->session = $session;
|
||||
$this->baseUrl = $baseUrl;
|
||||
$this->sharedNotebook = &$sharedNotebook;
|
||||
$this->findTimeoutMultiplier = 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of this Actor.
|
||||
*
|
||||
* @return string the name of this Actor.
|
||||
*/
|
||||
public function getName() {
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the base URL.
|
||||
*
|
||||
|
|
|
@ -135,7 +135,7 @@ class ActorContext extends RawMinkContext {
|
|||
$this->actors = array();
|
||||
$this->sharedNotebook = array();
|
||||
|
||||
$this->actors["default"] = new Actor($this->getSession(), $this->getMinkParameter("base_url"), $this->sharedNotebook);
|
||||
$this->actors["default"] = new Actor("default", $this->getSession(), $this->getMinkParameter("base_url"), $this->sharedNotebook);
|
||||
$this->actors["default"]->setFindTimeoutMultiplier($this->actorTimeoutMultiplier);
|
||||
|
||||
$this->currentActor = $this->actors["default"];
|
||||
|
@ -159,7 +159,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->sharedNotebook);
|
||||
$this->actors[$actorName] = new Actor($actorName, $this->getSession($actorName), $this->getMinkParameter("base_url"), $this->sharedNotebook);
|
||||
$this->actors[$actorName]->setFindTimeoutMultiplier($this->actorTimeoutMultiplier);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue