silverstripe-environmentcheck/tests/Controllers/DevHealthControllerTest.php

41 lines
1.1 KiB
PHP
Raw Normal View History

2015-09-10 23:13:48 +02:00
<?php
namespace SilverStripe\EnvironmentCheck\Tests\Controllers;
use SilverStripe\Control\HTTPRequest;
use SilverStripe\Dev\SapphireTest;
use SilverStripe\EnvironmentCheck\Controllers\DevHealthController;
use SilverStripe\EnvironmentCheck\EnvironmentChecker;
2015-09-10 23:13:48 +02:00
/**
* Class DevHealthControllerTest
*
* @package environmentcheck
2015-09-10 23:13:48 +02:00
*/
2015-11-21 07:18:35 +01:00
class DevHealthControllerTest extends SapphireTest
{
/**
* {@inheritDoc}
* @var array
*/
2016-07-12 04:08:29 +02:00
protected $usesDatabase = true;
2015-11-21 07:18:35 +01:00
public function testIndexCreatesChecker()
{
$controller = new DevHealthController();
2015-09-10 23:13:48 +02:00
$request = new HTTPRequest('GET', 'example.com');
2015-09-10 23:13:48 +02:00
2015-11-21 07:18:35 +01:00
// we need to fake authenticated access as BasicAuth::requireLogin doesn't like empty
// permission type strings, which is what health check uses.
2015-09-10 23:13:48 +02:00
putenv('ENVCHECK_BASICAUTH_USERNAME="foo"');
putenv('ENVCHECK_BASICAUTH_PASSWORD="bar"');
2015-09-10 23:13:48 +02:00
2015-11-21 07:18:35 +01:00
$_SERVER['PHP_AUTH_USER'] = 'foo';
$_SERVER['PHP_AUTH_PW'] = 'bar';
2015-09-10 23:13:48 +02:00
$this->assertInstanceOf(EnvironmentChecker::class, $controller->index($request));
2015-11-21 07:18:35 +01:00
}
2015-09-10 23:13:48 +02:00
}