diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2019-11-27 15:27:18 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2019-11-27 15:27:18 +0100 |
commit | 3a7cf40aaa678bea1df143d2982d603b7a334eec (patch) | |
tree | 63c1e3ad7f7f401d14411a4d44c523632906afc9 /apps/dav/tests/unit/CalDAV | |
parent | 0568b012672d650c6b5a49e72c4028dde5463c60 (diff) | |
download | nextcloud-server-3a7cf40aaa678bea1df143d2982d603b7a334eec.tar.gz nextcloud-server-3a7cf40aaa678bea1df143d2982d603b7a334eec.zip |
Mode to modern phpunit
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps/dav/tests/unit/CalDAV')
27 files changed, 95 insertions, 91 deletions
diff --git a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php index 3facbeb954d..8772f511486 100644 --- a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php +++ b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php @@ -72,7 +72,7 @@ abstract class AbstractCalDavBackend extends TestCase { const UNIT_TEST_GROUP = 'principals/groups/caldav-unit-test-group'; const UNIT_TEST_GROUP2 = 'principals/groups/caldav-unit-test-group2'; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->userManager = $this->createMock(IUserManager::class); @@ -106,7 +106,7 @@ abstract class AbstractCalDavBackend extends TestCase { $this->cleanUpBackend(); } - public function tearDown(): void { + protected function tearDown(): void { $this->cleanUpBackend(); parent::tearDown(); } diff --git a/apps/dav/tests/unit/CalDAV/Activity/Filter/GenericTest.php b/apps/dav/tests/unit/CalDAV/Activity/Filter/GenericTest.php index 4d5bcea9966..a09cbed4fce 100644 --- a/apps/dav/tests/unit/CalDAV/Activity/Filter/GenericTest.php +++ b/apps/dav/tests/unit/CalDAV/Activity/Filter/GenericTest.php @@ -56,7 +56,7 @@ class GenericTest extends TestCase { public function testGetIdentifier($filterClass) { /** @var IFilter $filter */ $filter = \OC::$server->query($filterClass); - $this->assertInternalType('string', $filter->getIdentifier()); + $this->assertIsString($filter->getIdentifier()); } /** @@ -66,7 +66,7 @@ class GenericTest extends TestCase { public function testGetName($filterClass) { /** @var IFilter $filter */ $filter = \OC::$server->query($filterClass); - $this->assertInternalType('string', $filter->getName()); + $this->assertIsString($filter->getName()); } /** @@ -77,7 +77,7 @@ class GenericTest extends TestCase { /** @var IFilter $filter */ $filter = \OC::$server->query($filterClass); $priority = $filter->getPriority(); - $this->assertInternalType('int', $filter->getPriority()); + $this->assertIsInt($filter->getPriority()); $this->assertGreaterThanOrEqual(0, $priority); $this->assertLessThanOrEqual(100, $priority); } @@ -89,7 +89,7 @@ class GenericTest extends TestCase { public function testGetIcon($filterClass) { /** @var IFilter $filter */ $filter = \OC::$server->query($filterClass); - $this->assertInternalType('string', $filter->getIcon()); + $this->assertIsString($filter->getIcon()); $this->assertStringStartsWith('http', $filter->getIcon()); } @@ -100,7 +100,7 @@ class GenericTest extends TestCase { public function testFilterTypes($filterClass) { /** @var IFilter $filter */ $filter = \OC::$server->query($filterClass); - $this->assertInternalType('array', $filter->filterTypes([])); + $this->assertIsArray($filter->filterTypes([])); } /** @@ -110,6 +110,6 @@ class GenericTest extends TestCase { public function testAllowedApps($filterClass) { /** @var IFilter $filter */ $filter = \OC::$server->query($filterClass); - $this->assertInternalType('array', $filter->allowedApps()); + $this->assertIsArray($filter->allowedApps()); } } diff --git a/apps/dav/tests/unit/CalDAV/Activity/Provider/BaseTest.php b/apps/dav/tests/unit/CalDAV/Activity/Provider/BaseTest.php index 64f9b6f86af..2f48b359659 100644 --- a/apps/dav/tests/unit/CalDAV/Activity/Provider/BaseTest.php +++ b/apps/dav/tests/unit/CalDAV/Activity/Provider/BaseTest.php @@ -113,10 +113,11 @@ class BaseTest extends TestCase { /** * @dataProvider dataGenerateObjectParameterThrows - * @expectedException \InvalidArgumentException * @param mixed $eventData */ public function testGenerateObjectParameterThrows($eventData) { + $this->expectException(\InvalidArgumentException::class); + $this->invokePrivate($this->provider, 'generateObjectParameter', [$eventData]); } diff --git a/apps/dav/tests/unit/CalDAV/Activity/Setting/GenericTest.php b/apps/dav/tests/unit/CalDAV/Activity/Setting/GenericTest.php index 73ddebeccce..ebc4f19c7d8 100644 --- a/apps/dav/tests/unit/CalDAV/Activity/Setting/GenericTest.php +++ b/apps/dav/tests/unit/CalDAV/Activity/Setting/GenericTest.php @@ -55,7 +55,7 @@ class GenericTest extends TestCase { public function testGetIdentifier($settingClass) { /** @var ISetting $setting */ $setting = \OC::$server->query($settingClass); - $this->assertInternalType('string', $setting->getIdentifier()); + $this->assertIsString($setting->getIdentifier()); } /** @@ -65,7 +65,7 @@ class GenericTest extends TestCase { public function testGetName($settingClass) { /** @var ISetting $setting */ $setting = \OC::$server->query($settingClass); - $this->assertInternalType('string', $setting->getName()); + $this->assertIsString($setting->getName()); } /** @@ -76,7 +76,7 @@ class GenericTest extends TestCase { /** @var ISetting $setting */ $setting = \OC::$server->query($settingClass); $priority = $setting->getPriority(); - $this->assertInternalType('int', $setting->getPriority()); + $this->assertIsInt($setting->getPriority()); $this->assertGreaterThanOrEqual(0, $priority); $this->assertLessThanOrEqual(100, $priority); } @@ -88,7 +88,7 @@ class GenericTest extends TestCase { public function testCanChangeStream($settingClass) { /** @var ISetting $setting */ $setting = \OC::$server->query($settingClass); - $this->assertInternalType('bool', $setting->canChangeStream()); + $this->assertIsBool($setting->canChangeStream()); } /** @@ -98,7 +98,7 @@ class GenericTest extends TestCase { public function testIsDefaultEnabledStream($settingClass) { /** @var ISetting $setting */ $setting = \OC::$server->query($settingClass); - $this->assertInternalType('bool', $setting->isDefaultEnabledStream()); + $this->assertIsBool($setting->isDefaultEnabledStream()); } /** @@ -108,7 +108,7 @@ class GenericTest extends TestCase { public function testCanChangeMail($settingClass) { /** @var ISetting $setting */ $setting = \OC::$server->query($settingClass); - $this->assertInternalType('bool', $setting->canChangeMail()); + $this->assertIsBool($setting->canChangeMail()); } /** @@ -118,6 +118,6 @@ class GenericTest extends TestCase { public function testIsDefaultEnabledMail($settingClass) { /** @var ISetting $setting */ $setting = \OC::$server->query($settingClass); - $this->assertInternalType('bool', $setting->isDefaultEnabledMail()); + $this->assertIsBool($setting->isDefaultEnabledMail()); } } diff --git a/apps/dav/tests/unit/CalDAV/BirthdayCalendar/EnablePluginTest.php b/apps/dav/tests/unit/CalDAV/BirthdayCalendar/EnablePluginTest.php index d2935850e51..26b126ed8a7 100644 --- a/apps/dav/tests/unit/CalDAV/BirthdayCalendar/EnablePluginTest.php +++ b/apps/dav/tests/unit/CalDAV/BirthdayCalendar/EnablePluginTest.php @@ -46,7 +46,7 @@ class EnablePluginTest extends TestCase { protected $response; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->server = $this->createMock(\Sabre\DAV\Server::class); diff --git a/apps/dav/tests/unit/CalDAV/CachedSubscriptionObjectTest.php b/apps/dav/tests/unit/CalDAV/CachedSubscriptionObjectTest.php index 7d4463c81b4..57931549019 100644 --- a/apps/dav/tests/unit/CalDAV/CachedSubscriptionObjectTest.php +++ b/apps/dav/tests/unit/CalDAV/CachedSubscriptionObjectTest.php @@ -52,11 +52,11 @@ class CachedSubscriptionObjectTest extends \Test\TestCase { $this->assertEquals('BEGIN...', $calendarObject->get()); } - /** - * @expectedException \Sabre\DAV\Exception\MethodNotAllowed - * @expectedExceptionMessage Creating objects in a cached subscription is not allowed - */ + public function testPut() { + $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class); + $this->expectExceptionMessage('Creating objects in a cached subscription is not allowed'); + $backend = $this->createMock(CalDavBackend::class); $calendarInfo = [ '{http://owncloud.org/ns}owner-principal' => 'user1', @@ -72,11 +72,11 @@ class CachedSubscriptionObjectTest extends \Test\TestCase { $calendarObject->put(''); } - /** - * @expectedException \Sabre\DAV\Exception\MethodNotAllowed - * @expectedExceptionMessage Deleting objects in a cached subscription is not allowed - */ + public function testDelete() { + $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class); + $this->expectExceptionMessage('Deleting objects in a cached subscription is not allowed'); + $backend = $this->createMock(CalDavBackend::class); $calendarInfo = [ '{http://owncloud.org/ns}owner-principal' => 'user1', diff --git a/apps/dav/tests/unit/CalDAV/CachedSubscriptionTest.php b/apps/dav/tests/unit/CalDAV/CachedSubscriptionTest.php index 82f9af364da..4143cd6a4fe 100644 --- a/apps/dav/tests/unit/CalDAV/CachedSubscriptionTest.php +++ b/apps/dav/tests/unit/CalDAV/CachedSubscriptionTest.php @@ -140,11 +140,11 @@ class CachedSubscriptionTest extends \Test\TestCase { $calendar->propPatch($propPatch); } - /** - * @expectedException \Sabre\DAV\Exception\NotFound - * @expectedExceptionMessage Calendar object not found - */ + public function testGetChild() { + $this->expectException(\Sabre\DAV\Exception\NotFound::class); + $this->expectExceptionMessage('Calendar object not found'); + $backend = $this->createMock(CalDavBackend::class); $calendarInfo = [ '{http://owncloud.org/ns}owner-principal' => 'user1', @@ -235,11 +235,11 @@ class CachedSubscriptionTest extends \Test\TestCase { $this->assertInstanceOf(CachedSubscriptionObject::class, $res[1]); } - /** - * @expectedException \Sabre\DAV\Exception\MethodNotAllowed - * @expectedExceptionMessage Creating objects in cached subscription is not allowed - */ + public function testCreateFile() { + $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class); + $this->expectExceptionMessage('Creating objects in cached subscription is not allowed'); + $backend = $this->createMock(CalDavBackend::class); $calendarInfo = [ '{http://owncloud.org/ns}owner-principal' => 'user1', diff --git a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php index 9a65b7c70c5..2c7e5bef56d 100644 --- a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php +++ b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php @@ -279,11 +279,11 @@ EOD; $this->assertCount(0, $calendarObjects); } - /** - * @expectedException \Sabre\DAV\Exception\BadRequest - * @expectedExceptionMessage Calendar object with uid already exists in this calendar collection. - */ + public function testMultipleCalendarObjectsWithSameUID() { + $this->expectException(\Sabre\DAV\Exception\BadRequest::class); + $this->expectExceptionMessage('Calendar object with uid already exists in this calendar collection.'); + $calendarId = $this->createTestCalendar(); $calData = <<<'EOD' diff --git a/apps/dav/tests/unit/CalDAV/CalendarHomeTest.php b/apps/dav/tests/unit/CalDAV/CalendarHomeTest.php index c93e436b1a1..913c7aa985a 100644 --- a/apps/dav/tests/unit/CalDAV/CalendarHomeTest.php +++ b/apps/dav/tests/unit/CalDAV/CalendarHomeTest.php @@ -68,11 +68,11 @@ class CalendarHomeTest extends TestCase { $this->calendarHome->createExtendedCollection('name123', $mkCol); } - /** - * @expectedException \Sabre\DAV\Exception\MethodNotAllowed - * @expectedExceptionMessage The resource you tried to create has a reserved name - */ + public function testCreateCalendarReservedName() { + $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class); + $this->expectExceptionMessage('The resource you tried to create has a reserved name'); + /** @var MkCol | \PHPUnit_Framework_MockObject_MockObject $mkCol */ $mkCol = $this->createMock(MkCol::class); diff --git a/apps/dav/tests/unit/CalDAV/CalendarTest.php b/apps/dav/tests/unit/CalDAV/CalendarTest.php index 8af6524b8aa..7b3baad5127 100644 --- a/apps/dav/tests/unit/CalDAV/CalendarTest.php +++ b/apps/dav/tests/unit/CalDAV/CalendarTest.php @@ -43,7 +43,7 @@ class CalendarTest extends TestCase { /** @var IConfig */ protected $config; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->l10n = $this->getMockBuilder(IL10N::class) ->disableOriginalConstructor()->getMock(); @@ -73,10 +73,10 @@ class CalendarTest extends TestCase { $c->delete(); } - /** - * @expectedException \Sabre\DAV\Exception\Forbidden - */ + public function testDeleteFromGroup() { + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + /** @var \PHPUnit_Framework_MockObject_MockObject | CalDavBackend $backend */ $backend = $this->getMockBuilder(CalDavBackend::class)->disableOriginalConstructor()->getMock(); $backend->expects($this->never())->method('updateShares'); diff --git a/apps/dav/tests/unit/CalDAV/PluginTest.php b/apps/dav/tests/unit/CalDAV/PluginTest.php index 65b135cf905..e91c0e8391e 100644 --- a/apps/dav/tests/unit/CalDAV/PluginTest.php +++ b/apps/dav/tests/unit/CalDAV/PluginTest.php @@ -30,7 +30,7 @@ class PluginTest extends TestCase { /** @var Plugin */ private $plugin; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->plugin = new Plugin(); diff --git a/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php b/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php index 0bbfe997304..516ced5e0e7 100644 --- a/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php +++ b/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php @@ -72,7 +72,7 @@ class PublicCalendarRootTest extends TestCase { /** @var ILogger */ private $logger; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $db = \OC::$server->getDatabaseConnection(); @@ -108,7 +108,7 @@ class PublicCalendarRootTest extends TestCase { $this->l10n, $this->config); } - public function tearDown(): void { + protected function tearDown(): void { parent::tearDown(); if (is_null($this->backend)) { diff --git a/apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php b/apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php index 728905e6e6c..3de178fe491 100644 --- a/apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php +++ b/apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php @@ -48,7 +48,7 @@ class PluginTest extends TestCase { /** @var IURLGenerator | \PHPUnit_Framework_MockObject_MockObject */ private $urlGenerator; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->config = $this->getMockBuilder(IConfig::class)-> diff --git a/apps/dav/tests/unit/CalDAV/Reminder/BackendTest.php b/apps/dav/tests/unit/CalDAV/Reminder/BackendTest.php index 9ba3b15b23c..ba63c415c31 100644 --- a/apps/dav/tests/unit/CalDAV/Reminder/BackendTest.php +++ b/apps/dav/tests/unit/CalDAV/Reminder/BackendTest.php @@ -42,7 +42,7 @@ class BackendTest extends TestCase { /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */ private $timeFactory; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $query = self::$realDatabase->getQueryBuilder(); diff --git a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/AbstractNotificationProviderTest.php b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/AbstractNotificationProviderTest.php index 305cf4866db..87d29e603c5 100644 --- a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/AbstractNotificationProviderTest.php +++ b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/AbstractNotificationProviderTest.php @@ -68,7 +68,7 @@ abstract class AbstractNotificationProviderTest extends TestCase { */ protected $user; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->logger = $this->createMock(ILogger::class); diff --git a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php index 2654ac8b45c..f2fcb21fbf8 100644 --- a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php +++ b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php @@ -61,7 +61,7 @@ class EmailProviderTest extends AbstractNotificationProviderTest { /** @var IMailer|\PHPUnit\Framework\MockObject\MockObject */ private $mailer; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->mailer = $this->createMock(IMailer::class); diff --git a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/PushProviderTest.php b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/PushProviderTest.php index c2a95278b3f..3c2f175fdcb 100644 --- a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/PushProviderTest.php +++ b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/PushProviderTest.php @@ -61,7 +61,7 @@ class PushProviderTest extends AbstractNotificationProviderTest { /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */ private $timeFactory; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->config = $this->createMock(IConfig::class); diff --git a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php index 9eecc37fb1a..7006e17dd8b 100644 --- a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php +++ b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php @@ -41,7 +41,7 @@ class NotificationProviderManagerTest extends TestCase { /** * @throws \OCP\AppFramework\QueryException */ - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->providerManager = new NotificationProviderManager(); @@ -49,22 +49,24 @@ class NotificationProviderManagerTest extends TestCase { } /** - * @expectedException OCA\DAV\CalDAV\Reminder\NotificationTypeDoesNotExistException - * @expectedExceptionMessage Type NOT EXISTENT is not an accepted type of notification * @throws ProviderNotAvailableException * @throws NotificationTypeDoesNotExistException */ public function testGetProviderForUnknownType(): void{ + $this->expectException(\OCA\DAV\CalDAV\Reminder\NotificationTypeDoesNotExistException::class); + $this->expectExceptionMessage('Type NOT EXISTENT is not an accepted type of notification'); + $this->providerManager->getProvider('NOT EXISTENT'); } /** - * @expectedException OCA\DAV\CalDAV\Reminder\NotificationProvider\ProviderNotAvailableException - * @expectedExceptionMessage No notification provider for type AUDIO available * @throws NotificationTypeDoesNotExistException * @throws ProviderNotAvailableException */ public function testGetProviderForUnRegisteredType(): void{ + $this->expectException(\OCA\DAV\CalDAV\Reminder\NotificationProvider\ProviderNotAvailableException::class); + $this->expectExceptionMessage('No notification provider for type AUDIO available'); + $this->providerManager->getProvider('AUDIO'); } @@ -80,11 +82,12 @@ class NotificationProviderManagerTest extends TestCase { } /** - * @expectedExceptionMessage Invalid notification provider registered - * @expectedException \InvalidArgumentException * @throws \OCP\AppFramework\QueryException */ public function testRegisterBadProvider(): void{ + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Invalid notification provider registered'); + $this->providerManager->registerProvider(Capabilities::class); } diff --git a/apps/dav/tests/unit/CalDAV/Reminder/NotifierTest.php b/apps/dav/tests/unit/CalDAV/Reminder/NotifierTest.php index 6bb6a8be1c8..6d64f2615de 100644 --- a/apps/dav/tests/unit/CalDAV/Reminder/NotifierTest.php +++ b/apps/dav/tests/unit/CalDAV/Reminder/NotifierTest.php @@ -98,12 +98,12 @@ class NotifierTest extends TestCase { $this->assertEquals($this->notifier->getName(), 'Calendar'); } - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Notification not from this app - */ + public function testPrepareWrongApp(): void { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Notification not from this app'); + /** @var INotification|\PHPUnit\Framework\MockObject\MockObject $notification */ $notification = $this->createMock(INotification::class); @@ -116,11 +116,11 @@ class NotifierTest extends TestCase { $this->notifier->prepare($notification, 'en'); } - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Unknown subject - */ + public function testPrepareWrongSubject() { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Unknown subject'); + /** @var INotification|\PHPUnit\Framework\MockObject\MockObject $notification */ $notification = $this->createMock(INotification::class); diff --git a/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php b/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php index 503478acc01..177a86ebab9 100644 --- a/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php +++ b/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php @@ -184,7 +184,7 @@ END:VEVENT END:VCALENDAR EOD; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->backend = $this->createMock(Backend::class); diff --git a/apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTest.php b/apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTest.php index 5f59af260c1..9b2e3d32232 100644 --- a/apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTest.php +++ b/apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTest.php @@ -64,7 +64,7 @@ abstract class AbstractPrincipalBackendTest extends TestCase { /** @var string */ protected $expectedCUType; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->userSession = $this->createMock(IUserSession::class); diff --git a/apps/dav/tests/unit/CalDAV/ResourceBooking/ResourcePrincipalBackendTest.php b/apps/dav/tests/unit/CalDAV/ResourceBooking/ResourcePrincipalBackendTest.php index 5d9e3e8455c..0bbe5a7c557 100644 --- a/apps/dav/tests/unit/CalDAV/ResourceBooking/ResourcePrincipalBackendTest.php +++ b/apps/dav/tests/unit/CalDAV/ResourceBooking/ResourcePrincipalBackendTest.php @@ -25,7 +25,7 @@ namespace OCA\DAV\Tests\unit\CalDAV\ResourceBooking; use OCA\DAV\CalDAV\ResourceBooking\ResourcePrincipalBackend; Class ResourcePrincipalBackendTest extends AbstractPrincipalBackendTest { - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->principalBackend = new ResourcePrincipalBackend(self::$realDatabase, diff --git a/apps/dav/tests/unit/CalDAV/ResourceBooking/RoomPrincipalBackendTest.php b/apps/dav/tests/unit/CalDAV/ResourceBooking/RoomPrincipalBackendTest.php index 34fa8e38f14..357f381c878 100644 --- a/apps/dav/tests/unit/CalDAV/ResourceBooking/RoomPrincipalBackendTest.php +++ b/apps/dav/tests/unit/CalDAV/ResourceBooking/RoomPrincipalBackendTest.php @@ -25,7 +25,7 @@ namespace OCA\DAV\Tests\unit\CalDAV\ResourceBooking; use OCA\DAV\CalDAV\ResourceBooking\RoomPrincipalBackend; Class RoomPrincipalBackendTest extends AbstractPrincipalBackendTest { - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->principalBackend = new RoomPrincipalBackend(self::$realDatabase, diff --git a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php index 58342db12f2..44022a2b114 100644 --- a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php +++ b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php @@ -48,7 +48,7 @@ use Test\TestCase; class IMipPluginTest extends TestCase { - public function setUp(): void { + protected function setUp(): void { $this->mailMessage = $this->createMock(IMessage::class); $this->mailMessage->method('setFrom')->willReturn($this->mailMessage); $this->mailMessage->method('setReplyTo')->willReturn($this->mailMessage); diff --git a/apps/dav/tests/unit/CalDAV/Schedule/PluginTest.php b/apps/dav/tests/unit/CalDAV/Schedule/PluginTest.php index a489839fc82..f75580142a3 100644 --- a/apps/dav/tests/unit/CalDAV/Schedule/PluginTest.php +++ b/apps/dav/tests/unit/CalDAV/Schedule/PluginTest.php @@ -36,7 +36,7 @@ class PluginTest extends TestCase { /** @var Server|\PHPUnit_Framework_MockObject_MockObject */ private $server; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->server = $this->createMock(Server::class); diff --git a/apps/dav/tests/unit/CalDAV/Search/Request/CalendarSearchReportTest.php b/apps/dav/tests/unit/CalDAV/Search/Request/CalendarSearchReportTest.php index 30cf768feab..d62c2528ca9 100644 --- a/apps/dav/tests/unit/CalDAV/Search/Request/CalendarSearchReportTest.php +++ b/apps/dav/tests/unit/CalDAV/Search/Request/CalendarSearchReportTest.php @@ -131,11 +131,11 @@ XML; ); } - /** - * @expectedException \Sabre\DAV\Exception\BadRequest - * @expectedExceptionMessage {http://nextcloud.com/ns}prop-filter or {http://nextcloud.com/ns}param-filter given without any {http://nextcloud.com/ns}comp-filter - */ + public function testRequiresCompFilter() { + $this->expectException(\Sabre\DAV\Exception\BadRequest::class); + $this->expectExceptionMessage('{http://nextcloud.com/ns}prop-filter or {http://nextcloud.com/ns}param-filter given without any {http://nextcloud.com/ns}comp-filter'); + $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?> <nc:calendar-search xmlns:nc="http://nextcloud.com/ns" xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:"> @@ -158,11 +158,11 @@ XML; $this->parse($xml); } - /** - * @expectedException \Sabre\DAV\Exception\BadRequest - * @expectedExceptionMessage The {http://nextcloud.com/ns}filter element is required for this request - */ + public function testRequiresFilter() { + $this->expectException(\Sabre\DAV\Exception\BadRequest::class); + $this->expectExceptionMessage('The {http://nextcloud.com/ns}filter element is required for this request'); + $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?> <nc:calendar-search xmlns:nc="http://nextcloud.com/ns" xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:"> @@ -176,11 +176,11 @@ XML; $this->parse($xml); } - /** - * @expectedException \Sabre\DAV\Exception\BadRequest - * @expectedExceptionMessage {http://nextcloud.com/ns}search-term is required for this request - */ + public function testNoSearchTerm() { + $this->expectException(\Sabre\DAV\Exception\BadRequest::class); + $this->expectExceptionMessage('{http://nextcloud.com/ns}search-term is required for this request'); + $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?> <nc:calendar-search xmlns:nc="http://nextcloud.com/ns" xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:"> @@ -204,11 +204,11 @@ XML; $this->parse($xml); } - /** - * @expectedException \Sabre\DAV\Exception\BadRequest - * @expectedExceptionMessage At least one{http://nextcloud.com/ns}prop-filter or {http://nextcloud.com/ns}param-filter is required for this request - */ + public function testCompOnly() { + $this->expectException(\Sabre\DAV\Exception\BadRequest::class); + $this->expectExceptionMessage('At least one{http://nextcloud.com/ns}prop-filter or {http://nextcloud.com/ns}param-filter is required for this request'); + $xml = <<<XML <?xml version="1.0" encoding="UTF-8"?> <nc:calendar-search xmlns:nc="http://nextcloud.com/ns" xmlns:c="urn:ietf:params:xml:ns:caldav" xmlns:d="DAV:"> diff --git a/apps/dav/tests/unit/CalDAV/Search/SearchPluginTest.php b/apps/dav/tests/unit/CalDAV/Search/SearchPluginTest.php index e0cdfaf732f..65a225646e2 100644 --- a/apps/dav/tests/unit/CalDAV/Search/SearchPluginTest.php +++ b/apps/dav/tests/unit/CalDAV/Search/SearchPluginTest.php @@ -36,7 +36,7 @@ class SearchPluginTest extends TestCase { /** @var \OCA\DAV\CalDAV\Search\SearchPlugin $plugin */ protected $plugin; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->server = $this->createMock(\Sabre\DAV\Server::class); |