From 7d06cf6fae1f1e5e43c0804017a77b977be5eb45 Mon Sep 17 00:00:00 2001 From: Milos Stojanovic Date: Fri, 6 Sep 2019 11:12:45 +0200 Subject: [PATCH] test for sanitizeFilename --- tests/backend/Unit/TmpfsTest.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/backend/Unit/TmpfsTest.php b/tests/backend/Unit/TmpfsTest.php index 6883c42..0d20c63 100644 --- a/tests/backend/Unit/TmpfsTest.php +++ b/tests/backend/Unit/TmpfsTest.php @@ -143,4 +143,14 @@ class TmpfsTest extends TestCase $this->assertFileExists(TEST_TMP_PATH.'old.txt'); } + + public function testSanitizeFilename() + { + $this->assertEquals('test.txt', $this->invokeMethod($this->service, 'sanitizeFilename', ['test.txt'])); + $this->assertEquals('断及服务层流.txt', $this->invokeMethod($this->service, 'sanitizeFilename', ['断及服务层流.txt'])); + $this->assertEquals('ąčęėįšųū.txt', $this->invokeMethod($this->service, 'sanitizeFilename', ['ąčęėįšųū.txt'])); + + // remove invalid chars + $this->assertEquals('..--s-u---pe----rm---an-.t-xt..--', $this->invokeMethod($this->service, 'sanitizeFilename', ["../\\s\"u<:>pe////rm?*|an\\.t\txt../;"])); + } }