2010-12-21 10:42:44 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2012-04-08 11:36:16 +02:00
|
|
|
* @package docsviewer
|
2010-12-21 10:42:44 +01:00
|
|
|
* @subpackage tests
|
|
|
|
*/
|
|
|
|
|
2011-08-02 05:30:58 +02:00
|
|
|
class DocumentationSearchTest extends FunctionalTest {
|
2010-12-21 10:42:44 +01:00
|
|
|
|
|
|
|
function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
if(!DocumentationSearch::enabled()) return;
|
|
|
|
|
|
|
|
DocumentationService::set_automatic_registration(false);
|
2012-04-08 11:36:16 +02:00
|
|
|
DocumentationService::register('docs-search', DOCSVIEWER_PATH . '/tests/docs-search/');
|
2010-12-21 10:42:44 +01:00
|
|
|
}
|
|
|
|
|
2011-08-02 05:30:58 +02:00
|
|
|
function testOpenSearchControllerAccessible() {
|
|
|
|
$c = new DocumentationOpenSearchController();
|
|
|
|
|
2012-04-14 08:02:53 +02:00
|
|
|
$response = $c->handleRequest(new SS_HTTPRequest('GET', ''), DataModel::inst());
|
2011-08-02 05:30:58 +02:00
|
|
|
$this->assertEquals(404, $response->getStatusCode());
|
|
|
|
|
|
|
|
// test accessing it when the search isn't active
|
|
|
|
DocumentationSearch::enable(false);
|
2012-04-14 08:02:53 +02:00
|
|
|
$response = $c->handleRequest(new SS_HTTPRequest('GET', 'description/'), DataModel::inst());
|
2011-08-02 05:30:58 +02:00
|
|
|
$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);
|
2012-04-14 08:02:53 +02:00
|
|
|
$response = $c->handleRequest(new SS_HTTPRequest('GET', 'description'), DataModel::inst());
|
2011-08-02 05:30:58 +02:00
|
|
|
$this->assertEquals(200, $response->getStatusCode());
|
|
|
|
|
|
|
|
$desc = new SimpleXMLElement($response->getBody());
|
|
|
|
$this->assertEquals(2, count($desc->Url));
|
|
|
|
}
|
2010-12-21 10:42:44 +01:00
|
|
|
}
|