| Conditions | 1 |
| Paths | 1 |
| Total Lines | 17 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 25 | public function testIndexCreatesChecker() |
||
|
|
|||
| 26 | { |
||
| 27 | $controller = new DevHealthController(); |
||
| 28 | |||
| 29 | $request = new HTTPRequest('GET', 'example.com'); |
||
| 30 | |||
| 31 | // we need to fake authenticated access as BasicAuth::requireLogin doesn't like empty |
||
| 32 | // permission type strings, which is what health check uses. |
||
| 33 | |||
| 34 | putenv('ENVCHECK_BASICAUTH_USERNAME="foo"'); |
||
| 35 | putenv('ENVCHECK_BASICAUTH_PASSWORD="bar"'); |
||
| 36 | |||
| 37 | $_SERVER['PHP_AUTH_USER'] = 'foo'; |
||
| 38 | $_SERVER['PHP_AUTH_PW'] = 'bar'; |
||
| 39 | |||
| 40 | $this->assertInstanceOf(EnvironmentChecker::class, $controller->index($request)); |
||
| 41 | } |
||
| 42 | } |
||
| 43 |
Instead of super-globals, we recommend to explicitly inject the dependencies of your class. This makes your code less dependent on global state and it becomes generally more testable: