mirror of
https://github.com/filegator/filegator.git
synced 2025-08-12 16:23:58 +02:00
slow feature tests replaced with unit tests
This commit is contained in:
@@ -317,82 +317,4 @@ class UploadTest extends TestCase
|
|||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testFileUploadWithUTF8()
|
|
||||||
{
|
|
||||||
$this->signIn('john@example.com', 'john123');
|
|
||||||
|
|
||||||
$files = ['file' => new UploadedFile(TEST_FILE, 'ąčęėįšųū.txt', 'text/plain', null, true)];
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
'resumableChunkNumber' => 1,
|
|
||||||
'resumableChunkSize' => 1048576,
|
|
||||||
'resumableCurrentChunkSize' => 0.5 * 1024 * 1024,
|
|
||||||
'resumableTotalChunks' => 1,
|
|
||||||
'resumableTotalSize' => 0.5 * 1024 * 1024,
|
|
||||||
'resumableType' => 'text/plain',
|
|
||||||
'resumableIdentifier' => 'CHUNKS-SIMPLE-TEST',
|
|
||||||
'resumableFilename' => "ąčęėįšųū.txt",
|
|
||||||
'resumableRelativePath' => '/',
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->sendRequest('POST', '/upload', $data, $files);
|
|
||||||
|
|
||||||
$this->assertOk();
|
|
||||||
|
|
||||||
$this->sendRequest('POST', '/getdir', [
|
|
||||||
'dir' => '/',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->assertResponseJsonHas([
|
|
||||||
'data' => [
|
|
||||||
'files' => [
|
|
||||||
0 => [
|
|
||||||
'type' => 'file',
|
|
||||||
'path' => '/ąčęėįšųū.txt',
|
|
||||||
'name' => 'ąčęėįšųū.txt',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testFileUploadWithMultibyteName()
|
|
||||||
{
|
|
||||||
$this->signIn('john@example.com', 'john123');
|
|
||||||
|
|
||||||
$files = ['file' => new UploadedFile(TEST_FILE, '断及服务层流.txt', 'text/plain', null, true)];
|
|
||||||
|
|
||||||
$data = [
|
|
||||||
'resumableChunkNumber' => 1,
|
|
||||||
'resumableChunkSize' => 1048576,
|
|
||||||
'resumableCurrentChunkSize' => 0.5 * 1024 * 1024,
|
|
||||||
'resumableTotalChunks' => 1,
|
|
||||||
'resumableTotalSize' => 0.5 * 1024 * 1024,
|
|
||||||
'resumableType' => 'text/plain',
|
|
||||||
'resumableIdentifier' => 'CHUNKS-SIMPLE-TEST',
|
|
||||||
'resumableFilename' => "断及服务层流.txt",
|
|
||||||
'resumableRelativePath' => '/',
|
|
||||||
];
|
|
||||||
|
|
||||||
$this->sendRequest('POST', '/upload', $data, $files);
|
|
||||||
|
|
||||||
$this->assertOk();
|
|
||||||
|
|
||||||
$this->sendRequest('POST', '/getdir', [
|
|
||||||
'dir' => '/',
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->assertResponseJsonHas([
|
|
||||||
'data' => [
|
|
||||||
'files' => [
|
|
||||||
0 => [
|
|
||||||
'type' => 'file',
|
|
||||||
'path' => '/断及服务层流.txt',
|
|
||||||
'name' => '断及服务层流.txt',
|
|
||||||
],
|
|
||||||
],
|
|
||||||
],
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -146,11 +146,16 @@ class TmpfsTest extends TestCase
|
|||||||
|
|
||||||
public function testSanitizeFilename()
|
public function testSanitizeFilename()
|
||||||
{
|
{
|
||||||
|
// regular
|
||||||
$this->assertEquals('test.txt', $this->invokeMethod($this->service, 'sanitizeFilename', ['test.txt']));
|
$this->assertEquals('test.txt', $this->invokeMethod($this->service, 'sanitizeFilename', ['test.txt']));
|
||||||
$this->assertEquals('断及服务层流.txt', $this->invokeMethod($this->service, 'sanitizeFilename', ['断及服务层流.txt']));
|
|
||||||
|
// utf-8
|
||||||
$this->assertEquals('ąčęėįšųū.txt', $this->invokeMethod($this->service, 'sanitizeFilename', ['ąčęėįšųū.txt']));
|
$this->assertEquals('ąčęėįšųū.txt', $this->invokeMethod($this->service, 'sanitizeFilename', ['ąčęėįšųū.txt']));
|
||||||
|
|
||||||
// remove invalid chars
|
// multi-byte
|
||||||
|
$this->assertEquals('断及服务层流.txt', $this->invokeMethod($this->service, 'sanitizeFilename', ['断及服务层流.txt']));
|
||||||
|
|
||||||
|
// with invalid chars
|
||||||
$this->assertEquals('..--s-u---pe----rm---an-.t-xt..--', $this->invokeMethod($this->service, 'sanitizeFilename', ["../\\s\"u<:>pe////rm?*|an\\.t\txt../;"]));
|
$this->assertEquals('..--s-u---pe----rm---an-.t-xt..--', $this->invokeMethod($this->service, 'sanitizeFilename', ["../\\s\"u<:>pe////rm?*|an\\.t\txt../;"]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user