Skip to content

Commit 87e5d6c

Browse files
committed
Add starter health check (baseUrl)
1 parent c1bb437 commit 87e5d6c

File tree

3 files changed

+62
-7
lines changed

3 files changed

+62
-7
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php
2+
3+
4+
/**
5+
* CodeIgniter
6+
*
7+
* An open source application development framework for PHP
8+
*
9+
* This content is released under the MIT License (MIT)
10+
*
11+
* Copyright (c) 2014-2019 British Columbia Institute of Technology
12+
* Copyright (c) 2019-2020 CodeIgniter Foundation
13+
*
14+
* Permission is hereby granted, free of charge, to any person obtaining a copy
15+
* of this software and associated documentation files (the "Software"), to deal
16+
* in the Software without restriction, including without limitation the rights
17+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18+
* copies of the Software, and to permit persons to whom the Software is
19+
* furnished to do so, subject to the following conditions:
20+
*
21+
* The above copyright notice and this permission notice shall be included in
22+
* all copies or substantial portions of the Software.
23+
*
24+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
30+
* THE SOFTWARE.
31+
*
32+
* @package CodeIgniter
33+
* @author CodeIgniter Dev Team
34+
* @copyright 2019-2020 CodeIgniter Foundation
35+
* @license https://opensource.org/licenses/MIT MIT License
36+
* @link https://codeigniter.com
37+
* @since Version 4.0.0
38+
* @filesource
39+
*/
40+
41+
namespace Tests\Support\Libraries;
42+
43+
/**
44+
* Class ConfigReader
45+
*
46+
* An extension of BaseConfig that prevents the constructor from
47+
* loading external values. Used to read actual local values from
48+
* a config file.
49+
*/
50+
class ConfigReader extends \App\Config\App
51+
{
52+
public function __construct()
53+
{
54+
}
55+
}

admin/starter/tests/unit/ExampleTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ public function testBaseUrlHasBeenSet()
2020

2121
// First check in .env
2222
$dotenv = new \CodeIgniter\Config\DotEnv(HOMEPATH);
23-
24-
if ($dotenv->load())
23+
if ($vars = $dotenv->parse())
2524
{
26-
// Check any line with "app.baseUrl" to see if it actually has a value set
27-
foreach (preg_grep('/^app\.baseURL', file(HOMEPATH . '.env')) as $line)
28-
{
29-
}
25+
$env = ! empty($vars['app.baseUrl']);
3026
}
3127

32-
$this->assertTrue($test);
28+
// Then check the actual config file
29+
$reader = new \Tests\Support\Libraries\ConfigReader();
30+
$config = ! empty($reader->baseUrl);
31+
32+
$this->assertTrue($env || $config);
3333
}
3434
}
File renamed without changes.

0 commit comments

Comments
 (0)