diff options
Diffstat (limited to 'apps/dav/tests/unit/Command/ListCalendarsTest.php')
-rw-r--r-- | apps/dav/tests/unit/Command/ListCalendarsTest.php | 59 |
1 files changed, 16 insertions, 43 deletions
diff --git a/apps/dav/tests/unit/Command/ListCalendarsTest.php b/apps/dav/tests/unit/Command/ListCalendarsTest.php index c98365e25fb..d398a7c772f 100644 --- a/apps/dav/tests/unit/Command/ListCalendarsTest.php +++ b/apps/dav/tests/unit/Command/ListCalendarsTest.php @@ -1,36 +1,17 @@ <?php + +declare(strict_types=1); /** - * - * - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Georg Ehrke <oc.list@georgehrke.com> - * @author Morris Jobke <hey@morrisjobke.de> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * @author Thomas Citharel <nextcloud@tcit.fr> - * - * @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: 2016 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ - -namespace OCA\DAV\Tests\Command; +namespace OCA\DAV\Tests\unit\Command; use OCA\DAV\CalDAV\BirthdayService; use OCA\DAV\CalDAV\CalDavBackend; use OCA\DAV\Command\ListCalendars; use OCP\IUserManager; +use PHPUnit\Framework\MockObject\MockObject; use Symfony\Component\Console\Tester\CommandTester; use Test\TestCase; @@ -40,15 +21,9 @@ use Test\TestCase; * @package OCA\DAV\Tests\Command */ class ListCalendarsTest extends TestCase { - - /** @var \OCP\IUserManager|\PHPUnit\Framework\MockObject\MockObject $userManager */ - private $userManager; - - /** @var CalDavBackend|\PHPUnit\Framework\MockObject\MockObject $l10n */ - private $calDav; - - /** @var ListCalendars */ - private $command; + private IUserManager&MockObject $userManager; + private CalDavBackend&MockObject $calDav; + private ListCalendars $command; public const USERNAME = 'username'; @@ -64,7 +39,7 @@ class ListCalendarsTest extends TestCase { ); } - public function testWithBadUser() { + public function testWithBadUser(): void { $this->expectException(\InvalidArgumentException::class); $this->userManager->expects($this->once()) @@ -76,10 +51,10 @@ class ListCalendarsTest extends TestCase { $commandTester->execute([ 'uid' => self::USERNAME, ]); - $this->assertStringContainsString("User <" . self::USERNAME . "> in unknown", $commandTester->getDisplay()); + $this->assertStringContainsString('User <' . self::USERNAME . '> in unknown', $commandTester->getDisplay()); } - public function testWithCorrectUserWithNoCalendars() { + public function testWithCorrectUserWithNoCalendars(): void { $this->userManager->expects($this->once()) ->method('userExists') ->with(self::USERNAME) @@ -94,20 +69,18 @@ class ListCalendarsTest extends TestCase { $commandTester->execute([ 'uid' => self::USERNAME, ]); - $this->assertStringContainsString("User <" . self::USERNAME . "> has no calendars\n", $commandTester->getDisplay()); + $this->assertStringContainsString('User <' . self::USERNAME . "> has no calendars\n", $commandTester->getDisplay()); } - public function dataExecute() { + public static function dataExecute(): array { return [ [false, '✓'], [true, 'x'] ]; } - /** - * @dataProvider dataExecute - */ - public function testWithCorrectUser(bool $readOnly, string $output) { + #[\PHPUnit\Framework\Attributes\DataProvider('dataExecute')] + public function testWithCorrectUser(bool $readOnly, string $output): void { $this->userManager->expects($this->once()) ->method('userExists') ->with(self::USERNAME) |