2008-12-04 23:38:32 +01:00
|
|
|
<?php
|
2009-04-29 03:20:24 +02:00
|
|
|
/**
|
|
|
|
* @package sapphire
|
|
|
|
* @subpackage tests
|
|
|
|
*/
|
|
|
|
class ErrorPageTest extends FunctionalTest {
|
2008-12-04 23:38:32 +01:00
|
|
|
|
|
|
|
static $fixture_file = 'sapphire/tests/ErrorPageTest.yml';
|
|
|
|
|
2009-05-04 04:20:57 +02:00
|
|
|
protected $orig = array();
|
|
|
|
|
|
|
|
protected $tmpAssetsPath = '';
|
|
|
|
|
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->orig['ErrorPage_staticfilepath'] = ErrorPage::get_static_filepath();
|
|
|
|
$this->tmpAssetsPath = sprintf('%s/_tmp_assets_%s', TEMP_FOLDER, rand());
|
|
|
|
Filesystem::makeFolder($this->tmpAssetsPath . '/ErrorPageTest');
|
|
|
|
ErrorPage::set_static_filepath($this->tmpAssetsPath . '/ErrorPageTest');
|
|
|
|
|
|
|
|
$this->orig['Director_environmenttype'] = Director::get_environment_type();
|
|
|
|
Director::set_environment_type('live');
|
|
|
|
}
|
|
|
|
|
|
|
|
function tearDown() {
|
|
|
|
parent::tearDown();
|
|
|
|
|
|
|
|
ErrorPage::set_static_filepath($this->orig['ErrorPage_staticfilepath']);
|
|
|
|
Director::set_environment_type($this->orig['Director_environmenttype']);
|
|
|
|
|
|
|
|
Filesystem::removeFolder($this->tmpAssetsPath . '/ErrorPageTest');
|
|
|
|
Filesystem::removeFolder($this->tmpAssetsPath);
|
|
|
|
}
|
|
|
|
|
2008-12-04 23:38:32 +01:00
|
|
|
function test404ErrorPage() {
|
2009-04-29 03:20:24 +02:00
|
|
|
$page = $this->objFromFixture('ErrorPage', '404');
|
2009-05-04 04:20:57 +02:00
|
|
|
// ensure that the errorpage exists as a physical file
|
|
|
|
$page->publish('Stage', 'Live');
|
2008-12-04 23:38:32 +01:00
|
|
|
|
2009-05-04 04:20:57 +02:00
|
|
|
$response = $this->get('nonexistent-page');
|
2008-12-04 23:38:32 +01:00
|
|
|
|
2009-05-04 04:20:57 +02:00
|
|
|
/* We have body text from the error page */
|
2009-04-29 03:20:24 +02:00
|
|
|
$this->assertNotNull($response->getBody(), 'We have body text from the error page');
|
2009-05-04 04:20:57 +02:00
|
|
|
|
2008-12-04 23:38:32 +01:00
|
|
|
/* Status code of the HTTPResponse for error page is "404" */
|
2009-05-04 04:20:57 +02:00
|
|
|
$this->assertEquals($response->getStatusCode(), '404', 'Status code of the HTTPResponse for error page is "404"');
|
2008-12-04 23:38:32 +01:00
|
|
|
|
|
|
|
/* Status message of the HTTPResponse for error page is "Not Found" */
|
2009-04-29 03:20:24 +02:00
|
|
|
$this->assertEquals($response->getStatusDescription(), 'Not Found', 'Status message of the HTTResponse for error page is "Not found"');
|
|
|
|
}
|
|
|
|
|
|
|
|
function testBehaviourOfShowInMenuAndShowInSearchFlags() {
|
|
|
|
$page = $this->objFromFixture('ErrorPage', '404');
|
|
|
|
|
|
|
|
/* Don't show the error page in the menus */
|
|
|
|
$this->assertEquals($page->ShowInMenus, 0, 'Don\'t show the error page in the menus');
|
|
|
|
|
|
|
|
/* Don't show the error page in the search */
|
|
|
|
$this->assertEquals($page->ShowInSearch, 0, 'Don\'t show the error page in search');
|
2008-12-04 23:38:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
?>
|