. * */ /** * An actor in a test scenario. * * Every Actor object is intended to be used only in a single test scenario. * An Actor can control its web browser thanks to the Mink Session received when * it was created, so in each scenario each Actor must have its own Mink * Session; the same Mink Session can be used by different Actors in different * scenarios, but never by different Actors in the same scenario. * * The test servers used in an scenario can change between different test runs, * so an Actor stores the base URL for the current test server being used; in * most cases the tests are specified using relative paths that can be converted * to the appropriate absolute URL using locatePath() in the step * implementation. */ class Actor { /** * @var \Behat\Mink\Session */ private $session; /** * @var string */ private $baseUrl; /** * 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. */ public function __construct(\Behat\Mink\Session $session, $baseUrl) { $this->session = $session; $this->baseUrl = $baseUrl; } /** * Sets the base URL. * * @param string $baseUrl the base URL used when solving relative URLs. */ public function setBaseUrl($baseUrl) { $this->baseUrl = $baseUrl; } /** * Returns the Mink Session used to control its web browser. * * @return \Behat\Mink\Session the Mink Session used to control its web * browser. */ public function getSession() { return $this->session; } /** * Returns the full path for the given relative path based on the base URL. * * @param string relativePath the relative path. * @return string the full path. */ public function locatePath($relativePath) { return $this->baseUrl . $relativePath; } }