Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-03-26 00:21:27 +0300
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-03-26 00:21:27 +0300
commit2ee65f177e4f7e09ad2287f14d564e7068d322fb (patch)
tree39075e87ea7927e20e8956824cb7c49bf626b178 /tests/lib/App
parent3cf321fdfc4235a87015a9af2f59c63220016c65 (diff)
Use the shorter phpunit syntax for mocked return values
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests/lib/App')
-rw-r--r--tests/lib/App/AppManagerTest.php32
-rw-r--r--tests/lib/App/AppStore/Bundles/BundleBase.php4
-rw-r--r--tests/lib/App/AppStore/Fetcher/AppFetcherTest.php8
-rw-r--r--tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php8
-rw-r--r--tests/lib/App/DependencyAnalyzerTest.php22
5 files changed, 37 insertions, 37 deletions
diff --git a/tests/lib/App/AppManagerTest.php b/tests/lib/App/AppManagerTest.php
index 0e895b5f999..50c1e13b3f9 100644
--- a/tests/lib/App/AppManagerTest.php
+++ b/tests/lib/App/AppManagerTest.php
@@ -40,20 +40,20 @@ class AppManagerTest extends TestCase {
$config->expects($this->any())
->method('getValue')
- ->will($this->returnCallback(function ($app, $key, $default) use (&$appConfig) {
+ ->willReturnCallback(function ($app, $key, $default) use (&$appConfig) {
return (isset($appConfig[$app]) and isset($appConfig[$app][$key])) ? $appConfig[$app][$key] : $default;
- }));
+ });
$config->expects($this->any())
->method('setValue')
- ->will($this->returnCallback(function ($app, $key, $value) use (&$appConfig) {
+ ->willReturnCallback(function ($app, $key, $value) use (&$appConfig) {
if (!isset($appConfig[$app])) {
$appConfig[$app] = array();
}
$appConfig[$app][$key] = $value;
- }));
+ });
$config->expects($this->any())
->method('getValues')
- ->will($this->returnCallback(function ($app, $key) use (&$appConfig) {
+ ->willReturnCallback(function ($app, $key) use (&$appConfig) {
if ($app) {
return $appConfig[$app];
} else {
@@ -65,7 +65,7 @@ class AppManagerTest extends TestCase {
}
return $values;
}
- }));
+ });
return $config;
}
@@ -346,7 +346,7 @@ class AppManagerTest extends TestCase {
$this->groupManager->expects($this->once())
->method('getUserGroupIds')
->with($user)
- ->will($this->returnValue(array('foo', 'bar')));
+ ->willReturn(array('foo', 'bar'));
$this->appConfig->setValue('test', 'enabled', '["foo"]');
$this->assertTrue($this->manager->isEnabledForUser('test', $user));
@@ -357,7 +357,7 @@ class AppManagerTest extends TestCase {
$this->groupManager->expects($this->once())
->method('getUserGroupIds')
->with($user)
- ->will($this->returnValue(array('bar')));
+ ->willReturn(array('bar'));
$this->appConfig->setValue('test', 'enabled', '["foo"]');
$this->assertFalse($this->manager->isEnabledForUser('test', $user));
@@ -373,11 +373,11 @@ class AppManagerTest extends TestCase {
$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(array('foo', 'bar')));
+ ->willReturn(array('foo', 'bar'));
$this->appConfig->setValue('test', 'enabled', '["foo"]');
$this->assertTrue($this->manager->isEnabledForUser('test'));
@@ -410,7 +410,7 @@ class AppManagerTest extends TestCase {
$this->groupManager->expects($this->any())
->method('getUserGroupIds')
->with($user)
- ->will($this->returnValue(array('foo', 'bar')));
+ ->willReturn(array('foo', 'bar'));
$this->appConfig->setValue('test1', 'enabled', 'yes');
$this->appConfig->setValue('test2', 'enabled', 'no');
@@ -462,11 +462,11 @@ class AppManagerTest extends TestCase {
$manager->expects($this->any())
->method('getAppInfo')
- ->will($this->returnCallback(
+ ->willReturnCallback(
function($appId) use ($appInfos) {
return $appInfos[$appId];
}
- ));
+ );
$this->appConfig->setValue('test1', 'enabled', 'yes');
$this->appConfig->setValue('test1', 'installed_version', '1.0.0');
@@ -511,11 +511,11 @@ class AppManagerTest extends TestCase {
$manager->expects($this->any())
->method('getAppInfo')
- ->will($this->returnCallback(
+ ->willReturnCallback(
function($appId) use ($appInfos) {
return $appInfos[$appId];
}
- ));
+ );
$this->appConfig->setValue('test1', 'enabled', 'yes');
$this->appConfig->setValue('test2', 'enabled', 'yes');
@@ -532,7 +532,7 @@ class AppManagerTest extends TestCase {
$group = $this->createMock(IGroup::class);
$group->expects($this->any())
->method('getGID')
- ->will($this->returnValue('foo'));
+ ->willReturn('foo');
$this->appConfig->setValue('test1', 'enabled', 'yes');
$this->appConfig->setValue('test2', 'enabled', 'no');
diff --git a/tests/lib/App/AppStore/Bundles/BundleBase.php b/tests/lib/App/AppStore/Bundles/BundleBase.php
index 2c566b0ea0a..dc7e1920896 100644
--- a/tests/lib/App/AppStore/Bundles/BundleBase.php
+++ b/tests/lib/App/AppStore/Bundles/BundleBase.php
@@ -41,9 +41,9 @@ abstract class BundleBase extends TestCase {
parent::setUp();
$this->l10n = $this->createMock(IL10N::class);
$this->l10n->method('t')
- ->will($this->returnCallback(function ($text, $parameters = []) {
+ ->willReturnCallback(function ($text, $parameters = []) {
return vsprintf($text, $parameters);
- }));
+ });
}
public function testGetIdentifier() {
diff --git a/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php b/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php
index 38e813dc251..30d1fec6c9e 100644
--- a/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php
+++ b/tests/lib/App/AppStore/Fetcher/AppFetcherTest.php
@@ -1946,14 +1946,14 @@ EJL3BaQAQaASSsvFrcozYxrQG4VzEg==
public function testAppstoreDisabled() {
$this->config
->method('getSystemValue')
- ->will($this->returnCallback(function($var, $default) {
+ ->willReturnCallback(function($var, $default) {
if ($var === 'appstoreenabled') {
return false;
} else if ($var === 'version') {
return '11.0.0.2';
}
return $default;
- }));
+ });
$this->appData
->expects($this->never())
->method('getFolder');
@@ -1965,14 +1965,14 @@ EJL3BaQAQaASSsvFrcozYxrQG4VzEg==
public function testNoInternet() {
$this->config
->method('getSystemValue')
- ->will($this->returnCallback(function($var, $default) {
+ ->willReturnCallback(function($var, $default) {
if ($var === 'has_internet_connection') {
return false;
} else if ($var === 'version') {
return '11.0.0.2';
}
return $default;
- }));
+ });
$this->appData
->expects($this->never())
->method('getFolder');
diff --git a/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php b/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php
index 8a82322b61c..22e7a8742ec 100644
--- a/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php
+++ b/tests/lib/App/AppStore/Fetcher/CategoryFetcherTest.php
@@ -41,12 +41,12 @@ class CategoryFetcherTest extends FetcherBase {
public function testAppstoreDisabled() {
$this->config
->method('getSystemValue')
- ->will($this->returnCallback(function($var, $default) {
+ ->willReturnCallback(function($var, $default) {
if ($var === 'appstoreenabled') {
return false;
}
return $default;
- }));
+ });
$this->appData
->expects($this->never())
->method('getFolder');
@@ -57,12 +57,12 @@ class CategoryFetcherTest extends FetcherBase {
public function testNoInternet() {
$this->config
->method('getSystemValue')
- ->will($this->returnCallback(function($var, $default) {
+ ->willReturnCallback(function($var, $default) {
if ($var === 'has_internet_connection') {
return false;
}
return $default;
- }));
+ });
$this->appData
->expects($this->never())
->method('getFolder');
diff --git a/tests/lib/App/DependencyAnalyzerTest.php b/tests/lib/App/DependencyAnalyzerTest.php
index 943b53eee64..8312bef5b98 100644
--- a/tests/lib/App/DependencyAnalyzerTest.php
+++ b/tests/lib/App/DependencyAnalyzerTest.php
@@ -32,41 +32,41 @@ class DependencyAnalyzerTest extends TestCase {
->getMock();
$this->platformMock->expects($this->any())
->method('getPhpVersion')
- ->will( $this->returnValue('5.4.3'));
+ ->willReturn( '5.4.3');
$this->platformMock->expects($this->any())
->method('getIntSize')
- ->will( $this->returnValue('4'));
+ ->willReturn( '4');
$this->platformMock->expects($this->any())
->method('getDatabase')
- ->will( $this->returnValue('mysql'));
+ ->willReturn( 'mysql');
$this->platformMock->expects($this->any())
->method('getOS')
- ->will( $this->returnValue('Linux'));
+ ->willReturn( 'Linux');
$this->platformMock->expects($this->any())
->method('isCommandKnown')
- ->will( $this->returnCallback(function($command) {
+ ->willReturnCallback( function($command) {
return ($command === 'grep');
- }));
+ });
$this->platformMock->expects($this->any())
->method('getLibraryVersion')
- ->will( $this->returnCallback(function($lib) {
+ ->willReturnCallback( function($lib) {
if ($lib === 'curl') {
return "2.3.4";
}
return null;
- }));
+ });
$this->platformMock->expects($this->any())
->method('getOcVersion')
- ->will( $this->returnValue('8.0.2'));
+ ->willReturn( '8.0.2');
$this->l10nMock = $this->getMockBuilder(IL10N::class)
->disableOriginalConstructor()
->getMock();
$this->l10nMock->expects($this->any())
->method('t')
- ->will($this->returnCallback(function($text, $parameters = array()) {
+ ->willReturnCallback(function($text, $parameters = array()) {
return vsprintf($text, $parameters);
- }));
+ });
$this->analyser = new DependencyAnalyzer($this->platformMock, $this->l10nMock);
}