2020-05-27 18:46:16 +02:00
|
|
|
<?php namespace Tests\Support;
|
|
|
|
|
|
|
|
use CodeIgniter\Session\Handlers\ArrayHandler;
|
2021-05-06 14:00:48 +00:00
|
|
|
use CodeIgniter\Session\SessionInterface;
|
2020-05-27 18:46:16 +02:00
|
|
|
use CodeIgniter\Test\CIUnitTestCase;
|
|
|
|
use CodeIgniter\Test\Mock\MockSession;
|
2021-05-06 14:00:48 +00:00
|
|
|
use Config\Services;
|
2020-05-27 18:46:16 +02:00
|
|
|
|
|
|
|
class SessionTestCase extends CIUnitTestCase
|
|
|
|
{
|
2020-08-04 11:25:22 +00:00
|
|
|
/**
|
2021-05-06 14:00:48 +00:00
|
|
|
* @var SessionInterface
|
2020-08-04 11:25:22 +00:00
|
|
|
*/
|
|
|
|
protected $session;
|
2020-05-27 18:46:16 +02:00
|
|
|
|
2020-08-04 11:25:22 +00:00
|
|
|
public function setUp(): void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
2020-05-27 18:46:16 +02:00
|
|
|
|
2020-08-04 11:25:22 +00:00
|
|
|
$this->mockSession();
|
|
|
|
}
|
2020-05-27 18:46:16 +02:00
|
|
|
|
2020-08-04 11:25:22 +00:00
|
|
|
/**
|
|
|
|
* Pre-loads the mock session driver into $this->session.
|
|
|
|
*
|
|
|
|
* @var string
|
|
|
|
*/
|
|
|
|
protected function mockSession()
|
|
|
|
{
|
|
|
|
$config = config('App');
|
|
|
|
$this->session = new MockSession(
|
|
|
|
new ArrayHandler($config, '0.0.0.0'),
|
2021-05-06 14:00:48 +00:00
|
|
|
$config,
|
2020-08-04 11:25:22 +00:00
|
|
|
);
|
2021-05-06 14:00:48 +00:00
|
|
|
Services::injectMock('session', $this->session);
|
2020-08-04 11:25:22 +00:00
|
|
|
}
|
2020-05-27 18:46:16 +02:00
|
|
|
}
|