Browse files

Adding additional tests for special characters in FileNameFilterTest

  • Loading branch information...
1 parent 1ce279e commit cd29b8c74cce9835e69a9137de8c985d2de88644 @halkyon halkyon committed Nov 2, 2012
Showing with 42 additions and 0 deletions.
  1. +42 −0 tests/filesystem/FileNameFilterTest.php
View
42 tests/filesystem/FileNameFilterTest.php
@@ -66,4 +66,46 @@ function testDoubleUnderscoresStartOfNameRemoved() {
$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));
+ }
+
}

0 comments on commit cd29b8c

Please sign in to comment.