Adding additional tests for special characters in FileNameFilterTest

This commit is contained in:
Sean Harvey 2012-11-02 09:34:34 +13:00
parent 1ce279ec9d
commit cd29b8c74c

View File

@ -66,4 +66,46 @@ class FileNameFilterTest extends SapphireTest {
$this->assertEquals('test.txt', $filter->filter($name)); $this->assertEquals('test.txt', $filter->filter($name));
} }
function testDotsStartOfNameRemoved() {
$name = '.test.txt';
$filter = new FileNameFilter();
$this->assertEquals('test.txt', $filter->filter($name));
}
function testDoubleDotsStartOfNameRemoved() {
$name = '..test.txt';
$filter = new FileNameFilter();
$this->assertEquals('test.txt', $filter->filter($name));
}
function testMixedInvalidCharsStartOfNameRemoved() {
$name = '..#@$#@$^__test.txt';
$filter = new FileNameFilter();
$this->assertEquals('test.txt', $filter->filter($name));
}
function testWhitespaceRemoved() {
$name = ' test doc.txt';
$filter = new FileNameFilter();
$this->assertEquals('test-doc.txt', $filter->filter($name));
}
function testUnderscoresReplacedWithDashes() {
$name = 'test_doc.txt';
$filter = new FileNameFilter();
$this->assertEquals('test-doc.txt', $filter->filter($name));
}
function testNonAsciiCharsReplacedWithDashes() {
$name = '!@#$%^test_123@##@$#%^.txt';
$filter = new FileNameFilter();
$this->assertEquals('test-123.txt', $filter->filter($name));
}
function testDuplicateDashesRemoved() {
$name = 'test--document.txt';
$filter = new FileNameFilter();
$this->assertEquals('test-document.txt', $filter->filter($name));
}
} }