diff options
author | Björn Schießle <bjoern@schiessle.org> | 2016-07-01 17:11:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-01 17:11:19 +0200 |
commit | 756b0c05b6ebc3e4f0addec67e96d3bdd2d5a11a (patch) | |
tree | 124d40453243102238e9d52d282099e660850dd8 /apps | |
parent | 7e4366ec860f9a03c1607364bb9c1d1d7997ccc1 (diff) | |
parent | ce6009e475557404c462ca1d3b94c126ddbb95df (diff) | |
download | nextcloud-server-756b0c05b6ebc3e4f0addec67e96d3bdd2d5a11a.tar.gz nextcloud-server-756b0c05b6ebc3e4f0addec67e96d3bdd2d5a11a.zip |
Merge pull request #282 from nextcloud/fix-tests
Fix unit test compatibility issues with phpunit 5.2+
Diffstat (limited to 'apps')
-rw-r--r-- | apps/dav/tests/unit/comments/commentsplugin.php | 10 | ||||
-rw-r--r-- | apps/dav/tests/unit/connector/sabre/filesplugin.php | 48 | ||||
-rw-r--r-- | apps/encryption/tests/lib/MigrationTest.php | 10 | ||||
-rw-r--r-- | apps/encryption/tests/lib/crypto/encryptionTest.php | 3 | ||||
-rw-r--r-- | apps/files_sharing/tests/api/share20ocstest.php | 6 | ||||
-rw-r--r-- | apps/files_sharing/tests/controller/sharecontroller.php | 6 |
6 files changed, 36 insertions, 47 deletions
diff --git a/apps/dav/tests/unit/comments/commentsplugin.php b/apps/dav/tests/unit/comments/commentsplugin.php index c7d073d1491..c909f6a61ab 100644 --- a/apps/dav/tests/unit/comments/commentsplugin.php +++ b/apps/dav/tests/unit/comments/commentsplugin.php @@ -449,16 +449,6 @@ class CommentsPlugin extends \Test\TestCase { ->with('users', 'alice', 'files', '42') ->will($this->returnValue($comment)); - $this->commentsManager->expects($this->any()) - ->method('setMessage') - ->with('') - ->will($this->throwException(new \InvalidArgumentException())); - - $this->commentsManager->expects($this->any()) - ->method('setVerb') - ->with('') - ->will($this->throwException(new \InvalidArgumentException())); - $this->userSession->expects($this->once()) ->method('getUser') ->will($this->returnValue($user)); diff --git a/apps/dav/tests/unit/connector/sabre/filesplugin.php b/apps/dav/tests/unit/connector/sabre/filesplugin.php index ecad56d004d..b664d7caaed 100644 --- a/apps/dav/tests/unit/connector/sabre/filesplugin.php +++ b/apps/dav/tests/unit/connector/sabre/filesplugin.php @@ -84,32 +84,37 @@ class FilesPlugin extends \Test\TestCase { /** * @param string $class + * @param bool $hasAllMethods + * @return \PHPUnit_Framework_MockObject_MockObject|\Sabre\DAV\IFile */ - private function createTestNode($class) { + private function createTestNode($class, $hasAllMethods = true) + { $node = $this->getMockBuilder($class) ->disableOriginalConstructor() ->getMock(); - $node->expects($this->any()) - ->method('getId') - ->will($this->returnValue(123)); $this->tree->expects($this->any()) ->method('getNodeForPath') ->with('/dummypath') ->will($this->returnValue($node)); - $node->expects($this->any()) - ->method('getFileId') - ->will($this->returnValue('00000123instanceid')); - $node->expects($this->any()) - ->method('getInternalFileId') - ->will($this->returnValue('123')); - $node->expects($this->any()) - ->method('getEtag') - ->will($this->returnValue('"abc"')); - $node->expects($this->any()) - ->method('getDavPermissions') - ->will($this->returnValue('DWCKMSR')); + if ($hasAllMethods) { + $node->expects($this->any()) + ->method('getId') + ->will($this->returnValue(123)); + $node->expects($this->any()) + ->method('getFileId') + ->will($this->returnValue('00000123instanceid')); + $node->expects($this->any()) + ->method('getInternalFileId') + ->will($this->returnValue('123')); + $node->expects($this->any()) + ->method('getEtag') + ->will($this->returnValue('"abc"')); + $node->expects($this->any()) + ->method('getDavPermissions') + ->will($this->returnValue('DWCKMSR')); + } return $node; } @@ -169,7 +174,7 @@ class FilesPlugin extends \Test\TestCase { } public function testGetPropertiesForFileHome() { - $node = $this->createTestNode('\OCA\DAV\Files\FilesHome'); + $node = $this->createTestNode('\OCA\DAV\Files\FilesHome', false); $propFind = new \Sabre\DAV\PropFind( '/dummyPath', @@ -190,9 +195,9 @@ class FilesPlugin extends \Test\TestCase { ->disableOriginalConstructor()->getMock(); $user->expects($this->never())->method('getUID'); $user->expects($this->never())->method('getDisplayName'); - $node->expects($this->never())->method('getDirectDownload'); - $node->expects($this->never())->method('getOwner'); - $node->expects($this->never())->method('getSize'); + // Method does not exist: $node->expects($this->never())->method('getDirectDownload'); + // Method does not exist: $node->expects($this->never())->method('getOwner'); + // Method does not exist: $node->expects($this->never())->method('getSize'); $this->plugin->handleGetProperties( $propFind, @@ -285,8 +290,7 @@ class FilesPlugin extends \Test\TestCase { 0 ); - $node->expects($this->never()) - ->method('getDirectDownload'); + // Method does not exist: $node->expects($this->never())->method('getDirectDownload'); $node->expects($this->once()) ->method('getSize') ->will($this->returnValue(1025)); diff --git a/apps/encryption/tests/lib/MigrationTest.php b/apps/encryption/tests/lib/MigrationTest.php index 6edb8624e70..c71d6245424 100644 --- a/apps/encryption/tests/lib/MigrationTest.php +++ b/apps/encryption/tests/lib/MigrationTest.php @@ -27,6 +27,11 @@ namespace OCA\Encryption\Tests; use OCA\Encryption\Migration; use OCP\ILogger; +/** + * Class MigrationTest + * @package OCA\Encryption\Tests + * @group DB + */ class MigrationTest extends \Test\TestCase { const TEST_ENCRYPTION_MIGRATION_USER1='test_encryption_user1'; @@ -39,7 +44,7 @@ class MigrationTest extends \Test\TestCase { private $recovery_key_id = 'recovery_key_id'; private $moduleId; - /** @var PHPUnit_Framework_MockObject_MockObject | ILogger */ + /** @var \PHPUnit_Framework_MockObject_MockObject | ILogger */ private $logger; public static function setUpBeforeClass() { @@ -512,12 +517,9 @@ class MigrationTest extends \Test\TestCase { */ public function testGetTargetDir($user, $keyPath, $filename, $trash, $systemMounts, $expected) { - $updater = $this->getMockBuilder('\OC\Files\Cache\Updater') - ->disableOriginalConstructor()->getMock(); $view = $this->getMockBuilder('\OC\Files\View') ->disableOriginalConstructor()->getMock(); $view->expects($this->any())->method('file_exists')->willReturn(true); - $view->expects($this->any())->method('getUpdater')->willReturn($updater); $m = $this->getMockBuilder('OCA\Encryption\Migration') diff --git a/apps/encryption/tests/lib/crypto/encryptionTest.php b/apps/encryption/tests/lib/crypto/encryptionTest.php index 8a228c2c215..ad20efb4451 100644 --- a/apps/encryption/tests/lib/crypto/encryptionTest.php +++ b/apps/encryption/tests/lib/crypto/encryptionTest.php @@ -142,9 +142,6 @@ class EncryptionTest extends TestCase { $this->cryptMock->expects($this->any()) ->method('multiKeyEncrypt') ->willReturn(true); - $this->cryptMock->expects($this->any()) - ->method('setAllFileKeys') - ->willReturn(true); $this->instance->end('/foo/bar'); } diff --git a/apps/files_sharing/tests/api/share20ocstest.php b/apps/files_sharing/tests/api/share20ocstest.php index 5b1f729997f..a0803742c2d 100644 --- a/apps/files_sharing/tests/api/share20ocstest.php +++ b/apps/files_sharing/tests/api/share20ocstest.php @@ -668,7 +668,7 @@ class Share20OCSTest extends \Test\TestCase { $user = $this->getMock('\OCP\IUser'); $this->userManager->method('userExists')->with('validUser')->willReturn(true); - $share->method('setPath')->with($path); + $share->method('setNode')->with($path); $share->method('setPermissions') ->with( \OCP\Constants::PERMISSION_ALL & @@ -773,7 +773,7 @@ class Share20OCSTest extends \Test\TestCase { ->method('allowGroupSharing') ->willReturn(true); - $share->method('setPath')->with($path); + $share->method('setNode')->with($path); $share->method('setPermissions')->with(\OCP\Constants::PERMISSION_ALL); $share->method('setShareType')->with(\OCP\Share::SHARE_TYPE_GROUP); $share->method('setSharedWith')->with('validGroup'); @@ -822,7 +822,7 @@ class Share20OCSTest extends \Test\TestCase { ->method('allowGroupSharing') ->willReturn(false); - $share->method('setPath')->with($path); + $share->method('setNode')->with($path); $expected = new \OC_OCS_Result(null, 404, 'group sharing is disabled by the administrator'); $result = $this->ocs->createShare(); diff --git a/apps/files_sharing/tests/controller/sharecontroller.php b/apps/files_sharing/tests/controller/sharecontroller.php index 24a6bc7984c..f953f02f23d 100644 --- a/apps/files_sharing/tests/controller/sharecontroller.php +++ b/apps/files_sharing/tests/controller/sharecontroller.php @@ -85,10 +85,6 @@ class ShareControllerTest extends \Test\TestCase { $this->userManager = $this->getMock('\OCP\IUserManager'); $this->federatedShareProvider = $this->getMockBuilder('OCA\FederatedFileSharing\FederatedShareProvider') ->disableOriginalConstructor()->getMock(); - $this->federatedShareProvider->expects($this->any()) - ->method('isOutgoingServer2serverShareEnabled')->willReturn(true); - $this->federatedShareProvider->expects($this->any()) - ->method('isIncomingServer2serverShareEnabled')->willReturn(true); $this->shareController = new \OCA\Files_Sharing\Controllers\ShareController( $this->appName, @@ -476,4 +472,4 @@ class ShareControllerTest extends \Test\TestCase { $this->assertEquals($expectedResponse, $response); } -}
\ No newline at end of file +} |