mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
MINOR Added WebserverRoutingTest as a substitute smoke test for .htaccess problems etc. - this used to be implicit functionality in RestfulServiceTest
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@79948 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
6b90c02940
commit
0d1db9834d
47
tests/WebserverRoutingTest.php
Normal file
47
tests/WebserverRoutingTest.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?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;
|
||||
|
||||
$url = Director::absoluteBaseURL() . 'WebserverRoutingTest_Controller/?usetestmanifest=1';
|
||||
|
||||
$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), '');
|
||||
$this->assertEquals($response, 'ok');
|
||||
|
||||
curl_close($ch);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @package sapphire
|
||||
* @subpackage tests
|
||||
*/
|
||||
class WebserverRoutingTest_Controller extends Controller {
|
||||
function index() {
|
||||
BasicAuth::disable();
|
||||
|
||||
return "ok";
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in New Issue
Block a user