aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/tests/unit/DAV
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-03-25 22:21:27 +0100
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-03-25 22:21:27 +0100
commit2ee65f177e4f7e09ad2287f14d564e7068d322fb (patch)
tree39075e87ea7927e20e8956824cb7c49bf626b178 /apps/dav/tests/unit/DAV
parent3cf321fdfc4235a87015a9af2f59c63220016c65 (diff)
downloadnextcloud-server-2ee65f177e4f7e09ad2287f14d564e7068d322fb.tar.gz
nextcloud-server-2ee65f177e4f7e09ad2287f14d564e7068d322fb.zip
Use the shorter phpunit syntax for mocked return values
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'apps/dav/tests/unit/DAV')
-rw-r--r--apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php14
-rw-r--r--apps/dav/tests/unit/DAV/GroupPrincipalTest.php40
-rw-r--r--apps/dav/tests/unit/DAV/HookManagerTest.php4
3 files changed, 29 insertions, 29 deletions
diff --git a/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php b/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php
index 45aab9af1f5..28af0715ea1 100644
--- a/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php
+++ b/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php
@@ -59,7 +59,7 @@ class CustomPropertiesBackendTest extends TestCase {
$this->user = $this->createMock(IUser::class);
$this->user->method('getUID')
->with()
- ->will($this->returnValue('dummy_user_42'));
+ ->willReturn('dummy_user_42');
$this->dbConnection = \OC::$server->getDatabaseConnection();
$this->backend = new CustomPropertiesBackend(
@@ -125,12 +125,12 @@ class CustomPropertiesBackendTest extends TestCase {
$propFind->expects($this->at(0))
->method('get404Properties')
->with()
- ->will($this->returnValue([
+ ->willReturn([
'{http://owncloud.org/ns}permissions',
'{http://owncloud.org/ns}downloadURL',
'{http://owncloud.org/ns}dDC',
'{http://owncloud.org/ns}size',
- ]));
+ ]);
$db->expects($this->never())
->method($this->anything());
@@ -142,16 +142,16 @@ class CustomPropertiesBackendTest extends TestCase {
$propFind = $this->createMock(PropFind::class);
$propFind->method('get404Properties')
->with()
- ->will($this->returnValue([
+ ->willReturn([
'{DAV:}getcontentlength',
'{DAV:}getcontenttype',
'{DAV:}getetag',
'{abc}def',
- ]));
+ ]);
$propFind->method('getRequestedProperties')
->with()
- ->will($this->returnValue([
+ ->willReturn([
'{DAV:}getcontentlength',
'{DAV:}getcontenttype',
'{DAV:}getetag',
@@ -159,7 +159,7 @@ class CustomPropertiesBackendTest extends TestCase {
'{urn:ietf:params:xml:ns:caldav}calendar-description',
'{urn:ietf:params:xml:ns:caldav}calendar-timezone',
'{abc}def',
- ]));
+ ]);
$props = [
'{abc}def' => 'a',
diff --git a/apps/dav/tests/unit/DAV/GroupPrincipalTest.php b/apps/dav/tests/unit/DAV/GroupPrincipalTest.php
index e60c2619303..08239dfd46a 100644
--- a/apps/dav/tests/unit/DAV/GroupPrincipalTest.php
+++ b/apps/dav/tests/unit/DAV/GroupPrincipalTest.php
@@ -74,7 +74,7 @@ class GroupPrincipalTest extends \Test\TestCase {
->expects($this->once())
->method('search')
->with('')
- ->will($this->returnValue([$group1, $group2]));
+ ->willReturn([$group1, $group2]);
$expectedResponse = [
0 => [
@@ -97,7 +97,7 @@ class GroupPrincipalTest extends \Test\TestCase {
->expects($this->once())
->method('search')
->with('')
- ->will($this->returnValue([]));
+ ->willReturn([]);
$response = $this->connector->getPrincipalsByPrefix('principals/groups');
$this->assertSame([], $response);
@@ -109,7 +109,7 @@ class GroupPrincipalTest extends \Test\TestCase {
->expects($this->once())
->method('get')
->with('foo')
- ->will($this->returnValue($group1));
+ ->willReturn($group1);
$expectedResponse = [
'uri' => 'principals/groups/foo',
@@ -126,7 +126,7 @@ class GroupPrincipalTest extends \Test\TestCase {
->expects($this->once())
->method('get')
->with('foo')
- ->will($this->returnValue($fooUser));
+ ->willReturn($fooUser);
$expectedResponse = [
'uri' => 'principals/groups/foo',
@@ -142,7 +142,7 @@ class GroupPrincipalTest extends \Test\TestCase {
->expects($this->once())
->method('get')
->with('foo')
- ->will($this->returnValue(null));
+ ->willReturn(null);
$response = $this->connector->getPrincipalByPath('principals/groups/foo');
$this->assertSame(null, $response);
@@ -154,7 +154,7 @@ class GroupPrincipalTest extends \Test\TestCase {
->expects($this->once())
->method('get')
->with('foo/bar')
- ->will($this->returnValue($group1));
+ ->willReturn($group1);
$expectedResponse = [
'uri' => 'principals/groups/foo%2Fbar',
@@ -202,23 +202,23 @@ class GroupPrincipalTest extends \Test\TestCase {
public function testSearchPrincipals($sharingEnabled, $groupsOnly, $test, $result) {
$this->shareManager->expects($this->once())
->method('shareAPIEnabled')
- ->will($this->returnValue($sharingEnabled));
+ ->willReturn($sharingEnabled);
if ($sharingEnabled) {
$this->shareManager->expects($this->once())
->method('shareWithGroupMembersOnly')
- ->will($this->returnValue($groupsOnly));
+ ->willReturn($groupsOnly);
if ($groupsOnly) {
$user = $this->createMock(IUser::class);
$this->userSession->expects($this->once())
->method('getUser')
- ->will($this->returnValue($user));
+ ->willReturn($user);
$this->groupManager->expects($this->once())
->method('getUserGroupIds')
->with($user)
- ->will($this->returnValue(['group1', 'group2', 'group5']));
+ ->willReturn(['group1', 'group2', 'group5']);
}
} else {
$this->shareManager->expects($this->never())
@@ -228,21 +228,21 @@ class GroupPrincipalTest extends \Test\TestCase {
}
$group1 = $this->createMock(IGroup::class);
- $group1->method('getGID')->will($this->returnValue('group1'));
+ $group1->method('getGID')->willReturn('group1');
$group2 = $this->createMock(IGroup::class);
- $group2->method('getGID')->will($this->returnValue('group2'));
+ $group2->method('getGID')->willReturn('group2');
$group3 = $this->createMock(IGroup::class);
- $group3->method('getGID')->will($this->returnValue('group3'));
+ $group3->method('getGID')->willReturn('group3');
$group4 = $this->createMock(IGroup::class);
- $group4->method('getGID')->will($this->returnValue('group4'));
+ $group4->method('getGID')->willReturn('group4');
$group5 = $this->createMock(IGroup::class);
- $group5->method('getGID')->will($this->returnValue('group5'));
+ $group5->method('getGID')->willReturn('group5');
if ($sharingEnabled) {
$this->groupManager->expects($this->once())
->method('search')
->with('Foo')
- ->will($this->returnValue([$group1, $group2, $group3, $group4, $group5]));
+ ->willReturn([$group1, $group2, $group3, $group4, $group5]);
} else {
$this->groupManager->expects($this->never())
->method('search');
@@ -269,23 +269,23 @@ class GroupPrincipalTest extends \Test\TestCase {
public function testFindByUri($sharingEnabled, $groupsOnly, $findUri, $result) {
$this->shareManager->expects($this->once())
->method('shareAPIEnabled')
- ->will($this->returnValue($sharingEnabled));
+ ->willReturn($sharingEnabled);
if ($sharingEnabled) {
$this->shareManager->expects($this->once())
->method('shareWithGroupMembersOnly')
- ->will($this->returnValue($groupsOnly));
+ ->willReturn($groupsOnly);
if ($groupsOnly) {
$user = $this->createMock(IUser::class);
$this->userSession->expects($this->once())
->method('getUser')
- ->will($this->returnValue($user));
+ ->willReturn($user);
$this->groupManager->expects($this->at(0))
->method('getUserGroupIds')
->with($user)
- ->will($this->returnValue(['group1', 'group2', 'group5']));
+ ->willReturn(['group1', 'group2', 'group5']);
}
} else {
$this->shareManager->expects($this->never())
diff --git a/apps/dav/tests/unit/DAV/HookManagerTest.php b/apps/dav/tests/unit/DAV/HookManagerTest.php
index ab95008585b..7b3388b9e74 100644
--- a/apps/dav/tests/unit/DAV/HookManagerTest.php
+++ b/apps/dav/tests/unit/DAV/HookManagerTest.php
@@ -54,9 +54,9 @@ class HookManagerTest extends TestCase {
$this->l10n
->expects($this->any())
->method('t')
- ->will($this->returnCallback(function ($text, $parameters = []) {
+ ->willReturnCallback(function ($text, $parameters = []) {
return vsprintf($text, $parameters);
- }));
+ });
}
public function test() {