2015-09-10 23:13:48 +02:00
|
|
|
<?php
|
|
|
|
|
2017-01-04 23:16:12 +01:00
|
|
|
namespace SilverStripe\EnvironmentCheck\Tests\Controllers;
|
|
|
|
|
|
|
|
use SilverStripe\Control\HTTPRequest;
|
|
|
|
use SilverStripe\Dev\SapphireTest;
|
|
|
|
use SilverStripe\EnvironmentCheck\Controllers\DevHealthController;
|
2017-03-21 11:57:07 +01:00
|
|
|
use SilverStripe\EnvironmentCheck\EnvironmentChecker;
|
2017-01-04 23:16:12 +01:00
|
|
|
|
2015-09-10 23:13:48 +02:00
|
|
|
/**
|
2017-01-04 23:16:12 +01:00
|
|
|
* Class DevHealthControllerTest
|
|
|
|
*
|
2015-09-10 23:13:48 +02:00
|
|
|
* @mixin PHPUnit_Framework_TestCase
|
2017-01-04 23:16:12 +01:00
|
|
|
*
|
|
|
|
* @package environmentcheck
|
2015-09-10 23:13:48 +02:00
|
|
|
*/
|
2015-11-21 07:18:35 +01:00
|
|
|
class DevHealthControllerTest extends SapphireTest
|
|
|
|
{
|
2017-01-04 23:16:12 +01:00
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
* @var array
|
|
|
|
*/
|
2016-07-12 04:08:29 +02:00
|
|
|
protected $usesDatabase = true;
|
2017-01-04 23:16:12 +01:00
|
|
|
|
2015-11-21 07:18:35 +01:00
|
|
|
public function testIndexCreatesChecker()
|
|
|
|
{
|
|
|
|
$controller = new DevHealthController();
|
2015-09-10 23:13:48 +02:00
|
|
|
|
2017-01-04 23:16:12 +01: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
|
|
|
|
2017-03-21 11:57:07 +01: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
|
|
|
|
2017-03-21 11:57:07 +01:00
|
|
|
$this->assertInstanceOf(EnvironmentChecker::class, $controller->index($request));
|
2015-11-21 07:18:35 +01:00
|
|
|
}
|
2015-09-10 23:13:48 +02:00
|
|
|
}
|