2010-08-01 06:46:32 +02:00
|
|
|
<?php
|
2010-12-22 09:21:49 +01:00
|
|
|
|
|
|
|
/**
|
2012-04-08 11:36:16 +02:00
|
|
|
* @package docsviewer
|
2010-12-22 09:21:49 +01:00
|
|
|
* @subpackage tests
|
|
|
|
*/
|
2010-08-01 06:46:32 +02:00
|
|
|
class DocumentationPageTest extends SapphireTest {
|
|
|
|
|
2014-09-07 01:26:12 +02:00
|
|
|
public function testGetLink() {
|
2012-04-08 11:36:16 +02:00
|
|
|
$entity = new DocumentationEntity('testmodule', null, DOCSVIEWER_PATH .'/tests/docs/');
|
2010-12-22 09:21:49 +01:00
|
|
|
|
|
|
|
$page = new DocumentationPage();
|
|
|
|
$page->setRelativePath('test.md');
|
|
|
|
$page->setEntity($entity);
|
|
|
|
|
|
|
|
// single layer
|
2012-04-14 07:00:22 +02:00
|
|
|
$this->assertStringEndsWith('testmodule/en/test', $page->Link, 'The page link should have no extension and have a language');
|
2010-12-22 09:21:49 +01:00
|
|
|
|
|
|
|
$folder = new DocumentationPage();
|
|
|
|
$folder->setRelativePath('sort');
|
|
|
|
$folder->setEntity($entity);
|
|
|
|
|
|
|
|
// folder, should have a trailing slash
|
2012-04-14 07:00:22 +02:00
|
|
|
$this->assertStringEndsWith('testmodule/en/sort/', $folder->Link);
|
2010-12-22 09:21:49 +01:00
|
|
|
|
|
|
|
// second
|
|
|
|
$nested = new DocumentationPage();
|
|
|
|
$nested->setRelativePath('subfolder/subpage.md');
|
|
|
|
$nested->setEntity($entity);
|
|
|
|
|
2012-04-14 07:00:22 +02:00
|
|
|
$this->assertStringEndsWith('testmodule/en/subfolder/subpage', $nested->Link);
|
2010-12-22 09:21:49 +01:00
|
|
|
|
|
|
|
// test with version.
|
2012-04-08 11:36:16 +02:00
|
|
|
$entity = DocumentationService::register("versionlinks", DOCSVIEWER_PATH ."/tests/docs-v2.4/", '1');
|
|
|
|
$entity->addVersion('2', DOCSVIEWER_PATH ."/tests/docs-v3.0/");
|
2011-07-08 04:42:52 +02:00
|
|
|
$entity->setStableVersion('2');
|
2011-07-04 02:05:22 +02:00
|
|
|
|
2010-12-22 09:21:49 +01:00
|
|
|
$page = new DocumentationPage();
|
|
|
|
$page->setRelativePath('test.md');
|
|
|
|
$page->setEntity($entity);
|
|
|
|
$page->setVersion('1');
|
2012-04-14 07:00:22 +02:00
|
|
|
$this->assertStringEndsWith('versionlinks/en/1/test', $page->Link);
|
2010-12-22 09:21:49 +01:00
|
|
|
}
|
|
|
|
|
2014-09-07 01:26:12 +02:00
|
|
|
public function testGetRelativePath() {
|
2010-10-21 22:27:23 +02:00
|
|
|
$page = new DocumentationPage();
|
|
|
|
$page->setRelativePath('test.md');
|
2012-04-08 11:36:16 +02:00
|
|
|
$page->setEntity(new DocumentationEntity('mymodule', null, DOCSVIEWER_PATH . '/tests/docs/'));
|
2010-10-21 22:27:23 +02:00
|
|
|
|
2010-08-01 06:46:32 +02:00
|
|
|
$this->assertEquals('test.md', $page->getRelativePath());
|
|
|
|
|
2010-10-21 22:27:23 +02:00
|
|
|
$page = new DocumentationPage();
|
|
|
|
$page->setRelativePath('subfolder/subpage.md');
|
2012-04-08 11:36:16 +02:00
|
|
|
$page->setEntity(new DocumentationEntity('mymodule', null, DOCSVIEWER_PATH . '/tests/docs/'));
|
2010-10-21 22:27:23 +02:00
|
|
|
|
2010-08-01 06:46:32 +02:00
|
|
|
$this->assertEquals('subfolder/subpage.md', $page->getRelativePath());
|
|
|
|
}
|
|
|
|
|
2014-09-07 01:26:12 +02:00
|
|
|
public function testGetPath() {
|
2012-04-08 11:36:16 +02:00
|
|
|
$absPath = DOCSVIEWER_PATH .'/tests/docs/';
|
2010-10-21 22:27:23 +02:00
|
|
|
$page = new DocumentationPage();
|
|
|
|
$page->setRelativePath('test.md');
|
|
|
|
$page->setEntity(new DocumentationEntity('mymodule', null, $absPath));
|
|
|
|
|
2010-08-01 06:46:32 +02:00
|
|
|
$this->assertEquals($absPath . 'en/test.md', $page->getPath());
|
|
|
|
|
2010-10-21 22:27:23 +02:00
|
|
|
$page = new DocumentationPage();
|
|
|
|
$page->setRelativePath('subfolder/subpage.md');
|
|
|
|
$page->setEntity(new DocumentationEntity('mymodule', null, $absPath));
|
|
|
|
|
2010-08-01 06:46:32 +02:00
|
|
|
$this->assertEquals($absPath . 'en/subfolder/subpage.md', $page->getPath());
|
|
|
|
}
|
|
|
|
|
2014-09-07 01:26:12 +02:00
|
|
|
public function testGetBreadcrumbTitle() {
|
2012-04-08 11:36:16 +02:00
|
|
|
$entity = new DocumentationEntity('testmodule', null, DOCSVIEWER_PATH . '/tests/docs/');
|
2011-07-01 03:19:35 +02:00
|
|
|
|
|
|
|
$page = new DocumentationPage();
|
|
|
|
$page->setRelativePath('test.md');
|
|
|
|
$page->setEntity($entity);
|
|
|
|
|
|
|
|
$this->assertEquals("Testmodule - Test", $page->getBreadcrumbTitle());
|
|
|
|
|
|
|
|
$page = new DocumentationPage();
|
|
|
|
$page->setRelativePath('subfolder/subpage.md');
|
2012-04-08 11:36:16 +02:00
|
|
|
$page->setEntity(new DocumentationEntity('mymodule', null, DOCSVIEWER_PATH . '/tests/docs/'));
|
2011-07-01 03:19:35 +02:00
|
|
|
|
|
|
|
$this->assertEquals('Mymodule - Subfolder - Subpage', $page->getBreadcrumbTitle());
|
|
|
|
}
|
|
|
|
|
2010-08-01 06:46:32 +02:00
|
|
|
}
|