mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Adding additional tests for special characters in FileNameFilterTest
This commit is contained in:
parent
1ce279ec9d
commit
cd29b8c74c
@ -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));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user