2014-09-07 01:26:12 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
2014-09-07 07:09:28 +02:00
|
|
|
* @package docsviewer
|
|
|
|
* @subpackage tests
|
2014-09-07 01:26:12 +02:00
|
|
|
*/
|
|
|
|
class DocumentationManifestTests extends SapphireTest {
|
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
private $manifest;
|
2014-09-07 01:26:12 +02:00
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
public function setUp() {
|
|
|
|
parent::setUp();
|
2014-09-07 01:26:12 +02:00
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
Config::nest();
|
2014-09-07 01:26:12 +02:00
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
// explicitly use dev/docs. Custom paths should be tested separately
|
|
|
|
Config::inst()->update(
|
|
|
|
'DocumentationViewer', 'link_base', 'dev/docs'
|
|
|
|
);
|
|
|
|
|
|
|
|
// disable automatic module registration so modules don't interfere.
|
|
|
|
Config::inst()->update(
|
|
|
|
'DocumentationManifest', 'automatic_registration', false
|
|
|
|
);
|
2014-09-07 01:26:12 +02:00
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
Config::inst()->remove('DocumentationManifest', 'register_entities');
|
|
|
|
|
|
|
|
Config::inst()->update(
|
|
|
|
'DocumentationManifest', 'register_entities', array(
|
|
|
|
array(
|
|
|
|
'Path' => DOCSVIEWER_PATH . "/tests/docs/",
|
|
|
|
'Title' => 'Doc Test',
|
|
|
|
'Key' => 'testdocs',
|
|
|
|
'Version' => '2.3'
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'Path' => DOCSVIEWER_PATH . "/tests/docs-v2.4/",
|
|
|
|
'Title' => 'Doc Test',
|
|
|
|
'Version' => '2.4',
|
|
|
|
'Key' => 'testdocs',
|
|
|
|
'Stable' => true
|
|
|
|
),
|
|
|
|
array(
|
|
|
|
'Path' => DOCSVIEWER_PATH . "/tests/docs-v3.0/",
|
|
|
|
'Title' => 'Doc Test',
|
|
|
|
'Key' => 'testdocs',
|
|
|
|
'Version' => '3.0'
|
2014-09-21 01:18:36 +02:00
|
|
|
),
|
|
|
|
array(
|
|
|
|
'Path' => DOCSVIEWER_PATH . "/tests/docs-manifest/",
|
|
|
|
'Title' => 'Manifest',
|
|
|
|
'Key' => 'manifest'
|
2014-09-15 11:47:45 +02:00
|
|
|
)
|
|
|
|
)
|
|
|
|
);
|
2014-09-07 01:26:12 +02:00
|
|
|
|
|
|
|
$this->manifest = new DocumentationManifest(true);
|
|
|
|
}
|
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
public function tearDown() {
|
|
|
|
parent::tearDown();
|
2014-09-07 01:26:12 +02:00
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
Config::unnest();
|
2014-09-07 01:26:12 +02:00
|
|
|
}
|
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
|
2014-09-07 01:26:12 +02:00
|
|
|
/**
|
|
|
|
* Check that the manifest matches what we'd expect.
|
|
|
|
*/
|
|
|
|
public function testRegenerate() {
|
|
|
|
$match = array(
|
2014-09-15 11:47:45 +02:00
|
|
|
'de/testdocs/2.3/',
|
|
|
|
'de/testdocs/2.3/german/',
|
|
|
|
'de/testdocs/2.3/test/',
|
|
|
|
'en/testdocs/2.3/',
|
|
|
|
'en/testdocs/2.3/sort/',
|
|
|
|
'en/testdocs/2.3/sort/basic/',
|
|
|
|
'en/testdocs/2.3/sort/intermediate/',
|
|
|
|
'en/testdocs/2.3/sort/advanced/',
|
2014-09-21 01:18:36 +02:00
|
|
|
'en/testdocs/2.3/sort/some-page/',
|
|
|
|
'en/testdocs/2.3/sort/another-page/',
|
|
|
|
'en/testdocs/2.3/subfolder/',
|
2014-09-15 11:47:45 +02:00
|
|
|
'en/testdocs/2.3/subfolder/subpage/',
|
|
|
|
'en/testdocs/2.3/subfolder/subsubfolder/',
|
|
|
|
'en/testdocs/2.3/subfolder/subsubfolder/subsubpage/',
|
2014-09-21 01:18:36 +02:00
|
|
|
'en/testdocs/2.3/test/',
|
2014-09-15 11:47:45 +02:00
|
|
|
'en/testdocs/',
|
|
|
|
'en/testdocs/test/',
|
|
|
|
'en/testdocs/3.0/',
|
|
|
|
'en/testdocs/3.0/changelog/',
|
|
|
|
'en/testdocs/3.0/tutorials/',
|
2014-09-21 01:18:36 +02:00
|
|
|
'en/testdocs/3.0/empty/',
|
|
|
|
'en/manifest/',
|
|
|
|
'en/manifest/guide/',
|
|
|
|
'en/manifest/guide/test/',
|
|
|
|
'en/manifest/second-guide/',
|
|
|
|
'en/manifest/second-guide/afile/'
|
2014-09-07 01:26:12 +02:00
|
|
|
);
|
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
$this->assertEquals($match, array_keys($this->manifest->getPages()));
|
2014-09-07 01:26:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetNextPage() {
|
2014-09-21 01:18:36 +02:00
|
|
|
// get next page at the end of one subfolder goes back up to the top
|
|
|
|
// most directory
|
|
|
|
$this->assertStringEndsWith('2.3/test/', $this->manifest->getNextPage(
|
|
|
|
DOCSVIEWER_PATH . '/tests/docs/en/subfolder/subsubfolder/subsubpage.md',
|
|
|
|
DOCSVIEWER_PATH . '/tests/docs/en/'
|
|
|
|
)->Link);
|
|
|
|
|
|
|
|
// after sorting, 2 is shown.
|
|
|
|
$this->assertContains('/intermediate/', $this->manifest->getNextPage(
|
|
|
|
DOCSVIEWER_PATH . '/tests/docs/en/sort/01-basic.md',
|
|
|
|
DOCSVIEWER_PATH . '/tests/docs/en/'
|
|
|
|
)->Link);
|
|
|
|
|
|
|
|
|
|
|
|
// next gets the following URL
|
|
|
|
$this->assertContains('/test/', $this->manifest->getNextPage(
|
|
|
|
DOCSVIEWER_PATH . '/tests/docs-v2.4/en/index.md',
|
|
|
|
DOCSVIEWER_PATH . '/tests/docs-v2.4/en/'
|
|
|
|
)->Link);
|
|
|
|
|
|
|
|
|
|
|
|
// last folder in a entity does not leak
|
|
|
|
$this->assertNull($this->manifest->getNextPage(
|
|
|
|
DOCSVIEWER_PATH . '/tests/docs/en/test.md',
|
|
|
|
DOCSVIEWER_PATH . '/tests/docs/en/'
|
|
|
|
));
|
2014-09-07 01:26:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPreviousPage() {
|
2014-09-21 01:18:36 +02:00
|
|
|
// goes right into subfolders
|
|
|
|
$this->assertContains('subfolder/subsubfolder/subsubpage', $this->manifest->getPreviousPage(
|
|
|
|
DOCSVIEWER_PATH . '/tests/docs/en/test.md',
|
|
|
|
DOCSVIEWER_PATH . '/tests/docs/en/'
|
|
|
|
)->Link);
|
|
|
|
|
|
|
|
// does not leak between entities
|
|
|
|
$this->assertNull($this->manifest->getPreviousPage(
|
|
|
|
DOCSVIEWER_PATH . '/tests/docs/en/index.md',
|
|
|
|
DOCSVIEWER_PATH . '/tests/docs/en/'
|
|
|
|
));
|
|
|
|
|
|
|
|
// does not leak between entities
|
|
|
|
$this->assertNull($this->manifest->getPreviousPage(
|
|
|
|
DOCSVIEWER_PATH . ' /tests/docs/en/index.md',
|
|
|
|
DOCSVIEWER_PATH . '/tests/docs/en/'
|
|
|
|
));
|
2014-09-07 01:26:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetPage() {
|
2014-09-20 03:44:26 +02:00
|
|
|
$this->markTestIncomplete();
|
2014-09-07 01:26:12 +02:00
|
|
|
}
|
2014-09-15 11:47:45 +02:00
|
|
|
|
|
|
|
public function testGenerateBreadcrumbs() {
|
2014-09-20 03:44:26 +02:00
|
|
|
$this->markTestIncomplete();
|
2014-09-15 11:47:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetChildrenFor() {
|
2014-09-20 03:44:26 +02:00
|
|
|
$expected = array(
|
|
|
|
array('Title' => 'Test', 'LinkingMode' => 'link')
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertDOSContains($expected, $this->manifest->getChildrenFor(
|
|
|
|
DOCSVIEWER_PATH . "/tests/docs/en/"
|
|
|
|
));
|
|
|
|
|
|
|
|
$expected = array(
|
|
|
|
array('Title' => 'ChangeLog', 'LinkingMode' => 'current'),
|
|
|
|
array('Title' => 'Tutorials'),
|
|
|
|
array('Title' => 'Empty')
|
|
|
|
);
|
2014-09-15 11:47:45 +02:00
|
|
|
|
2014-09-20 03:44:26 +02:00
|
|
|
$this->assertDOSContains($expected, $this->manifest->getChildrenFor(
|
|
|
|
DOCSVIEWER_PATH . '/tests/docs-v3.0/en/',
|
|
|
|
DOCSVIEWER_PATH . '/tests/docs-v3.0/en/ChangeLog.md'
|
|
|
|
));
|
2014-09-15 11:47:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetAllVersions() {
|
2014-09-20 03:44:26 +02:00
|
|
|
$expected = array(
|
|
|
|
'2.3' => '2.3',
|
|
|
|
'2.4' => '2.4',
|
2014-09-21 01:18:36 +02:00
|
|
|
'3.0' => '3.0',
|
|
|
|
'0.0' => 'Master'
|
|
|
|
);
|
2014-09-15 11:47:45 +02:00
|
|
|
|
2014-09-20 03:44:26 +02:00
|
|
|
$this->assertEquals($expected, $this->manifest->getAllVersions());
|
2014-09-15 11:47:45 +02:00
|
|
|
}
|
|
|
|
|
2014-09-19 13:29:22 +02:00
|
|
|
public function testGetAllEntityVersions() {
|
2014-09-20 03:44:26 +02:00
|
|
|
$expected = array(
|
|
|
|
'Version' => '2.3',
|
|
|
|
'Version' => '2.4',
|
|
|
|
'Version' => '3.0'
|
|
|
|
);
|
|
|
|
|
|
|
|
$entity = $this->manifest->getEntities()->find('Language', 'en');
|
|
|
|
|
|
|
|
$this->assertEquals(3, $this->manifest->getAllVersionsOfEntity($entity)->count());
|
|
|
|
|
|
|
|
$entity = $this->manifest->getEntities()->find('Language', 'de');
|
2014-09-19 13:29:22 +02:00
|
|
|
|
2014-09-20 03:44:26 +02:00
|
|
|
$this->assertEquals(1, $this->manifest->getAllVersionsOfEntity($entity)->count());
|
2014-09-19 13:29:22 +02:00
|
|
|
}
|
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
public function testGetStableVersion() {
|
2014-09-20 03:44:26 +02:00
|
|
|
$this->markTestIncomplete();
|
2014-09-15 11:47:45 +02:00
|
|
|
}
|
|
|
|
}
|