2021-05-19 16:35:13 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Support;
|
2020-05-27 18:46:16 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
2021-05-12 14:00:25 +00:00
|
|
|
/**
|
|
|
|
* @phpstan-ignore-next-line
|
|
|
|
*/
|
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
|
|
|
|
2021-05-19 16:35:13 +00:00
|
|
|
protected function setUp(): void
|
2020-08-04 11:25:22 +00:00
|
|
|
{
|
|
|
|
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
|
|
|
|
*/
|
2021-05-18 17:16:36 +00:00
|
|
|
protected function mockSession(): void
|
2020-08-04 11:25:22 +00:00
|
|
|
{
|
|
|
|
$config = config('App');
|
2021-05-19 16:35:13 +00:00
|
|
|
$this->session = new MockSession(new ArrayHandler($config, '0.0.0.0'), $config,);
|
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
|
|
|
}
|