diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-03-25 22:21:27 +0100 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-03-25 22:21:27 +0100 |
commit | 2ee65f177e4f7e09ad2287f14d564e7068d322fb (patch) | |
tree | 39075e87ea7927e20e8956824cb7c49bf626b178 /apps/files/tests | |
parent | 3cf321fdfc4235a87015a9af2f59c63220016c65 (diff) | |
download | nextcloud-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/files/tests')
-rw-r--r-- | apps/files/tests/BackgroundJob/ScanFilesTest.php | 24 | ||||
-rw-r--r-- | apps/files/tests/Controller/ApiControllerTest.php | 4 | ||||
-rw-r--r-- | apps/files/tests/Controller/ViewControllerTest.php | 62 | ||||
-rw-r--r-- | apps/files/tests/Service/TagServiceTest.php | 2 |
4 files changed, 46 insertions, 46 deletions
diff --git a/apps/files/tests/BackgroundJob/ScanFilesTest.php b/apps/files/tests/BackgroundJob/ScanFilesTest.php index 82f69df3ddc..5686fbc749c 100644 --- a/apps/files/tests/BackgroundJob/ScanFilesTest.php +++ b/apps/files/tests/BackgroundJob/ScanFilesTest.php @@ -63,22 +63,22 @@ class ScanFilesTest extends TestCase { ->expects($this->at(0)) ->method('getSystemValueBool') ->with('files_no_background_scan', false) - ->will($this->returnValue(false)); + ->willReturn(false); $this->config ->expects($this->at(1)) ->method('getAppValue') ->with('files', 'cronjob_scan_files', 0) - ->will($this->returnValue(50)); + ->willReturn(50); $this->userManager ->expects($this->at(0)) ->method('search') ->with('', 500, 50) - ->will($this->returnValue([])); + ->willReturn([]); $this->userManager ->expects($this->at(1)) ->method('search') ->with('', 500) - ->will($this->returnValue([])); + ->willReturn([]); $this->config ->expects($this->at(2)) ->method('setAppValue') @@ -93,19 +93,19 @@ class ScanFilesTest extends TestCase { ->expects($this->at(0)) ->method('getSystemValueBool') ->with('files_no_background_scan', false) - ->will($this->returnValue(false)); + ->willReturn(false); $this->config ->expects($this->at(1)) ->method('getAppValue') ->with('files', 'cronjob_scan_files', 0) - ->will($this->returnValue(50)); + ->willReturn(50); $this->userManager ->expects($this->at(0)) ->method('search') ->with('', 500, 50) - ->will($this->returnValue([ + ->willReturn([ $fakeUser - ])); + ]); $this->config ->expects($this->at(2)) ->method('setAppValue') @@ -123,22 +123,22 @@ class ScanFilesTest extends TestCase { ->expects($this->at(0)) ->method('getSystemValueBool') ->with('files_no_background_scan', false) - ->will($this->returnValue(false)); + ->willReturn(false); $this->config ->expects($this->at(1)) ->method('getAppValue') ->with('files', 'cronjob_scan_files', 0) - ->will($this->returnValue(50)); + ->willReturn(50); $this->userManager ->expects($this->at(0)) ->method('search') ->with('', 500, 50) - ->will($this->returnValue([])); + ->willReturn([]); $this->userManager ->expects($this->at(1)) ->method('search') ->with('', 500) - ->will($this->returnValue([])); + ->willReturn([]); $this->config ->expects($this->at(2)) ->method('setAppValue') diff --git a/apps/files/tests/Controller/ApiControllerTest.php b/apps/files/tests/Controller/ApiControllerTest.php index 8b2a763ec52..b35d9d7b95d 100644 --- a/apps/files/tests/Controller/ApiControllerTest.php +++ b/apps/files/tests/Controller/ApiControllerTest.php @@ -77,11 +77,11 @@ class ApiControllerTest extends TestCase { $this->user = $this->createMock(IUser::class); $this->user->expects($this->any()) ->method('getUID') - ->will($this->returnValue('user1')); + ->willReturn('user1'); $userSession = $this->createMock(IUserSession::class); $userSession->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); $this->tagService = $this->getMockBuilder(TagService::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/files/tests/Controller/ViewControllerTest.php b/apps/files/tests/Controller/ViewControllerTest.php index 3182172acfa..8f2f8fe9ec1 100644 --- a/apps/files/tests/Controller/ViewControllerTest.php +++ b/apps/files/tests/Controller/ViewControllerTest.php @@ -91,10 +91,10 @@ class ViewControllerTest extends TestCase { $this->user = $this->getMockBuilder(IUser::class)->getMock(); $this->user->expects($this->any()) ->method('getUID') - ->will($this->returnValue('testuser1')); + ->willReturn('testuser1'); $this->userSession->expects($this->any()) ->method('getUser') - ->will($this->returnValue($this->user)); + ->willReturn($this->user); $this->rootFolder = $this->getMockBuilder('\OCP\Files\IRootFolder')->getMock(); $this->activityHelper = $this->createMock(Helper::class); $this->viewController = $this->getMockBuilder('\OCA\Files\Controller\ViewController') @@ -121,27 +121,27 @@ class ViewControllerTest extends TestCase { $this->viewController ->expects($this->once()) ->method('getStorageInfo') - ->will($this->returnValue([ + ->willReturn([ 'used' => 123, 'quota' => 100, 'total' => 100, 'relative' => 123, 'owner' => 'MyName', 'ownerDisplayName' => 'MyDisplayName', - ])); + ]); $this->config ->method('getUserValue') - ->will($this->returnValueMap([ + ->willReturnMap([ [$this->user->getUID(), 'files', 'file_sorting', 'name', 'name'], [$this->user->getUID(), 'files', 'file_sorting_direction', 'asc', 'asc'], [$this->user->getUID(), 'files', 'show_hidden', false, false], [$this->user->getUID(), 'files', 'show_grid', true], - ])); + ]); $this->config ->expects($this->any()) ->method('getAppValue') - ->will($this->returnArgument(2)); + ->willReturnArgument(2); $nav = new Template('files', 'appnavigation'); $nav->assign('usage_relative', 123); @@ -409,29 +409,29 @@ class ViewControllerTest extends TestCase { $node = $this->getMockBuilder(Folder::class)->getMock(); $node->expects($this->once()) ->method('getPath') - ->will($this->returnValue('/testuser1/files/test/sub')); + ->willReturn('/testuser1/files/test/sub'); $baseFolder = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') ->with('testuser1') - ->will($this->returnValue($baseFolder)); + ->willReturn($baseFolder); $baseFolder->expects($this->at(0)) ->method('getById') ->with(123) - ->will($this->returnValue([$node])); + ->willReturn([$node]); $baseFolder->expects($this->at(1)) ->method('getRelativePath') ->with('/testuser1/files/test/sub') - ->will($this->returnValue('/test/sub')); + ->willReturn('/test/sub'); $this->urlGenerator ->expects($this->once()) ->method('linkToRoute') ->with('files.view.index', ['dir' => '/test/sub']) - ->will($this->returnValue('/apps/files/?dir=/test/sub')); + ->willReturn('/apps/files/?dir=/test/sub'); $expected = new Http\RedirectResponse('/apps/files/?dir=/test/sub'); $this->assertEquals($expected, $this->viewController->index('/whatever', '', '123')); @@ -441,37 +441,37 @@ class ViewControllerTest extends TestCase { $parentNode = $this->getMockBuilder(Folder::class)->getMock(); $parentNode->expects($this->once()) ->method('getPath') - ->will($this->returnValue('testuser1/files/test')); + ->willReturn('testuser1/files/test'); $baseFolder = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') ->with('testuser1') - ->will($this->returnValue($baseFolder)); + ->willReturn($baseFolder); $node = $this->getMockBuilder(File::class)->getMock(); $node->expects($this->once()) ->method('getParent') - ->will($this->returnValue($parentNode)); + ->willReturn($parentNode); $node->expects($this->once()) ->method('getName') - ->will($this->returnValue('somefile.txt')); + ->willReturn('somefile.txt'); $baseFolder->expects($this->at(0)) ->method('getById') ->with(123) - ->will($this->returnValue([$node])); + ->willReturn([$node]); $baseFolder->expects($this->at(1)) ->method('getRelativePath') ->with('testuser1/files/test') - ->will($this->returnValue('/test')); + ->willReturn('/test'); $this->urlGenerator ->expects($this->once()) ->method('linkToRoute') ->with('files.view.index', ['dir' => '/test', 'scrollto' => 'somefile.txt']) - ->will($this->returnValue('/apps/files/?dir=/test/sub&scrollto=somefile.txt')); + ->willReturn('/apps/files/?dir=/test/sub&scrollto=somefile.txt'); $expected = new Http\RedirectResponse('/apps/files/?dir=/test/sub&scrollto=somefile.txt'); $this->assertEquals($expected, $this->viewController->index('/whatever', '', '123')); @@ -482,12 +482,12 @@ class ViewControllerTest extends TestCase { $this->rootFolder->expects($this->once()) ->method('getUserFolder') ->with('testuser1') - ->will($this->returnValue($baseFolder)); + ->willReturn($baseFolder); $baseFolder->expects($this->at(0)) ->method('getById') ->with(123) - ->will($this->returnValue([])); + ->willReturn([]); $this->urlGenerator->expects($this->once()) ->method('linkToRoute') @@ -503,12 +503,12 @@ class ViewControllerTest extends TestCase { $this->appManager->expects($this->once()) ->method('isEnabledForUser') ->with('files_trashbin') - ->will($this->returnValue(true)); + ->willReturn(true); $parentNode = $this->getMockBuilder(Folder::class)->getMock(); $parentNode->expects($this->once()) ->method('getPath') - ->will($this->returnValue('testuser1/files_trashbin/files/test.d1462861890/sub')); + ->willReturn('testuser1/files_trashbin/files/test.d1462861890/sub'); $baseFolderFiles = $this->getMockBuilder(Folder::class)->getMock(); $baseFolderTrash = $this->getMockBuilder(Folder::class)->getMock(); @@ -516,39 +516,39 @@ class ViewControllerTest extends TestCase { $this->rootFolder->expects($this->at(0)) ->method('getUserFolder') ->with('testuser1') - ->will($this->returnValue($baseFolderFiles)); + ->willReturn($baseFolderFiles); $this->rootFolder->expects($this->at(1)) ->method('get') ->with('testuser1/files_trashbin/files/') - ->will($this->returnValue($baseFolderTrash)); + ->willReturn($baseFolderTrash); $baseFolderFiles->expects($this->once()) ->method('getById') ->with(123) - ->will($this->returnValue([])); + ->willReturn([]); $node = $this->getMockBuilder(File::class)->getMock(); $node->expects($this->once()) ->method('getParent') - ->will($this->returnValue($parentNode)); + ->willReturn($parentNode); $node->expects($this->once()) ->method('getName') - ->will($this->returnValue('somefile.txt')); + ->willReturn('somefile.txt'); $baseFolderTrash->expects($this->at(0)) ->method('getById') ->with(123) - ->will($this->returnValue([$node])); + ->willReturn([$node]); $baseFolderTrash->expects($this->at(1)) ->method('getRelativePath') ->with('testuser1/files_trashbin/files/test.d1462861890/sub') - ->will($this->returnValue('/test.d1462861890/sub')); + ->willReturn('/test.d1462861890/sub'); $this->urlGenerator ->expects($this->once()) ->method('linkToRoute') ->with('files.view.index', ['view' => 'trashbin', 'dir' => '/test.d1462861890/sub', 'scrollto' => 'somefile.txt']) - ->will($this->returnValue('/apps/files/?view=trashbin&dir=/test.d1462861890/sub&scrollto=somefile.txt')); + ->willReturn('/apps/files/?view=trashbin&dir=/test.d1462861890/sub&scrollto=somefile.txt'); $expected = new Http\RedirectResponse('/apps/files/?view=trashbin&dir=/test.d1462861890/sub&scrollto=somefile.txt'); $this->assertEquals($expected, $this->viewController->index('/whatever', '', '123')); diff --git a/apps/files/tests/Service/TagServiceTest.php b/apps/files/tests/Service/TagServiceTest.php index 7366c926b90..bc7c803953b 100644 --- a/apps/files/tests/Service/TagServiceTest.php +++ b/apps/files/tests/Service/TagServiceTest.php @@ -85,7 +85,7 @@ class TagServiceTest extends \Test\TestCase { $this->userSession->expects($this->any()) ->method('getUser') ->withAnyParameters() - ->will($this->returnValue($user)); + ->willReturn($user); $this->root = \OC::$server->getUserFolder(); $this->dispatcher = $this->createMock(EventDispatcherInterface::class); |