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
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
public function setUp() {
|
2010-12-21 10:42:44 +01:00
|
|
|
parent::setUp();
|
2014-09-15 11:47:45 +02:00
|
|
|
|
|
|
|
Config::nest();
|
|
|
|
|
|
|
|
// explicitly use dev/docs. Custom paths should be tested separately
|
|
|
|
Config::inst()->update(
|
|
|
|
'DocumentationViewer', 'link_base', 'dev/docs'
|
|
|
|
);
|
|
|
|
|
|
|
|
// disable automatic module registration so modules don't interfere.
|
|
|
|
Config::inst()->update(
|
|
|
|
'DocumentationManifest', 'automatic_registration', false
|
|
|
|
);
|
|
|
|
|
|
|
|
Config::inst()->remove('DocumentationManifest', 'register_entities');
|
|
|
|
Config::inst()->update('DocumentationSearch', 'enabled', true);
|
|
|
|
Config::inst()->update(
|
|
|
|
'DocumentationManifest', 'register_entities', array(
|
|
|
|
array(
|
|
|
|
'Path' => DOCSVIEWER_PATH . "/tests/docs-search/",
|
|
|
|
'Title' => 'Docs Search Test', )
|
|
|
|
)
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->manifest = new DocumentationManifest(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function tearDown() {
|
|
|
|
parent::tearDown();
|
2010-12-21 10:42:44 +01:00
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
Config::unnest();
|
2010-12-21 10:42:44 +01:00
|
|
|
}
|
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
public function testOpenSearchControllerAccessible() {
|
2011-08-02 05:30:58 +02:00
|
|
|
$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());
|
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
Config::inst()->update('DocumentationSearch', 'enabled', 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());
|
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
// 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
|
|
|
|
|
|
|
|
Config::inst()->update('DocumentationSearch', 'enabled', 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
|
|
|
}
|