2014-02-09 18:53:58 +04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Copyright (c) 2014 Andreas Fischer <bantu@owncloud.com>
|
|
|
|
* This file is licensed under the Affero General Public License version 3 or
|
|
|
|
* later.
|
|
|
|
* See the COPYING-README file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Test;
|
|
|
|
|
|
|
|
/**
|
2014-03-16 22:54:05 +04:00
|
|
|
* Tests whether LargeFileHelper is able to determine file size at all.
|
2014-02-09 18:53:58 +04:00
|
|
|
* Large files are not considered yet.
|
|
|
|
*/
|
2014-03-16 22:54:05 +04:00
|
|
|
class LargeFileHelperGetFileSize extends \PHPUnit_Framework_TestCase {
|
2014-02-09 18:53:58 +04:00
|
|
|
protected $filename;
|
2014-03-16 22:54:05 +04:00
|
|
|
protected $fileSize;
|
2014-02-09 18:53:58 +04:00
|
|
|
protected $helper;
|
|
|
|
|
|
|
|
public function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
$this->filename = __DIR__ . '/../data/data.tar.gz';
|
2014-03-16 22:54:05 +04:00
|
|
|
$this->fileSize = 4195;
|
2014-02-09 18:53:58 +04:00
|
|
|
$this->helper = new \OC\LargeFileHelper;
|
|
|
|
}
|
|
|
|
|
2014-03-16 22:54:05 +04:00
|
|
|
public function testGetFileSizeViaCurl() {
|
2014-02-09 18:53:58 +04:00
|
|
|
if (!extension_loaded('curl')) {
|
|
|
|
$this->markTestSkipped(
|
|
|
|
'The PHP curl extension is required for this test.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$this->assertSame(
|
2014-03-16 22:54:05 +04:00
|
|
|
$this->fileSize,
|
|
|
|
$this->helper->getFileSizeViaCurl($this->filename)
|
2014-02-09 18:53:58 +04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-03-16 22:54:05 +04:00
|
|
|
public function testGetFileSizeViaCOM() {
|
2014-02-09 18:53:58 +04:00
|
|
|
if (!extension_loaded('COM')) {
|
|
|
|
$this->markTestSkipped(
|
|
|
|
'The PHP Windows COM extension is required for this test.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$this->assertSame(
|
2014-03-16 22:54:05 +04:00
|
|
|
$this->fileSize,
|
2014-03-17 00:21:17 +04:00
|
|
|
$this->helper->getFileSizeViaCOM($this->filename)
|
2014-02-09 18:53:58 +04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-03-16 22:54:05 +04:00
|
|
|
public function testGetFileSizeViaExec() {
|
2014-02-09 18:53:58 +04:00
|
|
|
if (!\OC_Helper::is_function_enabled('exec')) {
|
|
|
|
$this->markTestSkipped(
|
|
|
|
'The exec() function needs to be enabled for this test.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$this->assertSame(
|
2014-03-16 22:54:05 +04:00
|
|
|
$this->fileSize,
|
|
|
|
$this->helper->getFileSizeViaExec($this->filename)
|
2014-02-09 18:53:58 +04:00
|
|
|
);
|
|
|
|
}
|
2014-02-18 15:57:44 +04:00
|
|
|
|
2014-03-16 22:54:05 +04:00
|
|
|
public function testGetFileSizeNative() {
|
2014-02-18 15:57:44 +04:00
|
|
|
$this->assertSame(
|
2014-03-16 22:54:05 +04:00
|
|
|
$this->fileSize,
|
|
|
|
$this->helper->getFileSizeNative($this->filename)
|
2014-02-18 15:57:44 +04:00
|
|
|
);
|
|
|
|
}
|
2014-02-09 18:53:58 +04:00
|
|
|
}
|