forked from codeigniter4/CodeIgniter4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHealthTest.php
More file actions
49 lines (41 loc) · 1.41 KB
/
HealthTest.php
File metadata and controls
49 lines (41 loc) · 1.41 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
<?php
use CodeIgniter\Test\CIUnitTestCase;
use Config\App;
use Tests\Support\Libraries\ConfigReader;
/**
* @internal
*/
final class HealthTest extends CIUnitTestCase
{
public function testIsDefinedAppPath(): void
{
$this->assertTrue(defined('APPPATH'));
}
public function testBaseUrlHasBeenSet(): void
{
$validation = service('validation');
$env = false;
// Check the baseURL in .env
if (is_file(HOMEPATH . '.env')) {
$env = preg_grep('/^app\.baseURL = ./', file(HOMEPATH . '.env')) !== false;
}
if ($env) {
// BaseURL in .env is a valid URL?
// phpunit.dist.xml sets app.baseURL in $_SERVER
// So if you set app.baseURL in .env, it takes precedence
$config = new App();
$this->assertTrue(
$validation->check($config->baseURL, 'valid_url'),
'baseURL "' . $config->baseURL . '" in .env is not valid URL',
);
}
// Get the baseURL in app/Config/App.php
// You can't use Config\App, because phpunit.dist.xml sets app.baseURL
$reader = new ConfigReader();
// BaseURL in app/Config/App.php is a valid URL?
$this->assertTrue(
$validation->check($reader->baseURL, 'valid_url'),
'baseURL "' . $reader->baseURL . '" in app/Config/App.php is not valid URL',
);
}
}