Skip to content

Commit

Permalink
Update phpunit (#25986)
Browse files Browse the repository at this point in the history
* Update phpunit dependency to 5.5

* getMock() -> createMock() or getMockBuilder()

* Fix integration tests - comment enable/disable app tests for now

* Update .htaccess
  • Loading branch information
DeepDiver1975 committed Sep 11, 2016
1 parent 0a6e09a commit 80a2bcc
Show file tree
Hide file tree
Showing 204 changed files with 2,581 additions and 2,214 deletions.
4 changes: 0 additions & 4 deletions .htaccess
Expand Up @@ -72,7 +72,3 @@ Options -Indexes
<IfModule pagespeed_module>
ModPagespeed Off
</IfModule>
#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####

ErrorDocument 403 //core/templates/403.php
ErrorDocument 404 //core/templates/404.php
2 changes: 1 addition & 1 deletion apps/dav/lib/Connector/Sabre/File.php
Expand Up @@ -73,7 +73,7 @@ class File extends Node implements IFile {
* different object on a subsequent GET you are strongly recommended to not
* return an ETag, and just return null.
*
* @param resource $data
* @param resource|string $data
*
* @throws Forbidden
* @throws UnsupportedMediaType
Expand Down
1 change: 1 addition & 0 deletions apps/dav/lib/Connector/Sabre/Node.php
Expand Up @@ -115,6 +115,7 @@ public function getPath() {
* @param string $name The new name
* @throws \Sabre\DAV\Exception\BadRequest
* @throws \Sabre\DAV\Exception\Forbidden
* @throws InvalidPath
*/
public function setName($name) {

Expand Down
4 changes: 2 additions & 2 deletions apps/dav/tests/unit/CardDAV/AddressBookImplTest.php
Expand Up @@ -64,8 +64,8 @@ public function setUp() {
->disableOriginalConstructor()->getMock();
$this->backend = $this->getMockBuilder('\OCA\DAV\CardDAV\CardDavBackend')
->disableOriginalConstructor()->getMock();
$this->vCard = $this->getMock('Sabre\VObject\Component\VCard');
$this->urlGenerator = $this->getMock('OCP\IURLGenerator');
$this->vCard = $this->createMock('Sabre\VObject\Component\VCard');
$this->urlGenerator = $this->createMock('OCP\IURLGenerator');

$this->addressBookImpl = new AddressBookImpl(
$this->addressBook,
Expand Down
6 changes: 4 additions & 2 deletions apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php
Expand Up @@ -105,8 +105,10 @@ public function testOnCardChanged($expectedOp) {
$this->cardDav->expects($this->once())->method('getShares')->willReturn([]);

/** @var BirthdayService | \PHPUnit_Framework_MockObject_MockObject $service */
$service = $this->getMock('\OCA\DAV\CalDAV\BirthdayService',
['buildBirthdayFromContact', 'birthdayEvenChanged'], [$this->calDav, $this->cardDav, $this->groupPrincialBackend]);
$service = $this->getMockBuilder(BirthdayService::class)
->setMethods(['buildBirthdayFromContact', 'birthdayEvenChanged'])
->setConstructorArgs([$this->calDav, $this->cardDav, $this->groupPrincialBackend])
->getMock();

if ($expectedOp === 'delete') {
$this->calDav->expects($this->once())->method('getCalendarObject')->willReturn('');
Expand Down
5 changes: 4 additions & 1 deletion apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php
Expand Up @@ -57,7 +57,10 @@ function setUp() {
$this->server->tree = $this->tree;
$this->logger = $this->getMockBuilder('\OCP\ILogger')->getMock();

$this->plugin = $this->getMock('OCA\DAV\CardDAV\ImageExportPlugin', ['getPhoto'], [$this->logger]);
$this->plugin = $this->getMockBuilder('OCA\DAV\CardDAV\ImageExportPlugin')
->setMethods(['getPhoto'])
->setConstructorArgs([$this->logger])
->getMock();
$this->plugin->initialize($this->server);
}

Expand Down
2 changes: 1 addition & 1 deletion apps/dav/tests/unit/CardDAV/SyncServiceTest.php
Expand Up @@ -132,7 +132,7 @@ private function getSyncServiceMock($backend, $response) {
$userManager = $this->getMockBuilder('OCP\IUserManager')->disableOriginalConstructor()->getMock();
$logger = $this->getMockBuilder('OCP\ILogger')->disableOriginalConstructor()->getMock();
/** @var SyncService | \PHPUnit_Framework_MockObject_MockObject $ss */
$ss = $this->getMock('OCA\DAV\CardDAV\SyncService', ['ensureSystemAddressBookExists', 'requestSyncReport', 'download'], [$backend, $userManager, $logger]);
$ss = $this->createMock('OCA\DAV\CardDAV\SyncService', ['ensureSystemAddressBookExists', 'requestSyncReport', 'download'], [$backend, $userManager, $logger]);
$ss->method('requestSyncReport')->withAnyParameters()->willReturn(['response' => $response, 'token' => 'sync-token-1']);
$ss->method('ensureSystemAddressBookExists')->willReturn(['id' => 1]);
$ss->method('download')->willReturn([
Expand Down
26 changes: 13 additions & 13 deletions apps/dav/tests/unit/Comments/CommentsNodeTest.php
Expand Up @@ -38,11 +38,11 @@ class CommentsNodeTest extends \Test\TestCase {
public function setUp() {
parent::setUp();

$this->commentsManager = $this->getMock('\OCP\Comments\ICommentsManager');
$this->comment = $this->getMock('\OCP\Comments\IComment');
$this->userManager = $this->getMock('\OCP\IUserManager');
$this->userSession = $this->getMock('\OCP\IUserSession');
$this->logger = $this->getMock('\OCP\ILogger');
$this->commentsManager = $this->createMock('\OCP\Comments\ICommentsManager');
$this->comment = $this->createMock('\OCP\Comments\IComment');
$this->userManager = $this->createMock('\OCP\IUserManager');
$this->userSession = $this->createMock('\OCP\IUserSession');
$this->logger = $this->createMock('\OCP\ILogger');

$this->node = new CommentNode(
$this->commentsManager,
Expand All @@ -54,7 +54,7 @@ public function setUp() {
}

public function testDelete() {
$user = $this->getMock('\OCP\IUser');
$user = $this->createMock('\OCP\IUser');

$user->expects($this->once())
->method('getUID')
Expand Down Expand Up @@ -87,7 +87,7 @@ public function testDelete() {
* @expectedException \Sabre\DAV\Exception\Forbidden
*/
public function testDeleteForbidden() {
$user = $this->getMock('\OCP\IUser');
$user = $this->createMock('\OCP\IUser');

$user->expects($this->once())
->method('getUID')
Expand Down Expand Up @@ -137,7 +137,7 @@ public function testGetLastModified() {
public function testUpdateComment() {
$msg = 'Hello Earth';

$user = $this->getMock('\OCP\IUser');
$user = $this->createMock('\OCP\IUser');

$user->expects($this->once())
->method('getUID')
Expand Down Expand Up @@ -173,7 +173,7 @@ public function testUpdateComment() {
public function testUpdateCommentLogException() {
$msg = null;

$user = $this->getMock('\OCP\IUser');
$user = $this->createMock('\OCP\IUser');

$user->expects($this->once())
->method('getUID')
Expand Down Expand Up @@ -210,7 +210,7 @@ public function testUpdateCommentLogException() {
* @expectedExceptionMessage Message exceeds allowed character limit of
*/
public function testUpdateCommentMessageTooLongException() {
$user = $this->getMock('\OCP\IUser');
$user = $this->createMock('\OCP\IUser');

$user->expects($this->once())
->method('getUID')
Expand Down Expand Up @@ -248,7 +248,7 @@ public function testUpdateCommentMessageTooLongException() {
public function testUpdateForbiddenByUser() {
$msg = 'HaXX0r';

$user = $this->getMock('\OCP\IUser');
$user = $this->createMock('\OCP\IUser');

$user->expects($this->once())
->method('getUID')
Expand Down Expand Up @@ -281,7 +281,7 @@ public function testUpdateForbiddenByUser() {
public function testUpdateForbiddenByType() {
$msg = 'HaXX0r';

$user = $this->getMock('\OCP\IUser');
$user = $this->createMock('\OCP\IUser');

$user->expects($this->never())
->method('getUID');
Expand Down Expand Up @@ -454,7 +454,7 @@ public function testGetPropertiesUnreadProperty($creationDT, $readDT, $expected)

$this->userSession->expects($this->once())
->method('getUser')
->will($this->returnValue($this->getMock('\OCP\IUser')));
->will($this->returnValue($this->createMock('\OCP\IUser')));

$properties = $this->node->getProperties(null);

Expand Down
20 changes: 10 additions & 10 deletions apps/dav/tests/unit/Comments/CommentsPluginTest.php
Expand Up @@ -54,8 +54,8 @@ public function setUp() {
->setMethods(['getRequestUri'])
->getMock();

$this->commentsManager = $this->getMock('\OCP\Comments\ICommentsManager');
$this->userSession = $this->getMock('\OCP\IUserSession');
$this->commentsManager = $this->createMock('\OCP\Comments\ICommentsManager');
$this->userSession = $this->createMock('\OCP\IUserSession');

$this->plugin = new CommentsPluginImplementation($this->commentsManager, $this->userSession);
}
Expand All @@ -79,7 +79,7 @@ public function testCreateComment() {

$requestData = json_encode($commentData);

$user = $this->getMock('OCP\IUser');
$user = $this->createMock('OCP\IUser');
$user->expects($this->once())
->method('getUID')
->will($this->returnValue('alice'));
Expand Down Expand Up @@ -173,7 +173,7 @@ public function testCreateCommentInvalidObject() {

$path = 'comments/files/666';

$user = $this->getMock('OCP\IUser');
$user = $this->createMock('OCP\IUser');
$user->expects($this->never())
->method('getUID');

Expand Down Expand Up @@ -255,7 +255,7 @@ public function testCreateCommentInvalidActor() {

$requestData = json_encode($commentData);

$user = $this->getMock('OCP\IUser');
$user = $this->createMock('OCP\IUser');
$user->expects($this->never())
->method('getUID');

Expand Down Expand Up @@ -341,7 +341,7 @@ public function testCreateCommentUnsupportedMediaType() {

$requestData = json_encode($commentData);

$user = $this->getMock('OCP\IUser');
$user = $this->createMock('OCP\IUser');
$user->expects($this->never())
->method('getUID');

Expand Down Expand Up @@ -429,7 +429,7 @@ public function testCreateCommentInvalidPayload() {

$requestData = json_encode($commentData);

$user = $this->getMock('OCP\IUser');
$user = $this->createMock('OCP\IUser');
$user->expects($this->once())
->method('getUID')
->will($this->returnValue('alice'));
Expand Down Expand Up @@ -521,7 +521,7 @@ public function testCreateCommentMessageTooLong() {

$requestData = json_encode($commentData);

$user = $this->getMock('OCP\IUser');
$user = $this->createMock('OCP\IUser');
$user->expects($this->once())
->method('getUID')
->will($this->returnValue('alice'));
Expand Down Expand Up @@ -598,7 +598,7 @@ public function testOnReportInvalidNode() {
$this->tree->expects($this->any())
->method('getNodeForPath')
->with('/' . $path)
->will($this->returnValue($this->getMock('\Sabre\DAV\INode')));
->will($this->returnValue($this->createMock('\Sabre\DAV\INode')));

$this->server->expects($this->any())
->method('getRequestUri')
Expand All @@ -617,7 +617,7 @@ public function testOnReportInvalidReportName() {
$this->tree->expects($this->any())
->method('getNodeForPath')
->with('/' . $path)
->will($this->returnValue($this->getMock('\Sabre\DAV\INode')));
->will($this->returnValue($this->createMock('\Sabre\DAV\INode')));

$this->server->expects($this->any())
->method('getRequestUri')
Expand Down
14 changes: 7 additions & 7 deletions apps/dav/tests/unit/Comments/EntityCollectionTest.php
Expand Up @@ -38,10 +38,10 @@ class EntityCollectionTest extends \Test\TestCase {
public function setUp() {
parent::setUp();

$this->commentsManager = $this->getMock('\OCP\Comments\ICommentsManager');
$this->userManager = $this->getMock('\OCP\IUserManager');
$this->userSession = $this->getMock('\OCP\IUserSession');
$this->logger = $this->getMock('\OCP\ILogger');
$this->commentsManager = $this->createMock('\OCP\Comments\ICommentsManager');
$this->userManager = $this->createMock('\OCP\IUserManager');
$this->userSession = $this->createMock('\OCP\IUserSession');
$this->logger = $this->createMock('\OCP\ILogger');

$this->collection = new \OCA\DAV\Comments\EntityCollection(
'19',
Expand All @@ -61,7 +61,7 @@ public function testGetChild() {
$this->commentsManager->expects($this->once())
->method('get')
->with('55')
->will($this->returnValue($this->getMock('\OCP\Comments\IComment')));
->will($this->returnValue($this->createMock('\OCP\Comments\IComment')));

$node = $this->collection->getChild('55');
$this->assertTrue($node instanceof \OCA\DAV\Comments\CommentNode);
Expand All @@ -83,7 +83,7 @@ public function testGetChildren() {
$this->commentsManager->expects($this->once())
->method('getForObject')
->with('files', '19')
->will($this->returnValue([$this->getMock('\OCP\Comments\IComment')]));
->will($this->returnValue([$this->createMock('\OCP\Comments\IComment')]));

$result = $this->collection->getChildren();

Expand All @@ -96,7 +96,7 @@ public function testFindChildren() {
$this->commentsManager->expects($this->once())
->method('getForObject')
->with('files', '19', 5, 15, $dt)
->will($this->returnValue([$this->getMock('\OCP\Comments\IComment')]));
->will($this->returnValue([$this->createMock('\OCP\Comments\IComment')]));

$result = $this->collection->findChildren(5, 15, $dt);

Expand Down
8 changes: 4 additions & 4 deletions apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php
Expand Up @@ -42,10 +42,10 @@ class EntityTypeCollectionTest extends \Test\TestCase {
public function setUp() {
parent::setUp();

$this->commentsManager = $this->getMock('\OCP\Comments\ICommentsManager');
$this->userManager = $this->getMock('\OCP\IUserManager');
$this->userSession = $this->getMock('\OCP\IUserSession');
$this->logger = $this->getMock('\OCP\ILogger');
$this->commentsManager = $this->createMock('\OCP\Comments\ICommentsManager');
$this->userManager = $this->createMock('\OCP\IUserManager');
$this->userSession = $this->createMock('\OCP\IUserSession');
$this->logger = $this->createMock('\OCP\ILogger');

$instance = $this;

Expand Down
10 changes: 5 additions & 5 deletions apps/dav/tests/unit/Comments/RootCollectionTest.php
Expand Up @@ -46,13 +46,13 @@ class RootCollectionTest extends \Test\TestCase {
public function setUp() {
parent::setUp();

$this->user = $this->getMock('\OCP\IUser');
$this->user = $this->createMock('\OCP\IUser');

$this->commentsManager = $this->getMock('\OCP\Comments\ICommentsManager');
$this->userManager = $this->getMock('\OCP\IUserManager');
$this->userSession = $this->getMock('\OCP\IUserSession');
$this->commentsManager = $this->createMock('\OCP\Comments\ICommentsManager');
$this->userManager = $this->createMock('\OCP\IUserManager');
$this->userSession = $this->createMock('\OCP\IUserSession');
$this->dispatcher = new EventDispatcher();
$this->logger = $this->getMock('\OCP\ILogger');
$this->logger = $this->createMock('\OCP\ILogger');

$this->collection = new \OCA\DAV\Comments\RootCollection(
$this->commentsManager,
Expand Down
18 changes: 9 additions & 9 deletions apps/dav/tests/unit/Connector/PublicAuthTest.php
Expand Up @@ -52,9 +52,9 @@ class PublicAuthTest extends \Test\TestCase {
protected function setUp() {
parent::setUp();

$this->session = $this->getMock('\OCP\ISession');
$this->request = $this->getMock('\OCP\IRequest');
$this->shareManager = $this->getMock('\OCP\Share\IManager');
$this->session = $this->createMock('\OCP\ISession');
$this->request = $this->createMock('\OCP\IRequest');
$this->shareManager = $this->createMock('\OCP\Share\IManager');

$this->auth = new \OCA\DAV\Connector\PublicAuth(
$this->request,
Expand Down Expand Up @@ -87,7 +87,7 @@ public function testNoShare() {
}

public function testShareNoPassword() {
$share = $this->getMock('OCP\Share\IShare');
$share = $this->createMock('OCP\Share\IShare');
$share->method('getPassword')->willReturn(null);

$this->shareManager->expects($this->once())
Expand All @@ -100,7 +100,7 @@ public function testShareNoPassword() {
}

public function testSharePasswordFancyShareType() {
$share = $this->getMock('OCP\Share\IShare');
$share = $this->createMock('OCP\Share\IShare');
$share->method('getPassword')->willReturn('password');
$share->method('getShareType')->willReturn(42);

Expand All @@ -115,7 +115,7 @@ public function testSharePasswordFancyShareType() {


public function testSharePasswordRemote() {
$share = $this->getMock('OCP\Share\IShare');
$share = $this->createMock('OCP\Share\IShare');
$share->method('getPassword')->willReturn('password');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_REMOTE);

Expand All @@ -129,7 +129,7 @@ public function testSharePasswordRemote() {
}

public function testSharePasswordLinkValidPassword() {
$share = $this->getMock('OCP\Share\IShare');
$share = $this->createMock('OCP\Share\IShare');
$share->method('getPassword')->willReturn('password');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);

Expand All @@ -149,7 +149,7 @@ public function testSharePasswordLinkValidPassword() {
}

public function testSharePasswordLinkValidSession() {
$share = $this->getMock('OCP\Share\IShare');
$share = $this->createMock('OCP\Share\IShare');
$share->method('getPassword')->willReturn('password');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
$share->method('getId')->willReturn('42');
Expand All @@ -173,7 +173,7 @@ public function testSharePasswordLinkValidSession() {
}

public function testSharePasswordLinkInvalidSession() {
$share = $this->getMock('OCP\Share\IShare');
$share = $this->createMock('OCP\Share\IShare');
$share->method('getPassword')->willReturn('password');
$share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_LINK);
$share->method('getId')->willReturn('42');
Expand Down
2 changes: 1 addition & 1 deletion apps/dav/tests/unit/Connector/Sabre/AuthTest.php
Expand Up @@ -586,7 +586,7 @@ public function testAuthenticateNoBasicAuthenticateHeadersProvidedWithAjaxButUse
->disableOriginalConstructor()
->getMock();
/** @var IUser */
$user = $this->getMock('OCP\IUser');
$user = $this->createMock('OCP\IUser');
$user->method('getUID')->willReturn('MyTestUser');
$this->userSession
->expects($this->any())
Expand Down

0 comments on commit 80a2bcc

Please sign in to comment.