2010-08-01 06:46:32 +02:00
|
|
|
<?php
|
2010-12-22 09:21:49 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @package sapphiredocs
|
|
|
|
* @subpackage tests
|
|
|
|
*/
|
|
|
|
|
2010-08-01 06:46:32 +02:00
|
|
|
class DocumentationPageTest extends SapphireTest {
|
|
|
|
|
2010-12-22 09:21:49 +01:00
|
|
|
function testGetLink() {
|
|
|
|
$entity = new DocumentationEntity('testmodule', null, BASE_PATH . '/sapphiredocs/tests/docs/');
|
|
|
|
|
|
|
|
$page = new DocumentationPage();
|
|
|
|
$page->setRelativePath('test.md');
|
|
|
|
$page->setEntity($entity);
|
|
|
|
|
|
|
|
// single layer
|
2011-01-14 02:03:46 +01: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
|
2011-01-14 02:03:46 +01: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);
|
|
|
|
|
2011-01-14 02:03:46 +01:00
|
|
|
$this->assertStringEndsWith('testmodule/en/subfolder/subpage', $nested->Link());
|
2010-12-22 09:21:49 +01:00
|
|
|
|
|
|
|
// test with version.
|
2011-07-01 03:19:35 +02:00
|
|
|
$entity = DocumentationService::register("versionlinks", BASE_PATH . "/sapphiredocs/tests/docs-v2.4/", '1');
|
2011-07-04 02:05:22 +02:00
|
|
|
$entity->addVersion('2', BASE_PATH . "/sapphiredocs/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');
|
2011-01-14 02:03:46 +01:00
|
|
|
$this->assertStringEndsWith('versionlinks/en/1/test', $page->Link());
|
2010-12-22 09:21:49 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-08-01 06:46:32 +02:00
|
|
|
function testGetRelativePath() {
|
2010-10-21 22:27:23 +02:00
|
|
|
$page = new DocumentationPage();
|
|
|
|
$page->setRelativePath('test.md');
|
|
|
|
$page->setEntity(new DocumentationEntity('mymodule', null, BASE_PATH . '/sapphiredocs/tests/docs/'));
|
|
|
|
|
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');
|
|
|
|
$page->setEntity(new DocumentationEntity('mymodule', null, BASE_PATH . '/sapphiredocs/tests/docs/'));
|
|
|
|
|
2010-08-01 06:46:32 +02:00
|
|
|
$this->assertEquals('subfolder/subpage.md', $page->getRelativePath());
|
|
|
|
}
|
|
|
|
|
|
|
|
function testGetPath() {
|
|
|
|
$absPath = BASE_PATH . '/sapphiredocs/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());
|
|
|
|
}
|
|
|
|
|
2011-07-01 03:19:35 +02:00
|
|
|
function testGetBreadcrumbTitle() {
|
|
|
|
$entity = new DocumentationEntity('testmodule', null, BASE_PATH . '/sapphiredocs/tests/docs/');
|
|
|
|
|
|
|
|
$page = new DocumentationPage();
|
|
|
|
$page->setRelativePath('test.md');
|
|
|
|
$page->setEntity($entity);
|
|
|
|
|
|
|
|
$this->assertEquals("Testmodule - Test", $page->getBreadcrumbTitle());
|
|
|
|
|
|
|
|
$page = new DocumentationPage();
|
|
|
|
$page->setRelativePath('subfolder/subpage.md');
|
|
|
|
$page->setEntity(new DocumentationEntity('mymodule', null, BASE_PATH . '/sapphiredocs/tests/docs/'));
|
|
|
|
|
|
|
|
$this->assertEquals('Mymodule - Subfolder - Subpage', $page->getBreadcrumbTitle());
|
|
|
|
}
|
|
|
|
|
2010-08-01 06:46:32 +02:00
|
|
|
}
|