diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/appframework/http/DispatcherTest.php | 8 | ||||
-rw-r--r-- | tests/lib/files/node/file.php | 41 | ||||
-rw-r--r-- | tests/lib/files/node/folder.php | 19 | ||||
-rw-r--r-- | tests/lib/files/node/node.php | 52 | ||||
-rw-r--r-- | tests/lib/files/node/root.php | 7 | ||||
-rw-r--r-- | tests/lib/files/objectstore/swift.php | 6 |
6 files changed, 74 insertions, 59 deletions
diff --git a/tests/lib/appframework/http/DispatcherTest.php b/tests/lib/appframework/http/DispatcherTest.php index 45ebd6fce96..3933e00804b 100644 --- a/tests/lib/appframework/http/DispatcherTest.php +++ b/tests/lib/appframework/http/DispatcherTest.php @@ -232,10 +232,6 @@ class DispatcherTest extends \Test\TestCase { public function testExceptionCallsAfterException() { - // TODO fails on PHP 5.3 - if (version_compare(PHP_VERSION, '5.4.0', '<')) { - $this->markTestSkipped('Fails on PHP 5.3'); - } $out = 'yo'; $httpHeaders = 'Http'; $responseHeaders = array('hell' => 'yeah'); @@ -251,10 +247,6 @@ class DispatcherTest extends \Test\TestCase { public function testExceptionThrowsIfCanNotBeHandledByAfterException() { - // TODO fails on PHP 5.3 and crashed travis (10 minute timeout) - if (version_compare(PHP_VERSION, '5.4.0', '<')) { - $this->markTestSkipped('Fails on PHP 5.3 and causes infinite loop - travis fails after 10 minute timeout'); - } $out = 'yo'; $httpHeaders = 'Http'; $responseHeaders = array('hell' => 'yeah'); diff --git a/tests/lib/files/node/file.php b/tests/lib/files/node/file.php index 1ae312ab5a8..a1d2266edf7 100644 --- a/tests/lib/files/node/file.php +++ b/tests/lib/files/node/file.php @@ -8,6 +8,7 @@ namespace Test\Files\Node; +use OC\Files\FileInfo; use OCP\Files\NotFoundException; use OCP\Files\NotPermittedException; use OC\Files\View; @@ -20,6 +21,10 @@ class File extends \Test\TestCase { $this->user = new \OC\User\User('', new \OC_User_Dummy); } + protected function getFileInfo($data) { + return new FileInfo('', null, '', $data); + } + public function testDelete() { $manager = $this->getMock('\OC\Files\Mount\Manager'); @@ -39,7 +44,7 @@ class File extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_ALL))); + ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL)))); $view->expects($this->once()) ->method('unlink') @@ -89,7 +94,7 @@ class File extends \Test\TestCase { $view->expects($this->any()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1))); + ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1)))); $view->expects($this->once()) ->method('unlink') @@ -124,7 +129,7 @@ class File extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_READ))); + ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_READ)))); $node = new \OC\Files\Node\File($root, $view, '/bar/foo'); $node->delete(); @@ -156,7 +161,7 @@ class File extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_READ))); + ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_READ)))); $node = new \OC\Files\Node\File($root, $view, '/bar/foo'); $this->assertEquals('bar', $node->getContent()); @@ -180,7 +185,7 @@ class File extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => 0))); + ->will($this->returnValue($this->getFileInfo(array('permissions' => 0)))); $node = new \OC\Files\Node\File($root, $view, '/bar/foo'); $node->getContent(); @@ -201,7 +206,7 @@ class File extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_ALL))); + ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL)))); $view->expects($this->once()) ->method('file_put_contents') @@ -226,7 +231,7 @@ class File extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_READ))); + ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_READ)))); $node = new \OC\Files\Node\File($root, $view, '/bar/foo'); $node->putContent('bar'); @@ -241,9 +246,9 @@ class File extends \Test\TestCase { $root = $this->getMock('\OC\Files\Node\Root', array(), array($manager, $view, $this->user)); $view->expects($this->once()) - ->method('getMimeType') + ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue('text/plain')); + ->will($this->returnValue($this->getFileInfo(array('mimetype' => 'text/plain')))); $node = new \OC\Files\Node\File($root, $view, '/bar/foo'); $this->assertEquals('text/plain', $node->getMimeType()); @@ -279,7 +284,7 @@ class File extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_ALL))); + ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL)))); $node = new \OC\Files\Node\File($root, $view, '/bar/foo'); $fh = $node->fopen('r'); @@ -316,7 +321,7 @@ class File extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_ALL))); + ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL)))); $node = new \OC\Files\Node\File($root, $view, '/bar/foo'); $fh = $node->fopen('w'); @@ -348,7 +353,7 @@ class File extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => 0))); + ->will($this->returnValue($this->getFileInfo(array('permissions' => 0)))); $node = new \OC\Files\Node\File($root, $view, '/bar/foo'); $node->fopen('r'); @@ -375,7 +380,7 @@ class File extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_UPDATE))); + ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_UPDATE)))); $node = new \OC\Files\Node\File($root, $view, '/bar/foo'); $node->fopen('w'); @@ -402,7 +407,7 @@ class File extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_READ))); + ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_READ)))); $node = new \OC\Files\Node\File($root, $view, '/bar/foo'); $node->fopen('w'); @@ -425,7 +430,7 @@ class File extends \Test\TestCase { $view->expects($this->any()) ->method('getFileInfo') - ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 3))); + ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 3)))); $node = new \OC\Files\Node\File($root, $view, '/bar/foo'); $parentNode = new \OC\Files\Node\Folder($root, $view, '/bar'); @@ -469,7 +474,7 @@ class File extends \Test\TestCase { $view->expects($this->any()) ->method('getFileInfo') - ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_READ, 'fileid' => 3))); + ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_READ, 'fileid' => 3)))); $node = new \OC\Files\Node\File($root, $view, '/bar/foo'); $parentNode = new \OC\Files\Node\Folder($root, $view, '/bar'); @@ -556,7 +561,7 @@ class File extends \Test\TestCase { $view->expects($this->any()) ->method('getFileInfo') - ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1))); + ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1)))); $node = new \OC\Files\Node\File($root, $view, '/bar/foo'); $parentNode = new \OC\Files\Node\Folder($root, $view, '/bar'); @@ -587,7 +592,7 @@ class File extends \Test\TestCase { $view->expects($this->any()) ->method('getFileInfo') - ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_READ))); + ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_READ)))); $view->expects($this->never()) ->method('rename'); diff --git a/tests/lib/files/node/folder.php b/tests/lib/files/node/folder.php index 91aa3b82db2..4aa57aa9373 100644 --- a/tests/lib/files/node/folder.php +++ b/tests/lib/files/node/folder.php @@ -9,6 +9,7 @@ namespace Test\Files\Node; use OC\Files\Cache\Cache; +use OC\Files\FileInfo; use OC\Files\Mount\Mount; use OC\Files\Node\Node; use OCP\Files\NotFoundException; @@ -23,6 +24,10 @@ class Folder extends \Test\TestCase { $this->user = new \OC\User\User('', new \OC_User_Dummy); } + protected function getFileInfo($data) { + return new FileInfo('', null, '', $data); + } + public function testDelete() { $manager = $this->getMock('\OC\Files\Mount\Manager'); /** @@ -39,7 +44,7 @@ class Folder extends \Test\TestCase { $view->expects($this->any()) ->method('getFileInfo') - ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_ALL))); + ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL)))); $view->expects($this->once()) ->method('rmdir') @@ -87,7 +92,7 @@ class Folder extends \Test\TestCase { $view->expects($this->any()) ->method('getFileInfo') - ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1))); + ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL, 'fileid' => 1)))); $view->expects($this->once()) ->method('rmdir') @@ -121,7 +126,7 @@ class Folder extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_READ))); + ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_READ)))); $node = new \OC\Files\Node\Folder($root, $view, '/bar/foo'); $node->delete(); @@ -255,7 +260,7 @@ class Folder extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_ALL))); + ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL)))); $view->expects($this->once()) ->method('mkdir') @@ -285,7 +290,7 @@ class Folder extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_READ))); + ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_READ)))); $node = new \OC\Files\Node\Folder($root, $view, '/bar/foo'); $node->newFolder('asd'); @@ -305,7 +310,7 @@ class Folder extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_ALL))); + ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL)))); $view->expects($this->once()) ->method('touch') @@ -335,7 +340,7 @@ class Folder extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_READ))); + ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_READ)))); $node = new \OC\Files\Node\Folder($root, $view, '/bar/foo'); $node->newFile('asd'); diff --git a/tests/lib/files/node/node.php b/tests/lib/files/node/node.php index 8820be5b0b2..4697479ba95 100644 --- a/tests/lib/files/node/node.php +++ b/tests/lib/files/node/node.php @@ -8,6 +8,8 @@ namespace Test\Files\Node; +use OC\Files\FileInfo; + class Node extends \Test\TestCase { private $user; @@ -16,6 +18,10 @@ class Node extends \Test\TestCase { $this->user = new \OC\User\User('', new \OC_User_Dummy); } + protected function getFileInfo($data) { + return new FileInfo('', null, '', $data); + } + public function testStat() { $manager = $this->getMock('\OC\Files\Mount\Manager'); /** @@ -55,12 +61,12 @@ class Node extends \Test\TestCase { ->method('getUser') ->will($this->returnValue($this->user)); - $stat = array( + $stat = $this->getFileInfo(array( 'fileid' => 1, 'size' => 100, 'etag' => 'qwerty', 'mtime' => 50 - ); + )); $view->expects($this->once()) ->method('getFileInfo') @@ -82,10 +88,18 @@ class Node extends \Test\TestCase { ->method('getUser') ->will($this->returnValue($this->user)); + + $stat = $this->getFileInfo(array( + 'fileid' => 1, + 'size' => 100, + 'etag' => 'qwerty', + 'mtime' => 50 + )); + $view->expects($this->once()) - ->method('filesize') + ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(100)); + ->will($this->returnValue($stat)); $node = new \OC\Files\Node\File($root, $view, '/bar/foo'); $this->assertEquals(100, $node->getSize()); @@ -102,12 +116,12 @@ class Node extends \Test\TestCase { ->method('getUser') ->will($this->returnValue($this->user)); - $stat = array( + $stat = $this->getFileInfo(array( 'fileid' => 1, 'size' => 100, 'etag' => 'qwerty', 'mtime' => 50 - ); + )); $view->expects($this->once()) ->method('getFileInfo') @@ -128,15 +142,18 @@ class Node extends \Test\TestCase { $root->expects($this->any()) ->method('getUser') ->will($this->returnValue($this->user)); - /** - * @var \OC\Files\Storage\Storage | \PHPUnit_Framework_MockObject_MockObject $storage - */ - $storage = $this->getMock('\OC\Files\Storage\Storage'); + + $stat = $this->getFileInfo(array( + 'fileid' => 1, + 'size' => 100, + 'etag' => 'qwerty', + 'mtime' => 50 + )); $view->expects($this->once()) - ->method('filemtime') + ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(50)); + ->will($this->returnValue($stat)); $node = new \OC\Files\Node\File($root, $view, '/bar/foo'); $this->assertEquals(50, $node->getMTime()); @@ -239,14 +256,9 @@ class Node extends \Test\TestCase { ->will($this->returnValue(true)); $view->expects($this->once()) - ->method('filemtime') - ->with('/bar/foo') - ->will($this->returnValue(100)); - - $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_ALL))); + ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL)))); $node = new \OC\Files\Node\Node($root, $view, '/bar/foo'); $node->touch(100); @@ -299,7 +311,7 @@ class Node extends \Test\TestCase { $view->expects($this->any()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_ALL))); + ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_ALL)))); $node = new \OC\Files\Node\Node($root, $view, '/bar/foo'); $node->touch(100); @@ -323,7 +335,7 @@ class Node extends \Test\TestCase { $view->expects($this->any()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('permissions' => \OCP\Constants::PERMISSION_READ))); + ->will($this->returnValue($this->getFileInfo(array('permissions' => \OCP\Constants::PERMISSION_READ)))); $node = new \OC\Files\Node\Node($root, $view, '/bar/foo'); $node->touch(100); diff --git a/tests/lib/files/node/root.php b/tests/lib/files/node/root.php index fcce7070f5d..35bd462157e 100644 --- a/tests/lib/files/node/root.php +++ b/tests/lib/files/node/root.php @@ -8,6 +8,7 @@ namespace Test\Files\Node; +use OC\Files\FileInfo; use OCP\Files\NotPermittedException; use OC\Files\Mount\Manager; @@ -19,6 +20,10 @@ class Root extends \Test\TestCase { $this->user = new \OC\User\User('', new \OC_User_Dummy); } + protected function getFileInfo($data) { + return new FileInfo('', null, '', $data); + } + public function testGet() { $manager = new Manager(); /** @@ -34,7 +39,7 @@ class Root extends \Test\TestCase { $view->expects($this->once()) ->method('getFileInfo') ->with('/bar/foo') - ->will($this->returnValue(array('fileid' => 10, 'path' => 'bar/foo', 'name', 'mimetype' => 'text/plain'))); + ->will($this->returnValue($this->getFileInfo(array('fileid' => 10, 'path' => 'bar/foo', 'name', 'mimetype' => 'text/plain')))); $view->expects($this->once()) ->method('is_dir') diff --git a/tests/lib/files/objectstore/swift.php b/tests/lib/files/objectstore/swift.php index f2c4a983cf2..30c60598277 100644 --- a/tests/lib/files/objectstore/swift.php +++ b/tests/lib/files/objectstore/swift.php @@ -34,7 +34,7 @@ class Swift extends \Test\Files\Storage\Storage { parent::setUp(); if (!getenv('RUN_OBJECTSTORE_TESTS')) { - $this->markTestSkipped('objectstore tests are unreliable on travis'); + $this->markTestSkipped('objectstore tests are unreliable in some environments'); } \OC_App::disable('files_sharing'); @@ -87,10 +87,6 @@ class Swift extends \Test\Files\Storage\Storage { } public function testStat() { - // TODO travis - if (getenv('TRAVIS')) { - $this->markTestSkipped('Fails on travis - connection times out sometimes'); - } $textFile = \OC::$SERVERROOT . '/tests/data/lorem.txt'; $ctimeStart = time(); |