Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
activeSession = defaultSession
Browse files Browse the repository at this point in the history
  • Loading branch information
everzet committed May 16, 2011
1 parent 2be2715 commit d3e89a5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
20 changes: 10 additions & 10 deletions src/Behat/Mink/Mink.php
Expand Up @@ -20,7 +20,7 @@
*/
class Mink
{
private $activeSessionName;
private $defaultSessionName;
private $sessions = array();

/**
Expand Down Expand Up @@ -69,29 +69,29 @@ public function hasSession($name)
}

/**
* Sets active session name to use.
* Sets default session name to use.
*
* @param null|string $name name of the registered session
* @param string $name name of the registered session
*/
public function setActiveSessionName($name)
public function setDefaultSessionName($name)
{
$name = strtolower($name);

if (!isset($this->sessions[$name])) {
throw new \InvalidArgumentException(sprintf('session "%s" is not registered.', $name));
}

$this->activeSessionName = $name;
$this->defaultSessionName = $name;
}

/**
* Returns currently active session name or null if none.
* Returns default session name or null if none.
*
* @return null|string
*/
public function getActiveSessionName()
public function getDefaultSessionName()
{
return $this->activeSessionName;
return $this->defaultSessionName;
}

/**
Expand All @@ -103,7 +103,7 @@ public function getActiveSessionName()
*/
public function getSession($name = null)
{
$name = strtolower($name) ?: $this->activeSessionName;
$name = strtolower($name) ?: $this->defaultSessionName;

if (null === $name) {
throw new \InvalidArgumentException('specify session name to get');
Expand All @@ -118,7 +118,7 @@ public function getSession($name = null)
// start session if needed
if (!$session->isStarted()) {
$session->start();
$this->activeSessionName = $name;
$this->defaultSessionName = $name;
}

return $session;
Expand Down
18 changes: 9 additions & 9 deletions tests/Behat/Mink/MinkTest.php
Expand Up @@ -87,22 +87,22 @@ public function testGetAlreadyStartedSession()
$this->assertSame($session, $this->mink->getSession('mock_session'));
}

public function testSetActiveSessionName()
public function testSetDefaultSessionName()
{
$this->assertNull($this->mink->getActiveSessionName());
$this->assertNull($this->mink->getDefaultSessionName());

$session = $this->getSessionMock();
$this->mink->registerSession('session_name', $session);
$this->mink->setActiveSessionName('session_name');
$this->mink->setDefaultSessionName('session_name');

$this->assertEquals('session_name', $this->mink->getActiveSessionName());
$this->assertEquals('session_name', $this->mink->getDefaultSessionName());

$this->setExpectedException('InvalidArgumentException');

$this->mink->setActiveSessionName('not_registered');
$this->mink->setDefaultSessionName('not_registered');
}

public function testGetActiveSession()
public function testGetDefaultSession()
{
$session1 = $this->getSessionMock();
$session2 = $this->getSessionMock();
Expand All @@ -111,18 +111,18 @@ public function testGetActiveSession()

$this->mink->registerSession('session_1', $session1);
$this->mink->registerSession('session_2', $session2);
$this->mink->setActiveSessionName('session_2');
$this->mink->setDefaultSessionName('session_2');

$this->assertSame($session1, $this->mink->getSession('session_1'));
$this->assertSame($session2, $this->mink->getSession('session_2'));
$this->assertSame($session2, $this->mink->getSession());

$this->mink->setActiveSessionName('session_1');
$this->mink->setDefaultSessionName('session_1');

$this->assertSame($session1, $this->mink->getSession());
}

public function testGetNoActiveSession()
public function testGetNoDefaultSession()
{
$session1 = $this->getSessionMock();

Expand Down

0 comments on commit d3e89a5

Please sign in to comment.