2009-06-24 06:56:50 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Test that SilverStripe is accessible through the webserver
|
|
|
|
* by using curl with an actual HTTP request, instead of an in-memory
|
|
|
|
* test through {@link Director::test()}.
|
|
|
|
* This can help to uncover e.g. webserver routing problems with .htaccess files.
|
|
|
|
*
|
|
|
|
* @todo Exclude this test from a standard test run - not all test environments
|
|
|
|
* might have a webserver installed, or have it accessible for HTTP requests
|
|
|
|
* from localhost.
|
|
|
|
*
|
|
|
|
* @package sapphire
|
|
|
|
* @subpackage tests
|
|
|
|
*/
|
|
|
|
class WebserverRoutingTest extends SapphireTest {
|
|
|
|
|
|
|
|
function testCanAccessWebserverThroughCurl() {
|
|
|
|
if(!function_exists('curl_init')) return;
|
|
|
|
|
2009-10-16 00:41:32 +02:00
|
|
|
$url = Director::absoluteBaseURL() . 'WebserverRoutingTest_Controller/?usetestmanifest=1&flush=1';
|
2009-06-24 06:56:50 +02:00
|
|
|
|
|
|
|
$ch = curl_init();
|
|
|
|
curl_setopt ($ch, CURLOPT_URL,$url );
|
|
|
|
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
|
|
|
|
$response = curl_exec($ch);
|
|
|
|
$info = curl_getinfo($ch);
|
|
|
|
|
|
|
|
$this->assertEquals(curl_error($ch), '');
|
2010-10-15 01:51:34 +02:00
|
|
|
$this->assertEquals(trim($response), 'ok');
|
2009-06-24 06:56:50 +02:00
|
|
|
|
|
|
|
curl_close($ch);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @package sapphire
|
|
|
|
* @subpackage tests
|
|
|
|
*/
|
|
|
|
class WebserverRoutingTest_Controller extends Controller {
|
|
|
|
function index() {
|
2009-11-16 00:43:30 +01:00
|
|
|
BasicAuth::protect_entire_site(false);
|
2009-06-24 06:56:50 +02:00
|
|
|
|
|
|
|
return "ok";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|