summaryrefslogtreecommitdiffstats
path: root/tests/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2014-05-30 16:13:48 +0200
committerThomas Müller <thomas.mueller@tmit.eu>2014-05-30 16:13:48 +0200
commit31ad1cbdd8884844fb58cd6140fb2a0387ebe5e2 (patch)
tree3981e3c1b7fc001c38971856bbc050b5c041167d /tests/lib
parent2ba5701b1af3ba37061fa0e5fa85aac7abaabea4 (diff)
parent129d8099b948c0b5c7456af42cf9a618f5f6920d (diff)
downloadnextcloud-server-31ad1cbdd8884844fb58cd6140fb2a0387ebe5e2.tar.gz
nextcloud-server-31ad1cbdd8884844fb58cd6140fb2a0387ebe5e2.zip
Merge pull request #5365 from owncloud/filesize-improvements-32bit
Add LargeFileHelper / Add CURL filesize workaround / Fix some 32-bit filesize issues
Diffstat (limited to 'tests/lib')
-rw-r--r--tests/lib/largefilehelper.php46
-rw-r--r--tests/lib/largefilehelpergetfilesize.php69
2 files changed, 115 insertions, 0 deletions
diff --git a/tests/lib/largefilehelper.php b/tests/lib/largefilehelper.php
new file mode 100644
index 00000000000..5db1f9c5a74
--- /dev/null
+++ b/tests/lib/largefilehelper.php
@@ -0,0 +1,46 @@
+<?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;
+
+class LargeFileHelper extends \PHPUnit_Framework_TestCase {
+ protected $helper;
+
+ public function setUp() {
+ parent::setUp();
+ $this->helper = new \OC\LargeFileHelper;
+ }
+
+ public function testFormatUnsignedIntegerFloat() {
+ $this->assertSame(
+ '9007199254740992',
+ $this->helper->formatUnsignedInteger((float) 9007199254740992)
+ );
+ }
+
+ public function testFormatUnsignedIntegerInt() {
+ $this->assertSame(
+ PHP_INT_SIZE === 4 ? '4294967295' : '18446744073709551615',
+ $this->helper->formatUnsignedInteger(-1)
+ );
+ }
+
+ public function testFormatUnsignedIntegerString() {
+ $this->assertSame(
+ '9007199254740993',
+ $this->helper->formatUnsignedInteger('9007199254740993')
+ );
+ }
+
+ /**
+ * @expectedException \UnexpectedValueException
+ */
+ public function testFormatUnsignedIntegerStringException() {
+ $this->helper->formatUnsignedInteger('900ABCD254740993');
+ }
+}
diff --git a/tests/lib/largefilehelpergetfilesize.php b/tests/lib/largefilehelpergetfilesize.php
new file mode 100644
index 00000000000..86ce6d295cf
--- /dev/null
+++ b/tests/lib/largefilehelpergetfilesize.php
@@ -0,0 +1,69 @@
+<?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.
+* Large files are not considered yet.
+*/
+class LargeFileHelperGetFileSize extends \PHPUnit_Framework_TestCase {
+ protected $filename;
+ protected $fileSize;
+ protected $helper;
+
+ public function setUp() {
+ parent::setUp();
+ $this->filename = __DIR__ . '/../data/data.tar.gz';
+ $this->fileSize = 4195;
+ $this->helper = new \OC\LargeFileHelper;
+ }
+
+ public function testGetFileSizeViaCurl() {
+ if (!extension_loaded('curl')) {
+ $this->markTestSkipped(
+ 'The PHP curl extension is required for this test.'
+ );
+ }
+ $this->assertSame(
+ $this->fileSize,
+ $this->helper->getFileSizeViaCurl($this->filename)
+ );
+ }
+
+ public function testGetFileSizeViaCOM() {
+ 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)
+ );
+ }
+
+ public function testGetFileSizeViaExec() {
+ 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)
+ );
+ }
+
+ public function testGetFileSizeNative() {
+ $this->assertSame(
+ $this->fileSize,
+ $this->helper->getFileSizeNative($this->filename)
+ );
+ }
+}