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
|
|
|
|
*/
|
|
|
|
|
2015-11-21 07:25:41 +01:00
|
|
|
class DocumentationSearchTest extends FunctionalTest
|
|
|
|
{
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
parent::setUp();
|
2014-09-15 11:47:45 +02:00
|
|
|
|
2015-11-21 07:25:41 +01:00
|
|
|
Config::nest();
|
2014-09-15 11:47:45 +02:00
|
|
|
|
2017-08-08 05:50:24 +02:00
|
|
|
// explicitly use dev/docs. Custom paths should be tested separately
|
2015-11-21 07:25:41 +01:00
|
|
|
Config::inst()->update(
|
2017-08-08 05:50:24 +02:00
|
|
|
'DocumentationViewer',
|
|
|
|
'link_base',
|
|
|
|
'dev/docs'
|
2015-11-21 07:25:41 +01:00
|
|
|
);
|
2014-09-15 11:47:45 +02:00
|
|
|
|
2015-11-21 07:25:41 +01:00
|
|
|
// disable automatic module registration so modules don't interfere.
|
|
|
|
Config::inst()->update(
|
2017-08-08 05:50:24 +02:00
|
|
|
'DocumentationManifest',
|
|
|
|
'automatic_registration',
|
|
|
|
false
|
2015-11-21 07:25:41 +01:00
|
|
|
);
|
2014-09-15 11:47:45 +02:00
|
|
|
|
2015-11-21 07:25:41 +01:00
|
|
|
Config::inst()->remove('DocumentationManifest', 'register_entities');
|
|
|
|
Config::inst()->update('DocumentationSearch', 'enabled', true);
|
|
|
|
Config::inst()->update(
|
2017-08-08 05:50:24 +02:00
|
|
|
'DocumentationManifest',
|
|
|
|
'register_entities',
|
|
|
|
array(
|
2015-11-21 07:25:41 +01:00
|
|
|
array(
|
|
|
|
'Path' => DOCSVIEWER_PATH . "/tests/docs-search/",
|
|
|
|
'Title' => 'Docs Search Test', )
|
|
|
|
)
|
|
|
|
);
|
2014-09-15 11:47:45 +02:00
|
|
|
|
2015-11-21 07:25:41 +01:00
|
|
|
$this->manifest = new DocumentationManifest(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function tearDown()
|
|
|
|
{
|
|
|
|
parent::tearDown();
|
|
|
|
|
|
|
|
Config::unnest();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testOpenSearchControllerAccessible()
|
|
|
|
{
|
|
|
|
$c = new DocumentationOpenSearchController();
|
|
|
|
$response = $c->handleRequest(new SS_HTTPRequest('GET', ''), DataModel::inst());
|
2016-12-02 03:31:18 +01:00
|
|
|
// $this->assertEquals(404, $response->getStatusCode());
|
2015-11-21 07:25:41 +01:00
|
|
|
|
|
|
|
Config::inst()->update('DocumentationSearch', 'enabled', false);
|
2014-09-15 11:47:45 +02:00
|
|
|
|
2015-11-21 07:25:41 +01:00
|
|
|
$response = $c->handleRequest(new SS_HTTPRequest('GET', 'description/'), DataModel::inst());
|
2016-12-02 03:31:18 +01:00
|
|
|
// $this->assertEquals(404, $response->getStatusCode());
|
2015-11-21 07:25:41 +01:00
|
|
|
|
2017-08-08 05:50:24 +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
|
2015-11-21 07:25:41 +01:00
|
|
|
// are there
|
2014-09-15 11:47:45 +02:00
|
|
|
|
2015-11-21 07:25:41 +01:00
|
|
|
Config::inst()->update('DocumentationSearch', 'enabled', true);
|
|
|
|
|
|
|
|
$response = $c->handleRequest(new SS_HTTPRequest('GET', 'description'), DataModel::inst());
|
2016-12-02 03:31:18 +01:00
|
|
|
// $this->assertEquals(200, $response->getStatusCode());
|
2015-11-21 07:25:41 +01:00
|
|
|
|
|
|
|
$desc = new SimpleXMLElement($response->getBody());
|
2016-12-02 03:31:18 +01:00
|
|
|
// $this->assertEquals(2, count($desc->Url));
|
2015-11-21 07:25:41 +01:00
|
|
|
}
|
|
|
|
}
|