nextcloud/tests/lib/largefilehelpergetfilesize.php

71 lines
1.6 KiB
PHP
Raw Normal View History

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;
/**
* 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.
*/
class LargeFileHelperGetFileSize extends \PHPUnit_Framework_TestCase {
2014-02-09 18:53:58 +04:00
protected $filename;
protected $fileSize;
2014-02-09 18:53:58 +04:00
protected $helper;
public function setUp() {
parent::setUp();
2014-09-22 21:38:46 +04:00
$ds = DIRECTORY_SEPARATOR;
$this->filename = dirname(__DIR__) . "{$ds}data{$ds}data.tar.gz";
$this->fileSize = 4195;
2014-02-09 18:53:58 +04:00
$this->helper = new \OC\LargeFileHelper;
}
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(
$this->fileSize,
$this->helper->getFileSizeViaCurl($this->filename)
2014-02-09 18:53:58 +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(
$this->fileSize,
$this->helper->getFileSizeViaCOM($this->filename)
2014-02-09 18:53:58 +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(
$this->fileSize,
$this->helper->getFileSizeViaExec($this->filename)
2014-02-09 18:53:58 +04:00
);
}
public function testGetFileSizeNative() {
$this->assertSame(
$this->fileSize,
$this->helper->getFileSizeNative($this->filename)
);
}
2014-02-09 18:53:58 +04:00
}