2014-09-06 01:13:12 +02:00
|
|
|
<?php
|
|
|
|
|
2014-09-15 11:47:45 +02:00
|
|
|
/**
|
|
|
|
* @package docsviewer
|
|
|
|
* @subpackage tests
|
|
|
|
*/
|
2015-11-21 07:25:41 +01:00
|
|
|
class DocumentationHelperTests extends SapphireTest
|
|
|
|
{
|
|
|
|
public function testCleanName()
|
|
|
|
{
|
2016-12-02 03:31:18 +01:00
|
|
|
$this->assertEquals(
|
2016-12-04 20:53:53 +01:00
|
|
|
'File path',
|
|
|
|
DocumentationHelper::clean_page_name(
|
2016-12-02 03:31:18 +01:00
|
|
|
'00_file-path.md'
|
|
|
|
)
|
|
|
|
);
|
2015-11-21 07:25:41 +01:00
|
|
|
}
|
2014-09-06 01:13:12 +02:00
|
|
|
|
2015-11-21 07:25:41 +01:00
|
|
|
public function testCleanUrl()
|
|
|
|
{
|
2016-12-02 03:31:18 +01:00
|
|
|
$this->assertEquals(
|
2016-12-04 20:53:53 +01:00
|
|
|
'some_path',
|
|
|
|
DocumentationHelper::clean_page_url(
|
2016-12-02 03:31:18 +01:00
|
|
|
'Some Path'
|
|
|
|
)
|
|
|
|
);
|
2014-09-15 11:47:45 +02:00
|
|
|
|
2016-12-02 03:31:18 +01:00
|
|
|
$this->assertEquals(
|
2016-12-04 20:53:53 +01:00
|
|
|
'somefilepath',
|
|
|
|
DocumentationHelper::clean_page_url(
|
2016-12-02 03:31:18 +01:00
|
|
|
'00_SomeFilePath.md'
|
|
|
|
)
|
|
|
|
);
|
2015-11-21 07:25:41 +01:00
|
|
|
}
|
2014-09-15 11:47:45 +02:00
|
|
|
|
2015-11-21 07:25:41 +01:00
|
|
|
public function testTrimSortNumber()
|
|
|
|
{
|
2016-12-02 03:31:18 +01:00
|
|
|
$this->assertEquals(
|
2016-12-04 20:53:53 +01:00
|
|
|
'file',
|
|
|
|
DocumentationHelper::trim_sort_number(
|
2016-12-02 03:31:18 +01:00
|
|
|
'0_file'
|
|
|
|
)
|
|
|
|
);
|
2014-09-15 11:47:45 +02:00
|
|
|
|
2016-12-02 03:31:18 +01:00
|
|
|
$this->assertEquals(
|
2016-12-04 20:53:53 +01:00
|
|
|
'2.1',
|
|
|
|
DocumentationHelper::trim_sort_number(
|
2016-12-02 03:31:18 +01:00
|
|
|
'2.1'
|
|
|
|
)
|
|
|
|
);
|
2014-09-15 11:47:45 +02:00
|
|
|
|
2016-12-02 03:31:18 +01:00
|
|
|
$this->assertEquals(
|
2016-12-04 20:53:53 +01:00
|
|
|
'dev/tasks/2.1',
|
|
|
|
DocumentationHelper::trim_sort_number(
|
2016-12-02 03:31:18 +01:00
|
|
|
'dev/tasks/2.1'
|
|
|
|
)
|
|
|
|
);
|
2015-11-21 07:25:41 +01:00
|
|
|
}
|
2014-09-15 11:47:45 +02:00
|
|
|
|
2015-11-21 07:25:41 +01:00
|
|
|
public function testTrimExtension()
|
|
|
|
{
|
2016-12-02 03:31:18 +01:00
|
|
|
$this->assertEquals(
|
2016-12-04 20:53:53 +01:00
|
|
|
'file',
|
|
|
|
DocumentationHelper::trim_extension_off(
|
2016-12-02 03:31:18 +01:00
|
|
|
'file.md'
|
|
|
|
)
|
|
|
|
);
|
2014-09-15 11:47:45 +02:00
|
|
|
|
2016-12-02 03:31:18 +01:00
|
|
|
$this->assertEquals(
|
2016-12-04 20:53:53 +01:00
|
|
|
'dev/path/file',
|
|
|
|
DocumentationHelper::trim_extension_off(
|
2016-12-02 03:31:18 +01:00
|
|
|
'dev/path/file.md'
|
|
|
|
)
|
|
|
|
);
|
2015-11-21 07:25:41 +01:00
|
|
|
}
|
2014-09-15 11:47:45 +02:00
|
|
|
|
2015-11-21 07:25:41 +01:00
|
|
|
public function testGetExtension()
|
|
|
|
{
|
2016-12-02 03:31:18 +01:00
|
|
|
$this->assertEquals(
|
2016-12-04 20:53:53 +01:00
|
|
|
'md',
|
|
|
|
DocumentationHelper::get_extension(
|
2016-12-02 03:31:18 +01:00
|
|
|
'file.md'
|
|
|
|
)
|
|
|
|
);
|
2014-09-15 11:47:45 +02:00
|
|
|
|
2016-12-02 03:31:18 +01:00
|
|
|
$this->assertEquals(
|
2016-12-04 20:53:53 +01:00
|
|
|
'md',
|
|
|
|
DocumentationHelper::get_extension(
|
2016-12-02 03:31:18 +01:00
|
|
|
'dev/tasks/file.md'
|
|
|
|
)
|
|
|
|
);
|
2014-09-15 11:47:45 +02:00
|
|
|
|
2016-12-02 03:31:18 +01:00
|
|
|
$this->assertEquals(
|
2016-12-04 20:53:53 +01:00
|
|
|
'txt',
|
|
|
|
DocumentationHelper::get_extension(
|
2016-12-02 03:31:18 +01:00
|
|
|
'dev/tasks/file.txt'
|
|
|
|
)
|
|
|
|
);
|
2014-09-15 11:47:45 +02:00
|
|
|
|
2016-12-02 03:31:18 +01:00
|
|
|
$this->assertNull(
|
|
|
|
DocumentationHelper::get_extension(
|
|
|
|
'doc_test/2.3'
|
|
|
|
)
|
|
|
|
);
|
2014-09-15 11:47:45 +02:00
|
|
|
|
2016-12-02 03:31:18 +01:00
|
|
|
$this->assertNull(
|
|
|
|
DocumentationHelper::get_extension(
|
|
|
|
'dev/docs/en/doc_test/2.3/subfolder'
|
|
|
|
)
|
|
|
|
);
|
2015-11-21 07:25:41 +01:00
|
|
|
}
|
2014-12-10 04:18:26 +01:00
|
|
|
}
|