From 197e94457ffb43b8307f5d0009313b7a7a4208fd Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 1 Jul 2016 16:04:25 +0200 Subject: [PATCH 1/9] Fix AvatarControllerTest with phpunit 5.2+ --- tests/core/controller/avatarcontrollertest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/core/controller/avatarcontrollertest.php b/tests/core/controller/avatarcontrollertest.php index 8e5e58904a739..c99b69228b1d4 100644 --- a/tests/core/controller/avatarcontrollertest.php +++ b/tests/core/controller/avatarcontrollertest.php @@ -93,7 +93,7 @@ protected function setUp() { $this->container['UserSession']->method('getUser')->willReturn($this->userMock); $this->avatarFile = $this->getMock('OCP\Files\File'); - $this->avatarFile->method('getContnet')->willReturn('image data'); + $this->avatarFile->method('getContent')->willReturn('image data'); $this->avatarFile->method('getMimeType')->willReturn('image type'); $this->avatarFile->method('getEtag')->willReturn('my etag'); } From ea9c79b7c0d22cead5b470a09653cd9ae6ff022e Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 1 Jul 2016 16:05:00 +0200 Subject: [PATCH 2/9] Fix Appframework tests with phpunit 5.2+ --- tests/lib/appframework/db/mappertest.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/lib/appframework/db/mappertest.php b/tests/lib/appframework/db/mappertest.php index c8b999ad62cc0..e2a70d9423ac1 100644 --- a/tests/lib/appframework/db/mappertest.php +++ b/tests/lib/appframework/db/mappertest.php @@ -236,7 +236,9 @@ public function testUpdateNothingChangedNoQuery(){ $entity->resetUpdatedFields(); $this->db->expects($this->never()) - ->method('prepareQuery'); + ->method('prepare'); + $this->db->expects($this->never()) + ->method('prepare'); $this->mapper->update($entity); } From 777dbec369937aa4ac87720bfeeb413a2a8801db Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 1 Jul 2016 16:05:16 +0200 Subject: [PATCH 3/9] Fix Notification tests with phpunit 5.2+ --- tests/lib/notification/notificationtest.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/lib/notification/notificationtest.php b/tests/lib/notification/notificationtest.php index ee9454c77a096..bb9440a34d92d 100644 --- a/tests/lib/notification/notificationtest.php +++ b/tests/lib/notification/notificationtest.php @@ -517,6 +517,7 @@ public function testIsValid($isValidCommon, $subject, $expected) { ->setMethods([ 'isValidCommon', 'getSubject', + 'getParsedSubject', ]) ->getMock(); @@ -547,6 +548,7 @@ public function testIsParsedValid($isValidCommon, $subject, $expected) { $notification = $this->getMockBuilder('\OC\Notification\Notification') ->setMethods([ 'isValidCommon', + 'getSubject', 'getParsedSubject', ]) ->getMock(); From 75c172a062579a5f28551eeb37d9145c451f1867 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 1 Jul 2016 16:08:26 +0200 Subject: [PATCH 4/9] Fix Share Manager tests with phpunit 5.2+ --- tests/lib/share20/managertest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/lib/share20/managertest.php b/tests/lib/share20/managertest.php index ece4ae2384746..8f3417d53fd3b 100644 --- a/tests/lib/share20/managertest.php +++ b/tests/lib/share20/managertest.php @@ -590,7 +590,7 @@ public function createShare($id, $type, $path, $sharedWith, $sharedBy, $shareOwn $share->method('getShareType')->willReturn($type); $share->method('getSharedWith')->willReturn($sharedWith); $share->method('getSharedBy')->willReturn($sharedBy); - $share->method('getSharedOwner')->willReturn($shareOwner); + $share->method('getShareOwner')->willReturn($shareOwner); $share->method('getNode')->willReturn($path); $share->method('getPermissions')->willReturn($permissions); $share->method('getExpirationDate')->willReturn($expireDate); From 28b3a0a37e22f8a35a71d2e56e8ffa4a144b9ab7 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 1 Jul 2016 16:16:40 +0200 Subject: [PATCH 5/9] Fix DAV tests with phpunit 5.2+ --- .../unit/connector/sabre/filesplugin.php | 48 ++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/apps/dav/tests/unit/connector/sabre/filesplugin.php b/apps/dav/tests/unit/connector/sabre/filesplugin.php index ecad56d004dd2..b664d7caaed34 100644 --- a/apps/dav/tests/unit/connector/sabre/filesplugin.php +++ b/apps/dav/tests/unit/connector/sabre/filesplugin.php @@ -84,32 +84,37 @@ public function setUp() { /** * @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 @@ public function testGetPropertiesForFile() { } 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 @@ public function testGetPropertiesForFileHome() { ->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 @@ public function testGetPropertiesForDirectory() { 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)); From fd5bdf5e1ab9d3bba74bb07f110dd5641ed83864 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 1 Jul 2016 16:22:50 +0200 Subject: [PATCH 6/9] Fix Encryption tests with phpunit 5.2+ --- apps/encryption/tests/lib/MigrationTest.php | 10 ++++++---- apps/encryption/tests/lib/crypto/encryptionTest.php | 3 --- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/apps/encryption/tests/lib/MigrationTest.php b/apps/encryption/tests/lib/MigrationTest.php index 6edb8624e7077..c71d624542437 100644 --- a/apps/encryption/tests/lib/MigrationTest.php +++ b/apps/encryption/tests/lib/MigrationTest.php @@ -27,6 +27,11 @@ 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 @@ public function prepareFileCache() { */ 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 8a228c2c2159c..ad20efb4451ec 100644 --- a/apps/encryption/tests/lib/crypto/encryptionTest.php +++ b/apps/encryption/tests/lib/crypto/encryptionTest.php @@ -142,9 +142,6 @@ public function endTest() { $this->cryptMock->expects($this->any()) ->method('multiKeyEncrypt') ->willReturn(true); - $this->cryptMock->expects($this->any()) - ->method('setAllFileKeys') - ->willReturn(true); $this->instance->end('/foo/bar'); } From eb715dd1b6da796c2b818a32769ffcd68e9d7ee9 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 1 Jul 2016 16:29:53 +0200 Subject: [PATCH 7/9] Fix Sharing app tests with phpunit 5.2+ --- apps/files_sharing/tests/api/share20ocstest.php | 6 +++--- apps/files_sharing/tests/controller/sharecontroller.php | 6 +----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/apps/files_sharing/tests/api/share20ocstest.php b/apps/files_sharing/tests/api/share20ocstest.php index 5b1f729997fea..a0803742c2d2d 100644 --- a/apps/files_sharing/tests/api/share20ocstest.php +++ b/apps/files_sharing/tests/api/share20ocstest.php @@ -668,7 +668,7 @@ public function testCreateShareUser() { $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 @@ public function testCreateShareGroup() { ->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 @@ public function testCreateShareGroupNotAllowed() { ->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 24a6bc7984ccc..f953f02f23d70 100644 --- a/apps/files_sharing/tests/controller/sharecontroller.php +++ b/apps/files_sharing/tests/controller/sharecontroller.php @@ -85,10 +85,6 @@ protected function setUp() { $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 @@ public function testDownloadShareWithCreateOnlyShare() { $this->assertEquals($expectedResponse, $response); } -} \ No newline at end of file +} From 3399d66c8ee6db9b76b17a395357b054b5d5f290 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 1 Jul 2016 16:41:29 +0200 Subject: [PATCH 8/9] Fix Comments tests with phpunit 5.2+ --- apps/dav/tests/unit/comments/commentsplugin.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/apps/dav/tests/unit/comments/commentsplugin.php b/apps/dav/tests/unit/comments/commentsplugin.php index c7d073d149140..c909f6a61ab4c 100644 --- a/apps/dav/tests/unit/comments/commentsplugin.php +++ b/apps/dav/tests/unit/comments/commentsplugin.php @@ -449,16 +449,6 @@ public function testCreateCommentInvalidPayload() { ->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)); From ce6009e475557404c462ca1d3b94c126ddbb95df Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 1 Jul 2016 16:41:46 +0200 Subject: [PATCH 9/9] Fix Single execution of preview tests --- tests/lib/preview/movie.php | 5 +++++ tests/lib/preview/office.php | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/tests/lib/preview/movie.php b/tests/lib/preview/movie.php index c6b0c0f7322bd..ef290092fc2eb 100644 --- a/tests/lib/preview/movie.php +++ b/tests/lib/preview/movie.php @@ -21,6 +21,11 @@ namespace Test\Preview; +/** + * Class Movie + * @package Test\Preview + * @group DB + */ class Movie extends Provider { public function setUp() { diff --git a/tests/lib/preview/office.php b/tests/lib/preview/office.php index 22eeb0aed333b..9fcdd6210318d 100644 --- a/tests/lib/preview/office.php +++ b/tests/lib/preview/office.php @@ -21,6 +21,11 @@ namespace Test\Preview; +/** + * Class Office + * @package Test\Preview + * @group DB + */ class Office extends Provider { public function setUp() {