mirror of
https://github.com/silverstripe/doc.silverstripe.org
synced 2024-10-22 17:05:50 +02:00
db7b9f408b
git-svn-id: http://svn.silverstripe.com/projects/ss2doc/branches/v2@120789 467b73ca-7a2a-4603-9d3b-597d59a354a9
50 lines
1.6 KiB
PHP
Executable File
50 lines
1.6 KiB
PHP
Executable File
<?php
|
|
|
|
/**
|
|
* @package sapphiredocs
|
|
* @subpackage tests
|
|
*/
|
|
|
|
class DocumentationSearchTest extends FunctionalTest {
|
|
|
|
function setUp() {
|
|
parent::setUp();
|
|
|
|
if(!DocumentationSearch::enabled()) return;
|
|
|
|
DocumentationService::set_automatic_registration(false);
|
|
DocumentationService::register('docs-search', BASE_PATH . '/sapphiredocs/tests/docs-search/');
|
|
}
|
|
|
|
function testGetAllPages() {
|
|
if(!DocumentationSearch::enabled()) return;
|
|
|
|
DocumentationService::set_automatic_registration(false);
|
|
DocumentationService::register('docs-search', BASE_PATH . '/sapphiredocs/tests/docs-search/');
|
|
|
|
$search = DocumentationSearch::get_all_documentation_pages();
|
|
|
|
$this->assertEquals(7, $search->Count(), '5 pages. 5 pages in entire folder');
|
|
}
|
|
|
|
function testOpenSearchControllerAccessible() {
|
|
$c = new DocumentationOpenSearchController();
|
|
|
|
$response = $c->handleRequest(new SS_HTTPRequest('GET', ''));
|
|
$this->assertEquals(404, $response->getStatusCode());
|
|
|
|
// test accessing it when the search isn't active
|
|
DocumentationSearch::enable(false);
|
|
$response = $c->handleRequest(new SS_HTTPRequest('GET', 'description/'));
|
|
$this->assertEquals(404, $response->getStatusCode());
|
|
|
|
// test we get a response to the description. The meta data test will check
|
|
// that the individual fields are valid but we should check urls are there
|
|
DocumentationSearch::enable(true);
|
|
$response = $c->handleRequest(new SS_HTTPRequest('GET', 'description'));
|
|
$this->assertEquals(200, $response->getStatusCode());
|
|
|
|
$desc = new SimpleXMLElement($response->getBody());
|
|
$this->assertEquals(2, count($desc->Url));
|
|
}
|
|
} |