MINOR: rename from docviewer to docsviewer

This commit is contained in:
Will Rossiter 2012-04-08 21:36:16 +12:00
parent a87094fb16
commit 1e28e8252f
17 changed files with 81 additions and 81 deletions

View File

@ -3,15 +3,15 @@
* Documentation Configuration * Documentation Configuration
* *
* Please override any of these options in your own projects _config.php file. * Please override any of these options in your own projects _config.php file.
* For more information and documentation see docviewer/docs/en * For more information and documentation see docsviewer/docs/en
*/ */
if(!defined('DOCVIEWER_PATH')) { if(!defined('DOCSVIEWER_PATH')) {
define('DOCVIEWER_PATH', dirname(__FILE__)); define('DOCSVIEWER_PATH', dirname(__FILE__));
} }
if(!defined('DOCVIEWER_DIR')) { if(!defined('DOCSVIEWER_DIR')) {
define('DOCVIEWER_DIR', array_pop(explode(DIRECTORY_SEPARATOR, DOCVIEWER_PATH))); define('DOCSVIEWER_DIR', array_pop(explode(DIRECTORY_SEPARATOR, DOCSVIEWER_PATH)));
} }

View File

@ -3,7 +3,7 @@
/** /**
* Parser wrapping the Markdown Extra parser (see http://michelf.com/projects/php-markdown/extra/). * Parser wrapping the Markdown Extra parser (see http://michelf.com/projects/php-markdown/extra/).
* *
* @package docviewer * @package docsviewer
*/ */
class DocumentationParser { class DocumentationParser {
@ -45,7 +45,7 @@ class DocumentationParser {
$md = self::rewrite_heading_anchors($md, $page); $md = self::rewrite_heading_anchors($md, $page);
$md = self::rewrite_code_blocks($md, $page); $md = self::rewrite_code_blocks($md, $page);
require_once(DOCVIEWER_PATH .'/thirdparty/markdown/markdown.php'); require_once(DOCSVIEWER_PATH .'/thirdparty/markdown/markdown.php');
$parser = new MarkdownExtra_Parser(); $parser = new MarkdownExtra_Parser();
$parser->no_markup = true; $parser->no_markup = true;

View File

@ -6,7 +6,7 @@
* *
* Redirects the user from example.com/foo to example.com/en/module/foo * Redirects the user from example.com/foo to example.com/en/module/foo
* *
* @package docviewer * @package docsviewer
*/ */
class DocumentationPermalinks { class DocumentationPermalinks {

View File

@ -21,7 +21,7 @@
* yoursite.com/search/?q=Foo&start=10&limit=10 * yoursite.com/search/?q=Foo&start=10&limit=10
* </code> * </code>
* *
* @package docviewer * @package docsviewer
*/ */
class DocumentationSearch { class DocumentationSearch {
@ -183,7 +183,7 @@ class DocumentationSearch {
*/ */
public function get_index_location() { public function get_index_location() {
if(!self::$index_location) if(!self::$index_location)
self::$index_location = DOCVIEWER_DIR; self::$index_location = DOCSVIEWER_DIR;
return Controller::join_links( return Controller::join_links(
TEMP_FOLDER, TEMP_FOLDER,

View File

@ -8,7 +8,7 @@
* Includes registering which components to document and handles the entities being * Includes registering which components to document and handles the entities being
* documented. * documented.
* *
* @package docviewer * @package docsviewer
*/ */
class DocumentationService { class DocumentationService {

View File

@ -4,7 +4,7 @@
* Public facing controller for handling an opensearch interface based on * Public facing controller for handling an opensearch interface based on
* the standard search form. * the standard search form.
* *
* @package docviewer * @package docsviewer
*/ */
class DocumentationOpenSearchController extends ContentController { class DocumentationOpenSearchController extends ContentController {

View File

@ -9,7 +9,7 @@
* For more documentation on how to use this class see the documentation in the * For more documentation on how to use this class see the documentation in the
* docs folder * docs folder
* *
* @package docviewer * @package docsviewer
*/ */
class DocumentationViewer extends Controller { class DocumentationViewer extends Controller {
@ -65,19 +65,19 @@ class DocumentationViewer extends Controller {
Requirements::combine_files( Requirements::combine_files(
'syntaxhighlighter.js', 'syntaxhighlighter.js',
array( array(
DOCVIEWER_DIR .'/thirdparty/syntaxhighlighter/scripts/shCore.js', DOCSVIEWER_DIR .'/thirdparty/syntaxhighlighter/scripts/shCore.js',
DOCVIEWER_DIR . '/thirdparty/syntaxhighlighter/scripts/shBrushJScript.js', DOCSVIEWER_DIR . '/thirdparty/syntaxhighlighter/scripts/shBrushJScript.js',
DOCVIEWER_DIR . '/thirdparty/syntaxhighlighter/scripts/shBrushPhp.js', DOCSVIEWER_DIR . '/thirdparty/syntaxhighlighter/scripts/shBrushPhp.js',
DOCVIEWER_DIR . '/thirdparty/syntaxhighlighter/scripts/shBrushXml.js', DOCSVIEWER_DIR . '/thirdparty/syntaxhighlighter/scripts/shBrushXml.js',
DOCVIEWER_DIR . '/thirdparty/syntaxhighlighter/scripts/shBrushCss.js', DOCSVIEWER_DIR . '/thirdparty/syntaxhighlighter/scripts/shBrushCss.js',
DOCVIEWER_DIR . '/javascript/shBrushSS.js' DOCSVIEWER_DIR . '/javascript/shBrushSS.js'
) )
); );
Requirements::javascript(DOCVIEWER_DIR .'/javascript/DocumentationViewer.js'); Requirements::javascript(DOCSVIEWER_DIR .'/javascript/DocumentationViewer.js');
Requirements::css(DOCVIEWER_DIR .'/css/shSilverStripeDocs.css'); Requirements::css(DOCSVIEWER_DIR .'/css/shSilverStripeDocs.css');
Requirements::css(DOCVIEWER_DIR .'/css/DocumentationViewer.css'); Requirements::css(DOCSVIEWER_DIR .'/css/DocumentationViewer.css');
} }
/** /**

View File

@ -17,7 +17,7 @@
* *
* @see http://php.net/manual/en/function.version-compare.php * @see http://php.net/manual/en/function.version-compare.php
* *
* @package docviewer * @package docsviewer
* @subpackage models * @subpackage models
*/ */

View File

@ -4,7 +4,7 @@
* A specific page within a {@link DocumentationEntity}. Maps 1 to 1 to a file on the * A specific page within a {@link DocumentationEntity}. Maps 1 to 1 to a file on the
* filesystem. * filesystem.
* *
* @package docviewer * @package docsviewer
* @subpackage model * @subpackage model
*/ */
class DocumentationPage extends ViewableData { class DocumentationPage extends ViewableData {

View File

@ -5,7 +5,7 @@
* *
* For the hourly cron rebuild use RebuildLuceneDocusIndex_Hourly * For the hourly cron rebuild use RebuildLuceneDocusIndex_Hourly
* *
* @package docviewer * @package docsviewer
* @subpackage tasks * @subpackage tasks
*/ */
@ -14,14 +14,14 @@ class RebuildLuceneDocsIndex extends BuildTask {
protected $title = "Rebuild Documentation Search Indexes"; protected $title = "Rebuild Documentation Search Indexes";
protected $description = " protected $description = "
Rebuilds the indexes used for the search engine in the docviewer."; Rebuilds the indexes used for the search engine in the docsviewer.";
function run($request) { function run($request) {
$this->rebuildIndexes(); $this->rebuildIndexes();
} }
function rebuildIndexes($quiet = false) { function rebuildIndexes($quiet = false) {
require_once(DOCVIEWER_PATH .'/thirdparty/markdown/markdown.php'); require_once(DOCSVIEWER_PATH .'/thirdparty/markdown/markdown.php');
require_once 'Zend/Search/Lucene.php'; require_once 'Zend/Search/Lucene.php';
ini_set("memory_limit", -1); ini_set("memory_limit", -1);
@ -107,7 +107,7 @@ class RebuildLuceneDocsIndex extends BuildTask {
} }
/** /**
* @package docviewer * @package docsviewer
* @subpackage tasks * @subpackage tasks
*/ */
class RebuildLuceneDocusIndex_Hourly extends HourlyTask { class RebuildLuceneDocusIndex_Hourly extends HourlyTask {

View File

@ -1,4 +1,4 @@
# Docviewer Module # docsviewer Module
This module has been developed to read and display content from markdown and This module has been developed to read and display content from markdown and
plain text files in web browser. It provides an easy way to bundle end user plain text files in web browser. It provides an easy way to bundle end user
@ -36,7 +36,7 @@ location then you can register paths directly:
To configure the documentation system the configuration information is To configure the documentation system the configuration information is
available on the [Configurations](dev/docs/en/docviewer/configuration-options) available on the [Configurations](dev/docs/en/docsviewer/configuration-options)
page. page.
## Writing documentation ## Writing documentation

View File

@ -1,12 +1,12 @@
<?php <?php
/** /**
* @package docviewer * @package docsviewer
* @subpackage tests * @subpackage tests
*/ */
class DocumentationEntityTest extends SapphireTest { class DocumentationEntityTest extends SapphireTest {
function testDocumentationEntityAccessing() { function testDocumentationEntityAccessing() {
$entity = new DocumentationEntity('docs', '1.0', DOCVIEWER_PATH .'/tests/docs/', 'My Test'); $entity = new DocumentationEntity('docs', '1.0', DOCSVIEWER_PATH .'/tests/docs/', 'My Test');
$this->assertEquals($entity->getTitle(), 'My Test'); $this->assertEquals($entity->getTitle(), 'My Test');
$this->assertEquals($entity->getVersions(), array('1.0')); $this->assertEquals($entity->getVersions(), array('1.0'));
@ -21,13 +21,13 @@ class DocumentationEntityTest extends SapphireTest {
} }
function testgetStableVersion() { function testgetStableVersion() {
$entity = new DocumentationEntity('docs', '1.0', DOCVIEWER_PATH. '/tests/docs/', 'My Test'); $entity = new DocumentationEntity('docs', '1.0', DOCSVIEWER_PATH. '/tests/docs/', 'My Test');
$entity->addVersion('1.1', DOCVIEWER_PATH. '/tests/docs-v2.4/'); $entity->addVersion('1.1', DOCSVIEWER_PATH. '/tests/docs-v2.4/');
$entity->addVersion('0.0', DOCVIEWER_PATH. '/tests/docs-v3.0/'); $entity->addVersion('0.0', DOCSVIEWER_PATH. '/tests/docs-v3.0/');
$this->assertEquals('1.1', $entity->getStableVersion(), 'Automatic version sorting'); $this->assertEquals('1.1', $entity->getStableVersion(), 'Automatic version sorting');
$entity = new DocumentationEntity('docs', '1.0', DOCVIEWER_PATH. '/tests/docs/', 'My Test'); $entity = new DocumentationEntity('docs', '1.0', DOCSVIEWER_PATH. '/tests/docs/', 'My Test');
$entity->addVersion('1.1.', DOCVIEWER_PATH .'/tests/docs-v2.4/'); $entity->addVersion('1.1.', DOCSVIEWER_PATH .'/tests/docs-v2.4/');
$entity->setStableVersion('1.0'); $entity->setStableVersion('1.0');
$this->assertEquals('1.0', $entity->getStableVersion(), 'Manual setting'); $this->assertEquals('1.0', $entity->getStableVersion(), 'Manual setting');
} }

View File

@ -1,14 +1,14 @@
<?php <?php
/** /**
* @package docviewer * @package docsviewer
* @subpackage tests * @subpackage tests
*/ */
class DocumentationPageTest extends SapphireTest { class DocumentationPageTest extends SapphireTest {
function testGetLink() { function testGetLink() {
$entity = new DocumentationEntity('testmodule', null, DOCVIEWER_PATH .'/tests/docs/'); $entity = new DocumentationEntity('testmodule', null, DOCSVIEWER_PATH .'/tests/docs/');
$page = new DocumentationPage(); $page = new DocumentationPage();
$page->setRelativePath('test.md'); $page->setRelativePath('test.md');
@ -32,8 +32,8 @@ class DocumentationPageTest extends SapphireTest {
$this->assertStringEndsWith('testmodule/en/subfolder/subpage', $nested->Link()); $this->assertStringEndsWith('testmodule/en/subfolder/subpage', $nested->Link());
// test with version. // test with version.
$entity = DocumentationService::register("versionlinks", DOCVIEWER_PATH ."/tests/docs-v2.4/", '1'); $entity = DocumentationService::register("versionlinks", DOCSVIEWER_PATH ."/tests/docs-v2.4/", '1');
$entity->addVersion('2', DOCVIEWER_PATH ."/tests/docs-v3.0/"); $entity->addVersion('2', DOCSVIEWER_PATH ."/tests/docs-v3.0/");
$entity->setStableVersion('2'); $entity->setStableVersion('2');
$page = new DocumentationPage(); $page = new DocumentationPage();
@ -47,19 +47,19 @@ class DocumentationPageTest extends SapphireTest {
function testGetRelativePath() { function testGetRelativePath() {
$page = new DocumentationPage(); $page = new DocumentationPage();
$page->setRelativePath('test.md'); $page->setRelativePath('test.md');
$page->setEntity(new DocumentationEntity('mymodule', null, DOCVIEWER_PATH . '/tests/docs/')); $page->setEntity(new DocumentationEntity('mymodule', null, DOCSVIEWER_PATH . '/tests/docs/'));
$this->assertEquals('test.md', $page->getRelativePath()); $this->assertEquals('test.md', $page->getRelativePath());
$page = new DocumentationPage(); $page = new DocumentationPage();
$page->setRelativePath('subfolder/subpage.md'); $page->setRelativePath('subfolder/subpage.md');
$page->setEntity(new DocumentationEntity('mymodule', null, DOCVIEWER_PATH . '/tests/docs/')); $page->setEntity(new DocumentationEntity('mymodule', null, DOCSVIEWER_PATH . '/tests/docs/'));
$this->assertEquals('subfolder/subpage.md', $page->getRelativePath()); $this->assertEquals('subfolder/subpage.md', $page->getRelativePath());
} }
function testGetPath() { function testGetPath() {
$absPath = DOCVIEWER_PATH .'/tests/docs/'; $absPath = DOCSVIEWER_PATH .'/tests/docs/';
$page = new DocumentationPage(); $page = new DocumentationPage();
$page->setRelativePath('test.md'); $page->setRelativePath('test.md');
$page->setEntity(new DocumentationEntity('mymodule', null, $absPath)); $page->setEntity(new DocumentationEntity('mymodule', null, $absPath));
@ -74,7 +74,7 @@ class DocumentationPageTest extends SapphireTest {
} }
function testGetBreadcrumbTitle() { function testGetBreadcrumbTitle() {
$entity = new DocumentationEntity('testmodule', null, DOCVIEWER_PATH . '/tests/docs/'); $entity = new DocumentationEntity('testmodule', null, DOCSVIEWER_PATH . '/tests/docs/');
$page = new DocumentationPage(); $page = new DocumentationPage();
$page->setRelativePath('test.md'); $page->setRelativePath('test.md');
@ -84,7 +84,7 @@ class DocumentationPageTest extends SapphireTest {
$page = new DocumentationPage(); $page = new DocumentationPage();
$page->setRelativePath('subfolder/subpage.md'); $page->setRelativePath('subfolder/subpage.md');
$page->setEntity(new DocumentationEntity('mymodule', null, DOCVIEWER_PATH . '/tests/docs/')); $page->setEntity(new DocumentationEntity('mymodule', null, DOCSVIEWER_PATH . '/tests/docs/'));
$this->assertEquals('Mymodule - Subfolder - Subpage', $page->getBreadcrumbTitle()); $this->assertEquals('Mymodule - Subfolder - Subpage', $page->getBreadcrumbTitle());
} }

View File

@ -1,13 +1,13 @@
<?php <?php
/** /**
* @package docviewer * @package docsviewer
*/ */
class DocumentationParserTest extends SapphireTest { class DocumentationParserTest extends SapphireTest {
function testRewriteCodeBlocks() { function testRewriteCodeBlocks() {
$page = new DocumentationPage(); $page = new DocumentationPage();
$page->setRelativePath('test.md'); $page->setRelativePath('test.md');
$page->setEntity(new DocumentationEntity('mymodule', '2.4', DOCVIEWER_PATH . '/tests/docs/')); $page->setEntity(new DocumentationEntity('mymodule', '2.4', DOCSVIEWER_PATH . '/tests/docs/'));
$page->setLang('en'); $page->setLang('en');
$page->setVersion('2.4'); $page->setVersion('2.4');
$result = DocumentationParser::rewrite_code_blocks($page->getMarkdown()); $result = DocumentationParser::rewrite_code_blocks($page->getMarkdown());
@ -38,23 +38,23 @@ HTML;
// Page on toplevel // Page on toplevel
$page = new DocumentationPage(); $page = new DocumentationPage();
$page->setRelativePath('subfolder/subpage.md'); $page->setRelativePath('subfolder/subpage.md');
$page->setEntity(new DocumentationEntity('mymodule', '2.4', DOCVIEWER_PATH . '/tests/docs/')); $page->setEntity(new DocumentationEntity('mymodule', '2.4', DOCSVIEWER_PATH . '/tests/docs/'));
$page->setLang('en'); $page->setLang('en');
$page->setVersion('2.4'); $page->setVersion('2.4');
$result = DocumentationParser::rewrite_image_links($page->getMarkdown(), $page, 'mycontroller/cms/2.4/en/'); $result = DocumentationParser::rewrite_image_links($page->getMarkdown(), $page, 'mycontroller/cms/2.4/en/');
$this->assertContains( $this->assertContains(
'[relative image link](' . Director::absoluteBaseURL() .'/'. DOCVIEWER_DIR . '/tests/docs/en/subfolder/_images/image.png)', '[relative image link](' . Director::absoluteBaseURL() .'/'. DOCSVIEWER_DIR . '/tests/docs/en/subfolder/_images/image.png)',
$result $result
); );
$this->assertContains( $this->assertContains(
'[parent image link](' . Director::absoluteBaseURL() . '/'. DOCVIEWER_DIR. '/tests/docs/en/_images/image.png)', '[parent image link](' . Director::absoluteBaseURL() . '/'. DOCSVIEWER_DIR. '/tests/docs/en/_images/image.png)',
$result $result
); );
// $this->assertContains( // $this->assertContains(
// '[absolute image link](' . Director::absoluteBaseURL() . '/'. DOCVIEWER_DIR. '/tests/docs/en/_images/image.png)', // '[absolute image link](' . Director::absoluteBaseURL() . '/'. DOCSVIEWER_DIR. '/tests/docs/en/_images/image.png)',
// $result // $result
// ); // );
} }
@ -63,7 +63,7 @@ HTML;
// Page on toplevel // Page on toplevel
$page = new DocumentationPage(); $page = new DocumentationPage();
$page->setRelativePath('test.md'); $page->setRelativePath('test.md');
$page->setEntity(new DocumentationEntity('mymodule', '2.4', DOCVIEWER_PATH .'/tests/docs/')); $page->setEntity(new DocumentationEntity('mymodule', '2.4', DOCSVIEWER_PATH .'/tests/docs/'));
$page->setLang('en'); $page->setLang('en');
$page->setVersion('2.4'); $page->setVersion('2.4');
@ -81,7 +81,7 @@ HTML;
function testHeadlineAnchors() { function testHeadlineAnchors() {
$page = new DocumentationPage(); $page = new DocumentationPage();
$page->setRelativePath('test.md'); $page->setRelativePath('test.md');
$page->setEntity(new DocumentationEntity('mymodule', '2.4', DOCVIEWER_PATH . '/tests/docs/')); $page->setEntity(new DocumentationEntity('mymodule', '2.4', DOCSVIEWER_PATH . '/tests/docs/'));
$page->setLang('en'); $page->setLang('en');
$page->setVersion('2.4'); $page->setVersion('2.4');
@ -119,7 +119,7 @@ HTML;
// Page on toplevel // Page on toplevel
$page = new DocumentationPage(); $page = new DocumentationPage();
$page->setRelativePath('test.md'); $page->setRelativePath('test.md');
$page->setEntity(new DocumentationEntity('mymodule', '2.4', DOCVIEWER_PATH . '/tests/docs/')); $page->setEntity(new DocumentationEntity('mymodule', '2.4', DOCSVIEWER_PATH . '/tests/docs/'));
$result = DocumentationParser::rewrite_relative_links($page->getMarkdown(), $page, 'mycontroller/cms/2.4/en/'); $result = DocumentationParser::rewrite_relative_links($page->getMarkdown(), $page, 'mycontroller/cms/2.4/en/');
@ -147,7 +147,7 @@ HTML;
// Page in subfolder // Page in subfolder
$page = new DocumentationPage(); $page = new DocumentationPage();
$page->setRelativePath('subfolder/subpage.md'); $page->setRelativePath('subfolder/subpage.md');
$page->setEntity(new DocumentationEntity('mymodule', '2.4', DOCVIEWER_PATH . '/tests/docs/')); $page->setEntity(new DocumentationEntity('mymodule', '2.4', DOCSVIEWER_PATH . '/tests/docs/'));
$result = DocumentationParser::rewrite_relative_links($page->getMarkdown(), $page, 'mycontroller/cms/2.4/en/'); $result = DocumentationParser::rewrite_relative_links($page->getMarkdown(), $page, 'mycontroller/cms/2.4/en/');
@ -180,7 +180,7 @@ HTML;
// Page in nested subfolder // Page in nested subfolder
$page = new DocumentationPage(); $page = new DocumentationPage();
$page->setRelativePath('subfolder/subsubfolder/subsubpage.md'); $page->setRelativePath('subfolder/subsubfolder/subsubpage.md');
$page->setEntity(new DocumentationEntity('mymodule', '2.4', DOCVIEWER_PATH . '/tests/docs/')); $page->setEntity(new DocumentationEntity('mymodule', '2.4', DOCSVIEWER_PATH . '/tests/docs/'));
$result = DocumentationParser::rewrite_relative_links($page->getMarkdown(), $page, 'mycontroller/cms/2.4/en/'); $result = DocumentationParser::rewrite_relative_links($page->getMarkdown(), $page, 'mycontroller/cms/2.4/en/');
@ -209,7 +209,7 @@ HTML;
function testRetrieveMetaData() { function testRetrieveMetaData() {
$page = new DocumentationPage(); $page = new DocumentationPage();
$page->setRelativePath('MetaDataTest.md'); $page->setRelativePath('MetaDataTest.md');
$page->setEntity(new DocumentationEntity('parser', '2.4', DOCVIEWER_PATH . '/tests/docs-parser/')); $page->setEntity(new DocumentationEntity('parser', '2.4', DOCSVIEWER_PATH . '/tests/docs-parser/'));
DocumentationParser::retrieve_meta_data($page); DocumentationParser::retrieve_meta_data($page);
@ -221,9 +221,9 @@ HTML;
function testParserConvertsSpecialCharacters() { function testParserConvertsSpecialCharacters() {
$page = new DocumentationPage(); $page = new DocumentationPage();
$page->setRelativePath('CodeSnippets.md'); $page->setRelativePath('CodeSnippets.md');
$page->setEntity(new DocumentationEntity('parser', '2.4', DOCVIEWER_PATH . '/tests/docs-parser/')); $page->setEntity(new DocumentationEntity('parser', '2.4', DOCSVIEWER_PATH . '/tests/docs-parser/'));
$parsed = DocumentationParser::parse($page, '/'.DOCVIEWER_DIR .'/tests/docs-parser/'); $parsed = DocumentationParser::parse($page, '/'.DOCSVIEWER_DIR .'/tests/docs-parser/');
// header elements parsed // header elements parsed
$this->assertContains( $this->assertContains(
@ -239,7 +239,7 @@ HTML;
} }
function testRewritingRelativeLinksToFiles() { function testRewritingRelativeLinksToFiles() {
$folder = DOCVIEWER_PATH . '/tests/docs-parser/'; $folder = DOCSVIEWER_PATH . '/tests/docs-parser/';
$page = new DocumentationPage(); $page = new DocumentationPage();
$page->setRelativePath('file-download.md'); $page->setRelativePath('file-download.md');
@ -248,12 +248,12 @@ HTML;
$parsed = DocumentationParser::parse($page, $folder); $parsed = DocumentationParser::parse($page, $folder);
$this->assertContains( $this->assertContains(
DOCVIEWER_DIR .'/tests/docs-parser/en/_images/external_link.png', DOCSVIEWER_DIR .'/tests/docs-parser/en/_images/external_link.png',
$parsed $parsed
); );
$this->assertContains( $this->assertContains(
DOCVIEWER_DIR .'/tests/docs-parser/en/_images/test.tar.gz', DOCSVIEWER_DIR .'/tests/docs-parser/en/_images/test.tar.gz',
$parsed $parsed
); );
} }

View File

@ -1,7 +1,7 @@
<?php <?php
/** /**
* @package docviewer * @package docsviewer
* @subpackage tests * @subpackage tests
*/ */
@ -13,14 +13,14 @@ class DocumentationSearchTest extends FunctionalTest {
if(!DocumentationSearch::enabled()) return; if(!DocumentationSearch::enabled()) return;
DocumentationService::set_automatic_registration(false); DocumentationService::set_automatic_registration(false);
DocumentationService::register('docs-search', DOCVIEWER_PATH . '/tests/docs-search/'); DocumentationService::register('docs-search', DOCSVIEWER_PATH . '/tests/docs-search/');
} }
function testGetAllPages() { function testGetAllPages() {
if(!DocumentationSearch::enabled()) return; if(!DocumentationSearch::enabled()) return;
DocumentationService::set_automatic_registration(false); DocumentationService::set_automatic_registration(false);
DocumentationService::register('docs-search', DOCVIEWER_PATH . '/tests/docs-search/'); DocumentationService::register('docs-search', DOCSVIEWER_PATH . '/tests/docs-search/');
$search = DocumentationSearch::get_all_documentation_pages(); $search = DocumentationSearch::get_all_documentation_pages();

View File

@ -1,14 +1,14 @@
<?php <?php
/** /**
* @package docviewer * @package docsviewer
* @subpackage tests * @subpackage tests
*/ */
class DocumentationServiceTest extends SapphireTest { class DocumentationServiceTest extends SapphireTest {
function testGetPagesFromFolder() { function testGetPagesFromFolder() {
$entity = DocumentationService::register('testdocs', DOCVIEWER_PATH . '/tests/docs/'); $entity = DocumentationService::register('testdocs', DOCSVIEWER_PATH . '/tests/docs/');
$pages = DocumentationService::get_pages_from_folder($entity); $pages = DocumentationService::get_pages_from_folder($entity);
$this->assertContains('index.md', $pages->column('Filename'), 'The tests/docs/en folder should contain a index file'); $this->assertContains('index.md', $pages->column('Filename'), 'The tests/docs/en folder should contain a index file');
@ -28,7 +28,7 @@ class DocumentationServiceTest extends SapphireTest {
function testGetPagesFromFolderRecursive() { function testGetPagesFromFolderRecursive() {
$entity = DocumentationService::register('testdocsrecursive', DOCVIEWER_PATH . '/tests/docs-recursive/'); $entity = DocumentationService::register('testdocsrecursive', DOCSVIEWER_PATH . '/tests/docs-recursive/');
$pages = DocumentationService::get_pages_from_folder($entity, null, true); $pages = DocumentationService::get_pages_from_folder($entity, null, true);
@ -43,19 +43,19 @@ class DocumentationServiceTest extends SapphireTest {
} }
function testFindPath() { function testFindPath() {
DocumentationService::register("DocumentationViewerTests", DOCVIEWER_PATH . "/tests/docs/"); DocumentationService::register("DocumentationViewerTests", DOCSVIEWER_PATH . "/tests/docs/");
// file // file
$path = DocumentationService::find_page('DocumentationViewerTests', array('test')); $path = DocumentationService::find_page('DocumentationViewerTests', array('test'));
$this->assertEquals(DOCVIEWER_PATH . "/tests/docs/en/test.md", $path); $this->assertEquals(DOCSVIEWER_PATH . "/tests/docs/en/test.md", $path);
// the home page. The path finder should go to the index.md file in the default language // the home page. The path finder should go to the index.md file in the default language
$path = DocumentationService::find_page('DocumentationViewerTests', array('')); $path = DocumentationService::find_page('DocumentationViewerTests', array(''));
$this->assertEquals(DOCVIEWER_PATH . "/tests/docs/en/index.md", $path); $this->assertEquals(DOCSVIEWER_PATH . "/tests/docs/en/index.md", $path);
// second level // second level
$path = DocumentationService::find_page('DocumentationViewerTests', array('subfolder', 'subpage')); $path = DocumentationService::find_page('DocumentationViewerTests', array('subfolder', 'subpage'));
$this->assertEquals(DOCVIEWER_PATH . "/tests/docs/en/subfolder/subpage.md", $path); $this->assertEquals(DOCSVIEWER_PATH . "/tests/docs/en/subfolder/subpage.md", $path);
// subsubfolder has no index file. It should fail instead the viewer should pick up on this // subsubfolder has no index file. It should fail instead the viewer should pick up on this
// and display the listing of the folder // and display the listing of the folder
@ -64,11 +64,11 @@ class DocumentationServiceTest extends SapphireTest {
// third level // third level
$path = DocumentationService::find_page('DocumentationViewerTests', array('subfolder', 'subsubfolder', 'subsubpage')); $path = DocumentationService::find_page('DocumentationViewerTests', array('subfolder', 'subsubfolder', 'subsubpage'));
$this->assertEquals(DOCVIEWER_PATH . "/tests/docs/en/subfolder/subsubfolder/subsubpage.md", $path); $this->assertEquals(DOCSVIEWER_PATH . "/tests/docs/en/subfolder/subsubfolder/subsubpage.md", $path);
// with trailing slash // with trailing slash
$path = DocumentationService::find_page('DocumentationViewerTests', array('subfolder', 'subsubfolder', 'subsubpage')); $path = DocumentationService::find_page('DocumentationViewerTests', array('subfolder', 'subsubfolder', 'subsubpage'));
$this->assertEquals(DOCVIEWER_PATH . "/tests/docs/en/subfolder/subsubfolder/subsubpage.md", $path); $this->assertEquals(DOCSVIEWER_PATH . "/tests/docs/en/subfolder/subsubfolder/subsubpage.md", $path);
} }

View File

@ -4,7 +4,7 @@
* Some of these tests are simply checking that pages load. They should not assume * Some of these tests are simply checking that pages load. They should not assume
* somethings working. * somethings working.
* *
* @package docviewer * @package docsviewer
* @subpackage tests * @subpackage tests
*/ */
@ -25,12 +25,12 @@ class DocumentationViewerTest extends FunctionalTest {
} }
// We set 3.0 as current, and test most assertions against 2.4 - to avoid 'current' rewriting issues // We set 3.0 as current, and test most assertions against 2.4 - to avoid 'current' rewriting issues
DocumentationService::register("DocumentationViewerTests", DOCVIEWER_PATH . "/tests/docs/", '2.3'); DocumentationService::register("DocumentationViewerTests", DOCSVIEWER_PATH . "/tests/docs/", '2.3');
DocumentationService::register("DocumentationViewerTests", DOCVIEWER_PATH . "/tests/docs-v2.4/", '2.4', 'Doc Test', true); DocumentationService::register("DocumentationViewerTests", DOCSVIEWER_PATH . "/tests/docs-v2.4/", '2.4', 'Doc Test', true);
DocumentationService::register("DocumentationViewerTests", DOCVIEWER_PATH . "/tests/docs-v3.0/", '3.0', 'Doc Test'); DocumentationService::register("DocumentationViewerTests", DOCSVIEWER_PATH . "/tests/docs-v3.0/", '3.0', 'Doc Test');
DocumentationService::register("DocumentationViewerAltModule1", DOCVIEWER_PATH . "/tests/docs-parser/", '1.0'); DocumentationService::register("DocumentationViewerAltModule1", DOCSVIEWER_PATH . "/tests/docs-parser/", '1.0');
DocumentationService::register("DocumentationViewerAltModule2", DOCVIEWER_PATH . "/tests/docs-search/", '1.0'); DocumentationService::register("DocumentationViewerAltModule2", DOCSVIEWER_PATH . "/tests/docs-search/", '1.0');
} }
function tearDownOnce() { function tearDownOnce() {