Add integration tests [MAILPOET-2015]
This commit is contained in:
35
tests/integration/Config/SessionTest.php
Normal file
35
tests/integration/Config/SessionTest.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
namespace MailPoet\Test\Config;
|
||||
|
||||
use MailPoet\Config\Session;
|
||||
|
||||
class SessionTest extends \MailPoetTest {
|
||||
function _before() {
|
||||
$this->destroySessionIfExists();
|
||||
}
|
||||
|
||||
function testItStartsSessionIfItIsNotStarted() {
|
||||
expect(session_id())->isEmpty();
|
||||
$session = new Session;
|
||||
$result = $session->init();
|
||||
expect($result)->equals(true);
|
||||
expect(session_id())->notEmpty();
|
||||
session_destroy();
|
||||
}
|
||||
|
||||
function testItDoesNotStartSessionIfItIsAlreadyStarted() {
|
||||
session_start();
|
||||
expect(session_id())->notEmpty();
|
||||
$session = new Session;
|
||||
$result = $session->init();
|
||||
expect($result)->equals(false);
|
||||
expect(session_id())->notEmpty();
|
||||
session_destroy();
|
||||
}
|
||||
|
||||
private function destroySessionIfExists() {
|
||||
if (session_id()) {
|
||||
session_destroy();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user