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-15 11:47:45 +02:00
|
|
|
protected $entity;
|
|
|
|
|
|
|
|
public function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->entity = new DocumentationEntity('doctest');
|
|
|
|
$this->entity->setPath(DOCSVIEWER_PATH . '/tests/docs/en/');
|
|
|
|
$this->entity->setVersion('2.4');
|
|
|
|
$this->entity->setLanguage('en');
|
|
|
|
|
|
|
|
Config::nest();
|
|
|
|
|
|
|
|
// explicitly use dev/docs. Custom paths should be tested separately
|
|
|
|
Config::inst()->update(
|
|
|
|
'DocumentationViewer', 'link_base', 'dev/docs/'
|
|
|
|
);
|
|
|
|
|
|
|
|
$manifest = new DocumentationManifest(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function tearDown() {
|
|
|
|
parent::tearDown();
|
|
|
|
|
|
|
|
Config::unnest();
|
|
|
|
}
|
|
|
|
|
2014-09-07 01:26:12 +02:00
|
|
|
public function testGetLink() {
|
2014-09-15 11:47:45 +02:00
|
|
|
$page = new DocumentationPage(
|
|
|
|
$this->entity,
|
|
|
|
'test.md',
|
|
|
|
DOCSVIEWER_PATH . '/tests/docs/en/test.md'
|
|
|
|
);
|
2010-12-22 09:21:49 +01:00
|
|
|
|
|
|
|
// single layer
|
2014-09-15 11:47:45 +02:00
|
|
|
$this->assertEquals('dev/docs/en/doctest/2.4/test/', $page->Link(),
|
|
|
|
'The page link should have no extension and have a language'
|
|
|
|
);
|
|
|
|
|
|
|
|
$page = new DocumentationFolder(
|
|
|
|
$this->entity,
|
|
|
|
'sort',
|
|
|
|
DOCSVIEWER_PATH . '/tests/docs/en/sort/'
|
|
|
|
);
|
2010-10-21 22:27:23 +02:00
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
$this->assertEquals('dev/docs/en/doctest/2.4/sort/', $page->Link());
|
2010-08-01 06:46:32 +02:00
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
$page = new DocumentationFolder(
|
|
|
|
$this->entity,
|
|
|
|
'1-basic.md',
|
|
|
|
DOCSVIEWER_PATH . '/tests/docs/en/sort/1-basic.md'
|
|
|
|
);
|
2010-10-21 22:27:23 +02:00
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
$this->assertEquals('dev/docs/en/doctest/2.4/sort/basic/', $page->Link());
|
2010-08-01 06:46:32 +02:00
|
|
|
}
|
|
|
|
|
2014-09-07 01:26:12 +02:00
|
|
|
public function testGetBreadcrumbTitle() {
|
2014-09-15 11:47:45 +02:00
|
|
|
$page = new DocumentationPage(
|
|
|
|
$this->entity,
|
|
|
|
'test.md',
|
|
|
|
DOCSVIEWER_PATH . '/tests/docs/en/test.md'
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertEquals("Test - Doctest", $page->getBreadcrumbTitle());
|
2011-07-01 03:19:35 +02:00
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
$page = new DocumentationFolder(
|
|
|
|
$this->entity,
|
|
|
|
'1-basic.md',
|
|
|
|
DOCSVIEWER_PATH . '/tests/docs/en/sort/1-basic.md'
|
|
|
|
);
|
2011-07-01 03:19:35 +02:00
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
$this->assertEquals('Basic - Sort - Doctest', $page->getBreadcrumbTitle());
|
2014-09-20 03:44:41 +02:00
|
|
|
|
|
|
|
$page = new DocumentationFolder(
|
|
|
|
$this->entity,
|
|
|
|
'',
|
|
|
|
DOCSVIEWER_PATH . '/tests/docs/en/sort/'
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertEquals('Sort - Doctest', $page->getBreadcrumbTitle());
|
|
|
|
|
2011-07-01 03:19:35 +02:00
|
|
|
}
|
2010-08-01 06:46:32 +02:00
|
|
|
}
|