silverstripe-framework/tests/WebserverRoutingTest.php
Ingo Schommer 326036a501 Excluded or removed tests relying on actual webserver routing
The "sanitychecks" group excludes through phpunit.xml.dist.
Removed RestfulService->testHttpErrorWithoutCache()
since its not sufficiently isolated in terms of testing.
Has been refactored in 3.x, but too intrusive to backport.

Changes mainly necessary to get Travis builds passing,
since we don't want to start mucking around with
dynamically generated file-to-url mappings just to
get *unit* tests passing - as opposed to integration-testing
the whole environment incl. webserver.
2012-11-28 15:35:09 +01:00

49 lines
1.3 KiB
PHP

<?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.
*
* @group sanitychecks
*
* @package sapphire
* @subpackage tests
*/
class WebserverRoutingTest extends SapphireTest {
function testCanAccessWebserverThroughCurl() {
if(!function_exists('curl_init')) return;
$url = Director::absoluteBaseURL() . 'WebserverRoutingTest_Controller/?usetestmanifest=1&flush=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->assertTrue(in_array(trim($response), array('ok', _t('BasicAuth.ENTERINFO'))));
curl_close($ch);
}
}
/**
* @package sapphire
* @subpackage tests
*/
class WebserverRoutingTest_Controller extends Controller {
function index() {
BasicAuth::protect_entire_site(false);
return "ok";
}
}
?>