silverstripe-docsviewer/tests/DocumentationHelperTests.php

76 lines
1.8 KiB
PHP
Raw Normal View History

<?php
/**
* @package docsviewer
* @subpackage tests
*/
2015-11-21 07:25:41 +01:00
class DocumentationHelperTests extends SapphireTest
{
public function testCleanName()
{
$this->assertEquals("File path", DocumentationHelper::clean_page_name(
'00_file-path.md'
));
}
2015-11-21 07:25:41 +01:00
public function testCleanUrl()
{
$this->assertEquals("some_path", DocumentationHelper::clean_page_url(
'Some Path'
));
2015-11-21 07:25:41 +01:00
$this->assertEquals("somefilepath", DocumentationHelper::clean_page_url(
'00_SomeFilePath.md'
));
}
2015-11-21 07:25:41 +01:00
public function testTrimSortNumber()
{
$this->assertEquals('file', DocumentationHelper::trim_sort_number(
'0_file'
));
2015-11-21 07:25:41 +01:00
$this->assertEquals('2.1', DocumentationHelper::trim_sort_number(
'2.1'
));
2015-11-21 07:25:41 +01:00
$this->assertEquals('dev/tasks/2.1', DocumentationHelper::trim_sort_number(
'dev/tasks/2.1'
));
}
2015-11-21 07:25:41 +01:00
public function testTrimExtension()
{
$this->assertEquals('file', DocumentationHelper::trim_extension_off(
'file.md'
));
2015-11-21 07:25:41 +01:00
$this->assertEquals('dev/path/file', DocumentationHelper::trim_extension_off(
'dev/path/file.md'
));
}
2015-11-21 07:25:41 +01:00
public function testGetExtension()
{
$this->assertEquals('md', DocumentationHelper::get_extension(
'file.md'
));
2015-11-21 07:25:41 +01:00
$this->assertEquals('md', DocumentationHelper::get_extension(
'dev/tasks/file.md'
));
2015-11-21 07:25:41 +01:00
$this->assertEquals('txt', DocumentationHelper::get_extension(
'dev/tasks/file.txt'
));
2015-11-21 07:25:41 +01:00
$this->assertNull(DocumentationHelper::get_extension(
'doc_test/2.3'
));
2015-11-21 07:25:41 +01:00
$this->assertNull(DocumentationHelper::get_extension(
'dev/docs/en/doc_test/2.3/subfolder'
));
}
}