-
Notifications
You must be signed in to change notification settings - Fork 145
Expand file tree
/
Copy pathTestCase.php
More file actions
60 lines (48 loc) · 1.81 KB
/
Copy pathTestCase.php
File metadata and controls
60 lines (48 loc) · 1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
declare(strict_types=1);
/**
* This file is part of CodeIgniter Shield.
*
* (c) CodeIgniter Foundation <admin@codeigniter.com>
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Tests\Support;
use CodeIgniter\Config\Factories;
use CodeIgniter\Settings\Settings;
use CodeIgniter\Test\CIUnitTestCase;
use Config\Services;
/**
* @internal
*/
abstract class TestCase extends CIUnitTestCase
{
protected function setUp(): void
{
$this->resetServices();
parent::setUp();
// Use Array Settings Handler
$configSettings = config('Settings');
$configSettings->handlers = ['array'];
$settings = new Settings($configSettings);
Services::injectMock('settings', $settings);
// Load helpers that should be autoloaded
helper(['auth', 'setting']);
// Ensure from email is available anywhere during Tests
setting('Email.fromEmail', 'foo@example.com');
setting('Email.fromName', 'John Smith');
// Clear any actions
$config = config('Auth');
$config->actions = ['login' => null, 'register' => null];
Factories::injectMock('config', 'Auth', $config);
// Set Config\Security::$csrfProtection to 'session'
$config = config('Security');
$config->csrfProtection = 'session';
Factories::injectMock('config', 'Security', $config);
// Set a valid JWT secret (>= 256 bits for HS256) required by firebase/php-jwt v7
$config = config('AuthJWT');
$config->keys['default'][0]['secret'] = 'a-very-secure-secret-key-for-hs256-ok';
Factories::injectMock('config', 'AuthJWT', $config);
}
}