diff options
author | Roeland Jago Douma <rullzer@users.noreply.github.com> | 2019-11-28 08:36:10 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-28 08:36:10 +0100 |
commit | 669302e570024c83140ff5c4f4b1489c5a1c66ed (patch) | |
tree | 010182798f5c83193554031753e063a8a0b35ca1 /apps/dav/tests/unit/CalDAV | |
parent | 125be68311a319f2b839e5aa4ea29cd642cd1e00 (diff) | |
parent | e3e782b63df4f1d65c86cb3b204b4bdecf93a6cd (diff) | |
download | nextcloud-server-669302e570024c83140ff5c4f4b1489c5a1c66ed.tar.gz nextcloud-server-669302e570024c83140ff5c4f4b1489c5a1c66ed.zip |
Merge pull request #18064 from nextcloud/feature/php74
Add php7.4 support
Diffstat (limited to 'apps/dav/tests/unit/CalDAV')
33 files changed, 114 insertions, 102 deletions
diff --git a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php index 9f9a7c01337..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() { + 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() { + protected function tearDown(): void { $this->cleanUpBackend(); parent::tearDown(); } diff --git a/apps/dav/tests/unit/CalDAV/Activity/BackendTest.php b/apps/dav/tests/unit/CalDAV/Activity/BackendTest.php index 3b4e0038b59..07597458681 100644 --- a/apps/dav/tests/unit/CalDAV/Activity/BackendTest.php +++ b/apps/dav/tests/unit/CalDAV/Activity/BackendTest.php @@ -44,7 +44,7 @@ class BackendTest extends TestCase { /** @var IUserSession|\PHPUnit_Framework_MockObject_MockObject */ protected $userSession; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->activityManager = $this->createMock(IManager::class); $this->groupManager = $this->createMock(IGroupManager::class); diff --git a/apps/dav/tests/unit/CalDAV/Activity/Filter/CalendarTest.php b/apps/dav/tests/unit/CalDAV/Activity/Filter/CalendarTest.php index 1c31508255a..b19f48762b5 100644 --- a/apps/dav/tests/unit/CalDAV/Activity/Filter/CalendarTest.php +++ b/apps/dav/tests/unit/CalDAV/Activity/Filter/CalendarTest.php @@ -37,7 +37,7 @@ class CalendarTest extends TestCase { /** @var IFilter|\PHPUnit_Framework_MockObject_MockObject */ protected $filter; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->url = $this->createMock(IURLGenerator::class); $l = $this->createMock(IL10N::class); 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/Filter/TodoTest.php b/apps/dav/tests/unit/CalDAV/Activity/Filter/TodoTest.php index f060e7a0b37..f8b505f6c51 100644 --- a/apps/dav/tests/unit/CalDAV/Activity/Filter/TodoTest.php +++ b/apps/dav/tests/unit/CalDAV/Activity/Filter/TodoTest.php @@ -37,7 +37,7 @@ class TodoTest extends TestCase { /** @var IFilter|\PHPUnit_Framework_MockObject_MockObject */ protected $filter; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->url = $this->createMock(IURLGenerator::class); $l = $this->createMock(IL10N::class); diff --git a/apps/dav/tests/unit/CalDAV/Activity/Provider/BaseTest.php b/apps/dav/tests/unit/CalDAV/Activity/Provider/BaseTest.php index db4d3e55fd8..2f48b359659 100644 --- a/apps/dav/tests/unit/CalDAV/Activity/Provider/BaseTest.php +++ b/apps/dav/tests/unit/CalDAV/Activity/Provider/BaseTest.php @@ -43,7 +43,7 @@ class BaseTest extends TestCase { /** @var IProvider|Base|\PHPUnit_Framework_MockObject_MockObject */ protected $provider; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->userManager = $this->createMock(IUserManager::class); $this->groupManager = $this->createMock(IGroupManager::class); @@ -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 44bf9237b2f..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() { + 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 a7981cfa159..913c7aa985a 100644 --- a/apps/dav/tests/unit/CalDAV/CalendarHomeTest.php +++ b/apps/dav/tests/unit/CalDAV/CalendarHomeTest.php @@ -39,7 +39,7 @@ class CalendarHomeTest extends TestCase { /** @var CalendarHome */ private $calendarHome; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->backend = $this->createMock(CalDavBackend::class); @@ -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/CalendarImplTest.php b/apps/dav/tests/unit/CalDAV/CalendarImplTest.php index ca3256773b3..432447ef5f7 100644 --- a/apps/dav/tests/unit/CalDAV/CalendarImplTest.php +++ b/apps/dav/tests/unit/CalDAV/CalendarImplTest.php @@ -41,7 +41,7 @@ class CalendarImplTest extends \Test\TestCase { /** @var CalDavBackend | \PHPUnit_Framework_MockObject_MockObject */ private $backend; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->calendar = $this->createMock(Calendar::class); diff --git a/apps/dav/tests/unit/CalDAV/CalendarManagerTest.php b/apps/dav/tests/unit/CalDAV/CalendarManagerTest.php index 1831840610c..89fe6972f9d 100644 --- a/apps/dav/tests/unit/CalDAV/CalendarManagerTest.php +++ b/apps/dav/tests/unit/CalDAV/CalendarManagerTest.php @@ -45,7 +45,7 @@ class CalendarManagerTest extends \Test\TestCase { /** @var CalendarManager */ private $manager; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->backend = $this->createMock(CalDavBackend::class); $this->l10n = $this->createMock(IL10N::class); diff --git a/apps/dav/tests/unit/CalDAV/CalendarTest.php b/apps/dav/tests/unit/CalDAV/CalendarTest.php index 7ce43f40916..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() { + 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/OutboxTest.php b/apps/dav/tests/unit/CalDAV/OutboxTest.php index be5dc33fc61..3da6d8a9b9b 100644 --- a/apps/dav/tests/unit/CalDAV/OutboxTest.php +++ b/apps/dav/tests/unit/CalDAV/OutboxTest.php @@ -34,7 +34,7 @@ class OutboxTest extends TestCase { /** @var Outbox */ private $outbox; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->config = $this->createMock(IConfig::class); diff --git a/apps/dav/tests/unit/CalDAV/PluginTest.php b/apps/dav/tests/unit/CalDAV/PluginTest.php index 87bf69c2805..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() { + 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 51977313ed4..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() { + 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() { + 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 ed803c67dd3..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() { + 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 dae3cb74e24..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() { + protected function setUp(): void { parent::setUp(); $query = self::$realDatabase->getQueryBuilder(); @@ -56,7 +56,7 @@ class BackendTest extends TestCase { $this->createRemindersTestSet(); } - protected function tearDown() { + protected function tearDown(): void { $query = self::$realDatabase->getQueryBuilder(); $query->delete('calendar_reminders')->execute(); $query->delete('calendarobjects')->execute(); diff --git a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/AbstractNotificationProviderTest.php b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/AbstractNotificationProviderTest.php index 889ac867315..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() { + 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 a288907b4ba..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() { + 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 346faf1a65e..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() { + 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 d55f15ee5ae..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() { + 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 8d38617ad2a..6d64f2615de 100644 --- a/apps/dav/tests/unit/CalDAV/Reminder/NotifierTest.php +++ b/apps/dav/tests/unit/CalDAV/Reminder/NotifierTest.php @@ -50,7 +50,7 @@ class NotifierTest extends TestCase { /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */ protected $timeFactory; - protected function setUp() { + protected function setUp(): void { parent::setUp(); $this->urlGenerator = $this->createMock(IURLGenerator::class); @@ -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 73f5ddde15d..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() { + 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 ea2a7520227..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() { + protected function setUp(): void { parent::setUp(); $this->userSession = $this->createMock(IUserSession::class); @@ -73,7 +73,7 @@ abstract class AbstractPrincipalBackendTest extends TestCase { $this->proxyMapper = $this->createMock(ProxyMapper::class); } - protected function tearDown() { + protected function tearDown(): void { $query = self::$realDatabase->getQueryBuilder(); $query->delete('calendar_resources')->execute(); diff --git a/apps/dav/tests/unit/CalDAV/ResourceBooking/ResourcePrincipalBackendTest.php b/apps/dav/tests/unit/CalDAV/ResourceBooking/ResourcePrincipalBackendTest.php index ef71cd3b8d7..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() { + 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 92788f0d7a8..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() { + 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 967f3a51481..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() { + 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 ff6c0837c7a..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() { + 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 12eb74259fc..65a225646e2 100644 --- a/apps/dav/tests/unit/CalDAV/Search/SearchPluginTest.php +++ b/apps/dav/tests/unit/CalDAV/Search/SearchPluginTest.php @@ -26,6 +26,7 @@ namespace OCA\DAV\Tests\unit\CalDAV\Search; use OCA\DAV\CalDAV\CalendarHome; use OCA\DAV\CalDAV\Search\SearchPlugin; use OCA\DAV\CalDAV\Search\Xml\Request\CalendarSearchReport; +use Sabre\Xml\Service; use Test\TestCase; class SearchPluginTest extends TestCase { @@ -35,12 +36,13 @@ class SearchPluginTest extends TestCase { /** @var \OCA\DAV\CalDAV\Search\SearchPlugin $plugin */ protected $plugin; - public function setUp() { + protected function setUp(): void { parent::setUp(); $this->server = $this->createMock(\Sabre\DAV\Server::class); $this->server->tree = $this->createMock(\Sabre\DAV\Tree::class); $this->server->httpResponse = $this->createMock(\Sabre\HTTP\Response::class); + $this->server->xml = new Service(); $this->plugin = new SearchPlugin(); $this->plugin->initialize($this->server); @@ -62,6 +64,7 @@ class SearchPluginTest extends TestCase { $server->expects($this->at(0)) ->method('on') ->with('report', [$plugin, 'report']); + $server->xml = new Service(); $plugin->initialize($server); @@ -93,6 +96,11 @@ class SearchPluginTest extends TestCase { ->method('getHTTPDepth') ->with(2) ->will($this->returnValue(2)); + $this->server + ->method('getHTTPPrefer') + ->willReturn([ + 'return' => null + ]); $calendarHome->expects($this->at(0)) ->method('calendarSearch') ->will($this->returnValue([])); |