mark all tests that use session to run as separate processes and not share global state

This commit is contained in:
Andrei Furnica 2018-08-02 14:36:24 +03:00
parent 0d16b33326
commit ee5f6a5355
No known key found for this signature in database
GPG Key ID: 6408728868B34CDD
4 changed files with 38 additions and 2 deletions

View File

@ -19,7 +19,7 @@ ini_set('display_errors', 1);
| backtraces along with the other error information. If you would
| prefer to not see this, set this value to false.
*/
defined('SHOW_DEBUG_BACKTRACE') or define('SHOW_DEBUG_BACKTRACE', true);
define('SHOW_DEBUG_BACKTRACE', true);
/*
|--------------------------------------------------------------------------
@ -30,4 +30,4 @@ defined('SHOW_DEBUG_BACKTRACE') or define('SHOW_DEBUG_BACKTRACE', true);
| release of the framework.
*/
defined('CI_DEBUG') or define('CI_DEBUG', 1);
define('CI_DEBUG', 1);

View File

@ -156,17 +156,29 @@ class CommomFunctionsTest extends \CIUnitTestCase
// ------------------------------------------------------------------------
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
*/
public function testSessionInstance()
{
$this->assertInstanceOf(CodeIgniter\Session\Session::class, session());
}
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
*/
public function testSessionVariable()
{
$_SESSION['notbogus'] = 'Hi there';
$this->assertEquals('Hi there', session('notbogus'));
}
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
*/
public function testSessionVariableNotThere()
{
$_SESSION['bogus'] = 'Hi there';

View File

@ -129,18 +129,30 @@ class ServicesTest extends \CIUnitTestCase
$this->assertInstanceOf(\CodeIgniter\View\Cell::class, $actual);
}
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
*/
public function testNewSession()
{
$actual = Services::session($this->config);
$this->assertInstanceOf(\CodeIgniter\Session\Session::class, $actual);
}
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
*/
public function testNewSessionWithNullConfig()
{
$actual = Services::session(null, false);
$this->assertInstanceOf(\CodeIgniter\Session\Session::class, $actual);
}
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
*/
public function testCallStatic()
{
// __callStatic should kick in for this but fail

View File

@ -52,6 +52,10 @@ class RedirectResponseTest extends \CIUnitTestCase
$this->assertEquals('http://example.com/foo', $response->getHeaderLine('Location'));
}
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
*/
public function testWithInput()
{
$_SESSION = [];
@ -68,6 +72,10 @@ class RedirectResponseTest extends \CIUnitTestCase
$this->assertEquals('baz', $_SESSION['_ci_old_input']['post']['bar']);
}
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
*/
public function testWithValidationErrors()
{
$_SESSION = [];
@ -85,6 +93,10 @@ class RedirectResponseTest extends \CIUnitTestCase
$this->assertArrayHasKey('_ci_validation_errors', $_SESSION);
}
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
*/
public function testWith()
{
$_SESSION = [];