Test LargeFileHelperGetFileSize also with ascii only characters
And skip the UTF8 names on Windows as they are not supported
This commit is contained in:
parent
216ef617db
commit
f2282e4251
|
@ -13,58 +13,77 @@ namespace Test;
|
||||||
* Large files are not considered yet.
|
* Large files are not considered yet.
|
||||||
*/
|
*/
|
||||||
class LargeFileHelperGetFileSize extends \PHPUnit_Framework_TestCase {
|
class LargeFileHelperGetFileSize extends \PHPUnit_Framework_TestCase {
|
||||||
protected $filename;
|
/** @var \OC\LargeFileHelper */
|
||||||
protected $fileSize;
|
|
||||||
protected $helper;
|
protected $helper;
|
||||||
|
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
$ds = DIRECTORY_SEPARATOR;
|
$this->helper = new \OC\LargeFileHelper();
|
||||||
$this->filename = dirname(__DIR__) . "{$ds}data{$ds}strängé filename (duplicate #2).txt";
|
|
||||||
$this->fileSize = 446;
|
|
||||||
$this->helper = new \OC\LargeFileHelper;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetFileSizeViaCurl() {
|
public function dataFileNameProvider() {
|
||||||
|
$path = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR;
|
||||||
|
|
||||||
|
$filePaths = array(array($path . 'lorem.txt', 446));
|
||||||
|
if (!\OC_Util::runningOnWindows()) {
|
||||||
|
$filePaths[] = array($path . 'strängé filename (duplicate #2).txt', 446);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $filePaths;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider dataFileNameProvider
|
||||||
|
*/
|
||||||
|
public function testGetFileSizeViaCurl($filename, $fileSize) {
|
||||||
if (!extension_loaded('curl')) {
|
if (!extension_loaded('curl')) {
|
||||||
$this->markTestSkipped(
|
$this->markTestSkipped(
|
||||||
'The PHP curl extension is required for this test.'
|
'The PHP curl extension is required for this test.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
$this->fileSize,
|
$fileSize,
|
||||||
$this->helper->getFileSizeViaCurl($this->filename)
|
$this->helper->getFileSizeViaCurl($filename)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetFileSizeViaCOM() {
|
/**
|
||||||
|
* @dataProvider dataFileNameProvider
|
||||||
|
*/
|
||||||
|
public function testGetFileSizeViaCOM($filename, $fileSize) {
|
||||||
if (!extension_loaded('COM')) {
|
if (!extension_loaded('COM')) {
|
||||||
$this->markTestSkipped(
|
$this->markTestSkipped(
|
||||||
'The PHP Windows COM extension is required for this test.'
|
'The PHP Windows COM extension is required for this test.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
$this->fileSize,
|
$fileSize,
|
||||||
$this->helper->getFileSizeViaCOM($this->filename)
|
$this->helper->getFileSizeViaCOM($filename)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetFileSizeViaExec() {
|
/**
|
||||||
|
* @dataProvider dataFileNameProvider
|
||||||
|
*/
|
||||||
|
public function testGetFileSizeViaExec($filename, $fileSize) {
|
||||||
if (!\OC_Helper::is_function_enabled('exec')) {
|
if (!\OC_Helper::is_function_enabled('exec')) {
|
||||||
$this->markTestSkipped(
|
$this->markTestSkipped(
|
||||||
'The exec() function needs to be enabled for this test.'
|
'The exec() function needs to be enabled for this test.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
$this->fileSize,
|
$fileSize,
|
||||||
$this->helper->getFileSizeViaExec($this->filename)
|
$this->helper->getFileSizeViaExec($filename)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetFileSizeNative() {
|
/**
|
||||||
|
* @dataProvider dataFileNameProvider
|
||||||
|
*/
|
||||||
|
public function testGetFileSizeNative($filename, $fileSize) {
|
||||||
$this->assertSame(
|
$this->assertSame(
|
||||||
$this->fileSize,
|
$fileSize,
|
||||||
$this->helper->getFileSizeNative($this->filename)
|
$this->helper->getFileSizeNative($filename)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue