SessionLimitSessionTestCase.php in Session Limit 8
File
tests/SessionLimitSessionTestCase.php
View source
<?php
namespace Drupal\session_limit;
class SessionLimitSessionTestCase extends SessionLimitBaseTestCase {
public static function getInfo() {
return array(
'name' => 'Session Limit MutiSession Tests',
'description' => 'Ensure the multi session tests for SimpleTest work as expected',
'group' => 'Session Limit',
);
}
public function setUp() {
parent::setUp('session_limit');
}
public function testSessionStashAndRestore() {
$user1 = $this
->drupalCreateUser(array(
'access content',
));
$user2 = $this
->drupalCreateUser(array(
'access content',
));
\Drupal::configFactory()
->getEditable('session_limit.settings')
->set('session_limit_behaviour', 0)
->save();
\Drupal::configFactory()
->getEditable('session_limit.settings')
->set('session_limit_max', 100)
->save();
$this
->drupalLogin($user1);
$this
->drupalGet('user');
$this
->assertText(t('Log out'), t('User is logged in under session 1.'));
$this
->assertText($user1->name, t('User1 is logged in under session 1.'));
$session_1 = $this
->stashSession();
$this
->drupalGet('node');
$this
->assertNoText(t('Log out'), t('Session 1 is shelved.'));
$this
->drupalLogin($user2);
$this
->drupalGet('user');
$this
->assertText(t('Log out'), t('User is logged in under session 2.'));
$this
->assertText($user2->name, t('User2 is logged in under session 2.'));
$session_2 = $this
->stashSession();
$this
->restoreSession($session_1);
$this
->drupalGet('user');
$this
->assertText(t('Log out'), t('User is logged in under session 1.'));
$this
->assertText($user1->name, t('User1 is logged in under session 1.'));
$this
->restoreSession($session_2);
$this
->drupalGet('user');
$this
->assertText(t('Log out'), t('User is logged in under session 2.'));
$this
->assertText($user2->name, t('User2 is logged in under session 2.'));
}
}