diff --git a/src/Behat/Mink/Session.php b/src/Behat/Mink/Session.php index dbc5571ee..3e8ff36c4 100644 --- a/src/Behat/Mink/Session.php +++ b/src/Behat/Mink/Session.php @@ -24,6 +24,7 @@ class Session private $driver; private $page; private $selectorsHandler; + private $uniqueId; /** * Initializes session. @@ -42,6 +43,7 @@ public function __construct(DriverInterface $driver, SelectorsHandler $selectors $this->driver = $driver; $this->page = new DocumentElement($this); $this->selectorsHandler = $selectorsHandler; + $this->uniqueId = uniqid('mink_session_'); } /** @@ -97,6 +99,17 @@ public function getDriver() return $this->driver; } + /** + * Returns session unique id. + * + * @return string + * @access public + */ + public function getUniqueId() + { + return $this->uniqueId; + } + /** * Returns page element. * @@ -205,7 +218,7 @@ public function getCurrentUrl() /** * Capture a screenshot of the current window. * - * @return string screenshot of MIME type image/* depending + * @return string screenshot of MIME type image/* depending * on driver (e.g., image/png, image/jpeg) */ public function getScreenshot() diff --git a/tests/Behat/Mink/SessionTest.php b/tests/Behat/Mink/SessionTest.php index 116082150..be701f6d1 100644 --- a/tests/Behat/Mink/SessionTest.php +++ b/tests/Behat/Mink/SessionTest.php @@ -11,6 +11,13 @@ class SessionTest extends \PHPUnit_Framework_TestCase { private $driver; private $selectorsHandler; + + /** + * Session. + * + * @var Session + * @access private + */ private $session; protected function setUp() @@ -114,4 +121,18 @@ public function testWait() $this->session->wait(1000, 'function() {}'); } + + /** + * Testing that 2 sessions created with same parameters have different IDs. + * + * @return void + * @access public + */ + public function testUniqueId() + { + $session = new Session($this->driver, $this->selectorsHandler); + + $this->assertNotEquals($session->getUniqueId(), $this->session->getUniqueId()); + + } }