2014-02-09 14:53:58 +00: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 18:54:05 +00:00
|
|
|
* Tests whether LargeFileHelper is able to determine file size at all.
|
2014-02-09 14:53:58 +00:00
|
|
|
* Large files are not considered yet.
|
|
|
|
*/
|
2014-03-16 18:54:05 +00:00
|
|
|
class LargeFileHelperGetFileSize extends \PHPUnit_Framework_TestCase {
|
2014-02-09 14:53:58 +00:00
|
|
|
protected $filename;
|
2014-03-16 18:54:05 +00:00
|
|
|
protected $fileSize;
|
2014-02-09 14:53:58 +00:00
|
|
|
protected $helper;
|
|
|
|
|
|
|
|
public function setUp() {
|
|
|
|
parent::setUp();
|
|
|
|
$this->filename = __DIR__ . '/../data/data.tar.gz';
|
2014-03-16 18:54:05 +00:00
|
|
|
$this->fileSize = 4195;
|
2014-02-09 14:53:58 +00:00
|
|
|
$this->helper = new \OC\LargeFileHelper;
|
|
|
|
}
|
|
|
|
|
2014-03-16 18:54:05 +00:00
|
|
|
public function testGetFileSizeViaCurl() {
|
2014-02-09 14:53:58 +00:00
|
|
|
if (!extension_loaded('curl')) {
|
|
|
|
$this->markTestSkipped(
|
|
|
|
'The PHP curl extension is required for this test.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$this->assertSame(
|
2014-03-16 18:54:05 +00:00
|
|
|
$this->fileSize,
|
|
|
|
$this->helper->getFileSizeViaCurl($this->filename)
|
2014-02-09 14:53:58 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-03-16 18:54:05 +00:00
|
|
|
public function testGetFileSizeViaCOM() {
|
2014-02-09 14:53:58 +00:00
|
|
|
if (!extension_loaded('COM')) {
|
|
|
|
$this->markTestSkipped(
|
|
|
|
'The PHP Windows COM extension is required for this test.'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
$this->assertSame(
|
2014-03-16 18:54:05 +00:00
|
|
|
$this->fileSize,
|
2014-03-16 20:21:17 +00:00
|
|
|
$this->helper->getFileSizeViaCOM($this->filename)
|
2014-02-09 14:53:58 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2014-03-16 18:54:05 +00:00
|
|
|
public function testGetFileSizeViaExec() {
|
2014-02-09 14:53:58 +00: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 18:54:05 +00:00
|
|
|
$this->fileSize,
|
|
|
|
$this->helper->getFileSizeViaExec($this->filename)
|
2014-02-09 14:53:58 +00:00
|
|
|
);
|
|
|
|
}
|
2014-02-18 11:57:44 +00:00
|
|
|
|
2014-03-16 18:54:05 +00:00
|
|
|
public function testGetFileSizeNative() {
|
2014-02-18 11:57:44 +00:00
|
|
|
$this->assertSame(
|
2014-03-16 18:54:05 +00:00
|
|
|
$this->fileSize,
|
|
|
|
$this->helper->getFileSizeNative($this->filename)
|
2014-02-18 11:57:44 +00:00
|
|
|
);
|
|
|
|
}
|
2014-02-09 14:53:58 +00:00
|
|
|
}
|