diff options
Diffstat (limited to 'tests/lib/Contacts/ContactsMenu/ManagerTest.php')
-rw-r--r-- | tests/lib/Contacts/ContactsMenu/ManagerTest.php | 62 |
1 files changed, 21 insertions, 41 deletions
diff --git a/tests/lib/Contacts/ContactsMenu/ManagerTest.php b/tests/lib/Contacts/ContactsMenu/ManagerTest.php index eb776a6e39d..dd6c634c740 100644 --- a/tests/lib/Contacts/ContactsMenu/ManagerTest.php +++ b/tests/lib/Contacts/ContactsMenu/ManagerTest.php @@ -1,35 +1,18 @@ <?php /** - * @copyright 2017 Christoph Wurst <christoph@winzerhof-wurst.at> - * - * @author 2017 Christoph Wurst <christoph@winzerhof-wurst.at> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ namespace Tests\Contacts\ContactsMenu; use OC\Contacts\ContactsMenu\ActionProviderStore; use OC\Contacts\ContactsMenu\ContactsStore; +use OC\Contacts\ContactsMenu\Entry; use OC\Contacts\ContactsMenu\Manager; use OCP\App\IAppManager; use OCP\Constants; -use OCP\Contacts\ContactsMenu\IEntry; use OCP\Contacts\ContactsMenu\IProvider; use OCP\IConfig; use OCP\IUser; @@ -65,7 +48,7 @@ class ManagerTest extends TestCase { private function generateTestEntries(): array { $entries = []; foreach (range('Z', 'A') as $char) { - $entry = $this->createMock(IEntry::class); + $entry = $this->createMock(Entry::class); $entry->expects($this->any()) ->method('getFullName') ->willReturn('Contact ' . $char); @@ -74,7 +57,7 @@ class ManagerTest extends TestCase { return $entries; } - public function testGetFilteredEntries() { + public function testGetFilteredEntries(): void { $filter = 'con'; $user = $this->createMock(IUser::class); $entries = $this->generateTestEntries(); @@ -82,11 +65,10 @@ class ManagerTest extends TestCase { $this->config->expects($this->exactly(2)) ->method('getSystemValueInt') - ->withConsecutive( - ['sharing.maxAutocompleteResults', Constants::SHARING_MAX_AUTOCOMPLETE_RESULTS_DEFAULT], - ['sharing.minSearchStringLength', 0] - ) - ->willReturnOnConsecutiveCalls(25, 0); + ->willReturnMap([ + ['sharing.maxAutocompleteResults', Constants::SHARING_MAX_AUTOCOMPLETE_RESULTS_DEFAULT, 25], + ['sharing.minSearchStringLength', 0, 0], + ]); $this->contactsStore->expects($this->once()) ->method('getContacts') ->with($user, $filter) @@ -111,7 +93,7 @@ class ManagerTest extends TestCase { $this->assertEquals($expected, $data); } - public function testGetFilteredEntriesLimit() { + public function testGetFilteredEntriesLimit(): void { $filter = 'con'; $user = $this->createMock(IUser::class); $entries = $this->generateTestEntries(); @@ -119,11 +101,10 @@ class ManagerTest extends TestCase { $this->config->expects($this->exactly(2)) ->method('getSystemValueInt') - ->withConsecutive( - ['sharing.maxAutocompleteResults', Constants::SHARING_MAX_AUTOCOMPLETE_RESULTS_DEFAULT], - ['sharing.minSearchStringLength', 0] - ) - ->willReturnOnConsecutiveCalls(3, 0); + ->willReturnMap([ + ['sharing.maxAutocompleteResults', Constants::SHARING_MAX_AUTOCOMPLETE_RESULTS_DEFAULT, 3], + ['sharing.minSearchStringLength', 0, 0], + ]); $this->contactsStore->expects($this->once()) ->method('getContacts') ->with($user, $filter) @@ -148,18 +129,17 @@ class ManagerTest extends TestCase { $this->assertEquals($expected, $data); } - public function testGetFilteredEntriesMinSearchStringLength() { + public function testGetFilteredEntriesMinSearchStringLength(): void { $filter = 'con'; $user = $this->createMock(IUser::class); $provider = $this->createMock(IProvider::class); $this->config->expects($this->exactly(2)) ->method('getSystemValueInt') - ->withConsecutive( - ['sharing.maxAutocompleteResults', Constants::SHARING_MAX_AUTOCOMPLETE_RESULTS_DEFAULT], - ['sharing.minSearchStringLength', 0] - ) - ->willReturnOnConsecutiveCalls(3, 4); + ->willReturnMap([ + ['sharing.maxAutocompleteResults', Constants::SHARING_MAX_AUTOCOMPLETE_RESULTS_DEFAULT, 3], + ['sharing.minSearchStringLength', 0, 4], + ]); $this->appManager->expects($this->once()) ->method('isEnabledForUser') ->with($this->equalTo('contacts'), $user) @@ -174,7 +154,7 @@ class ManagerTest extends TestCase { $this->assertEquals($expected, $data); } - public function testFindOne() { + public function testFindOne(): void { $shareTypeFilter = 42; $shareWithFilter = 'foobar'; @@ -197,7 +177,7 @@ class ManagerTest extends TestCase { $this->assertEquals($entry, $data); } - public function testFindOne404() { + public function testFindOne404(): void { $shareTypeFilter = 42; $shareWithFilter = 'foobar'; |