Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2019-11-27 17:27:18 +0300
committerRoeland Jago Douma <roeland@famdouma.nl>2019-11-27 17:27:18 +0300
commit3a7cf40aaa678bea1df143d2982d603b7a334eec (patch)
tree63c1e3ad7f7f401d14411a4d44c523632906afc9 /apps
parent0568b012672d650c6b5a49e72c4028dde5463c60 (diff)
Mode to modern phpunit
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'apps')
-rw-r--r--apps/admin_audit/tests/Actions/SecurityTest.php2
-rw-r--r--apps/comments/tests/Unit/Collaboration/CommentersSorterTest.php2
-rw-r--r--apps/comments/tests/Unit/JSSettingsHelperTest.php2
-rw-r--r--apps/comments/tests/Unit/Notification/NotifierTest.php30
-rw-r--r--apps/dav/lib/CalDAV/CachedSubscription.php4
-rw-r--r--apps/dav/lib/CalDAV/CalendarHome.php4
-rw-r--r--apps/dav/tests/unit/Avatars/AvatarHomeTest.php5
-rw-r--r--apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php4
-rw-r--r--apps/dav/tests/unit/CalDAV/Activity/Filter/GenericTest.php12
-rw-r--r--apps/dav/tests/unit/CalDAV/Activity/Provider/BaseTest.php3
-rw-r--r--apps/dav/tests/unit/CalDAV/Activity/Setting/GenericTest.php14
-rw-r--r--apps/dav/tests/unit/CalDAV/BirthdayCalendar/EnablePluginTest.php2
-rw-r--r--apps/dav/tests/unit/CalDAV/CachedSubscriptionObjectTest.php16
-rw-r--r--apps/dav/tests/unit/CalDAV/CachedSubscriptionTest.php16
-rw-r--r--apps/dav/tests/unit/CalDAV/CalDavBackendTest.php8
-rw-r--r--apps/dav/tests/unit/CalDAV/CalendarHomeTest.php8
-rw-r--r--apps/dav/tests/unit/CalDAV/CalendarTest.php8
-rw-r--r--apps/dav/tests/unit/CalDAV/PluginTest.php2
-rw-r--r--apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php4
-rw-r--r--apps/dav/tests/unit/CalDAV/Publishing/PublishingTest.php2
-rw-r--r--apps/dav/tests/unit/CalDAV/Reminder/BackendTest.php2
-rw-r--r--apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/AbstractNotificationProviderTest.php2
-rw-r--r--apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php2
-rw-r--r--apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/PushProviderTest.php2
-rw-r--r--apps/dav/tests/unit/CalDAV/Reminder/NotificationProviderManagerTest.php17
-rw-r--r--apps/dav/tests/unit/CalDAV/Reminder/NotifierTest.php16
-rw-r--r--apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php2
-rw-r--r--apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTest.php2
-rw-r--r--apps/dav/tests/unit/CalDAV/ResourceBooking/ResourcePrincipalBackendTest.php2
-rw-r--r--apps/dav/tests/unit/CalDAV/ResourceBooking/RoomPrincipalBackendTest.php2
-rw-r--r--apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php2
-rw-r--r--apps/dav/tests/unit/CalDAV/Schedule/PluginTest.php2
-rw-r--r--apps/dav/tests/unit/CalDAV/Search/Request/CalendarSearchReportTest.php32
-rw-r--r--apps/dav/tests/unit/CalDAV/Search/SearchPluginTest.php2
-rw-r--r--apps/dav/tests/unit/CardDAV/AddressBookImplTest.php2
-rw-r--r--apps/dav/tests/unit/CardDAV/AddressBookTest.php12
-rw-r--r--apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php2
-rw-r--r--apps/dav/tests/unit/CardDAV/CardDavBackendTest.php16
-rw-r--r--apps/dav/tests/unit/CardDAV/ConverterTest.php2
-rw-r--r--apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php2
-rw-r--r--apps/dav/tests/unit/CardDAV/Sharing/PluginTest.php2
-rw-r--r--apps/dav/tests/unit/Command/ListCalendarsTest.php6
-rw-r--r--apps/dav/tests/unit/Command/MoveCalendarTest.php19
-rw-r--r--apps/dav/tests/unit/Command/RemoveInvalidSharesTest.php2
-rw-r--r--apps/dav/tests/unit/Comments/CommentsNodeTest.php48
-rw-r--r--apps/dav/tests/unit/Comments/CommentsPluginTest.php46
-rw-r--r--apps/dav/tests/unit/Comments/EntityCollectionTest.php8
-rw-r--r--apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php14
-rw-r--r--apps/dav/tests/unit/Comments/RootCollectionTest.php50
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/AuthTest.php32
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/BearerAuthTest.php2
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php7
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php2
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php2
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php4
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php66
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php2
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php2
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/FileTest.php50
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php15
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php8
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php10
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php9
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php26
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php6
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php2
-rw-r--r--apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php2
-rw-r--r--apps/dav/tests/unit/Controller/BirthdayCalendarControllerTest.php2
-rw-r--r--apps/dav/tests/unit/Controller/DirectControllerTest.php2
-rw-r--r--apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php2
-rw-r--r--apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php2
-rw-r--r--apps/dav/tests/unit/DAV/GroupPrincipalTest.php10
-rw-r--r--apps/dav/tests/unit/DAV/HookManagerTest.php2
-rw-r--r--apps/dav/tests/unit/DAV/Sharing/PluginTest.php2
-rw-r--r--apps/dav/tests/unit/DAV/SystemPrincipalBackendTest.php10
-rw-r--r--apps/dav/tests/unit/Direct/DirectFileTest.php2
-rw-r--r--apps/dav/tests/unit/Direct/DirectHomeTest.php2
-rw-r--r--apps/dav/tests/unit/Files/FileSearchBackendTest.php12
-rw-r--r--apps/dav/tests/unit/Files/Sharing/FilesDropPluginTest.php2
-rw-r--r--apps/dav/tests/unit/Migration/CalDAVRemoveEmptyValueTest.php2
-rw-r--r--apps/dav/tests/unit/Provisioning/Apple/AppleProvisioningNodeTest.php26
-rw-r--r--apps/dav/tests/unit/Provisioning/Apple/AppleProvisioningPluginTest.php2
-rw-r--r--apps/dav/tests/unit/Settings/CalDAVSettingsTest.php2
-rw-r--r--apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php6
-rw-r--r--apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php24
-rw-r--r--apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php28
-rw-r--r--apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php36
-rw-r--r--apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php54
-rw-r--r--apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php36
-rw-r--r--apps/dav/tests/unit/Upload/ChunkingPluginTest.php10
-rw-r--r--apps/dav/tests/unit/Upload/FutureFileTest.php12
-rw-r--r--apps/encryption/tests/Command/TestEnableMasterKey.php2
-rw-r--r--apps/encryption/tests/Crypto/CryptTest.php11
-rw-r--r--apps/encryption/tests/Crypto/DecryptAllTest.php2
-rw-r--r--apps/encryption/tests/Crypto/EncryptAllTest.php2
-rw-r--r--apps/encryption/tests/Crypto/EncryptionTest.php13
-rw-r--r--apps/encryption/tests/HookManagerTest.php12
-rw-r--r--apps/encryption/tests/KeyManagerTest.php20
-rw-r--r--apps/encryption/tests/SessionTest.php32
-rw-r--r--apps/encryption/tests/Settings/AdminTest.php2
-rw-r--r--apps/federatedfilesharing/tests/AddressHandlerTest.php5
-rw-r--r--apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php2
-rw-r--r--apps/federatedfilesharing/tests/FederatedShareProviderTest.php4
-rw-r--r--apps/federatedfilesharing/tests/NotificationsTest.php2
-rw-r--r--apps/federatedfilesharing/tests/Settings/AdminTest.php2
-rw-r--r--apps/federatedfilesharing/tests/TokenHandlerTest.php2
-rw-r--r--apps/federation/tests/BackgroundJob/GetSharedSecretTest.php2
-rw-r--r--apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php2
-rw-r--r--apps/federation/tests/Controller/OCSAuthAPIControllerTest.php2
-rw-r--r--apps/federation/tests/Controller/SettingsControllerTest.php8
-rw-r--r--apps/federation/tests/DbHandlerTest.php4
-rw-r--r--apps/federation/tests/HooksTest.php2
-rw-r--r--apps/federation/tests/Middleware/AddServerMiddlewareTest.php2
-rw-r--r--apps/federation/tests/Settings/AdminTest.php2
-rw-r--r--apps/federation/tests/SyncFederationAddressbooksTest.php2
-rw-r--r--apps/federation/tests/TrustedServersTest.php7
-rw-r--r--apps/files/tests/Activity/Filter/GenericTest.php12
-rw-r--r--apps/files/tests/Activity/ProviderTest.php8
-rw-r--r--apps/files/tests/Activity/Setting/GenericTest.php14
-rw-r--r--apps/files/tests/BackgroundJob/ScanFilesTest.php2
-rw-r--r--apps/files/tests/Controller/ApiControllerTest.php2
-rw-r--r--apps/files/tests/Controller/ViewControllerTest.php2
-rw-r--r--apps/files_external/tests/Auth/Password/GlobalAuth.php6
-rw-r--r--apps/files_external/tests/Config/UserPlaceholderHandlerTest.php2
-rw-r--r--apps/files_external/tests/Controller/AjaxControllerTest.php2
-rw-r--r--apps/files_external/tests/Controller/GlobalStoragesControllerTest.php2
-rw-r--r--apps/files_external/tests/Controller/StoragesControllerTest.php4
-rw-r--r--apps/files_external/tests/Controller/UserStoragesControllerTest.php2
-rw-r--r--apps/files_external/tests/Service/BackendServiceTest.php3
-rw-r--r--apps/files_external/tests/Service/DBConfigServiceTest.php4
-rw-r--r--apps/files_external/tests/Service/GlobalStoragesServiceTest.php7
-rw-r--r--apps/files_external/tests/Service/StoragesServiceTest.php16
-rw-r--r--apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php29
-rw-r--r--apps/files_external/tests/Service/UserStoragesServiceTest.php8
-rw-r--r--apps/files_external/tests/Settings/AdminTest.php2
-rw-r--r--apps/files_external/tests/Settings/SectionTest.php2
-rw-r--r--apps/files_external/tests/Storage/SFTP_KeyTest.php26
-rw-r--r--apps/files_sharing/tests/CapabilitiesTest.php10
-rw-r--r--apps/files_sharing/tests/Collaboration/ShareRecipientSorterTest.php2
-rw-r--r--apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php2
-rw-r--r--apps/files_sharing/tests/Controller/ExternalShareControllerTest.php2
-rw-r--r--apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php2
-rw-r--r--apps/files_sharing/tests/Controller/ShareAPIControllerTest.php194
-rw-r--r--apps/files_sharing/tests/Controller/ShareControllerTest.php6
-rw-r--r--apps/files_sharing/tests/Controller/ShareInfoControllerTest.php2
-rw-r--r--apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php8
-rw-r--r--apps/files_sharing/tests/LockingTest.php10
-rw-r--r--apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php2
-rw-r--r--apps/files_sharing/tests/Middleware/ShareInfoMiddlewareTest.php2
-rw-r--r--apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php16
-rw-r--r--apps/files_sharing/tests/Migration/SetPasswordColumnTest.php4
-rw-r--r--apps/files_sharing/tests/MountProviderTest.php2
-rw-r--r--apps/files_trashbin/tests/CapabilitiesTest.php2
-rw-r--r--apps/files_trashbin/tests/Command/CleanUpTest.php2
-rw-r--r--apps/files_trashbin/tests/Controller/PreviewControllerTest.php2
-rw-r--r--apps/files_versions/tests/Command/CleanupTest.php2
-rw-r--r--apps/files_versions/tests/Controller/PreviewControllerTest.php2
-rw-r--r--apps/files_versions/tests/VersioningTest.php6
-rw-r--r--apps/oauth2/tests/Controller/LoginRedirectorControllerTest.php2
-rw-r--r--apps/oauth2/tests/Controller/OauthApiControllerTest.php2
-rw-r--r--apps/oauth2/tests/Controller/SettingsControllerTest.php2
-rw-r--r--apps/oauth2/tests/Db/AccessTokenMapperTest.php8
-rw-r--r--apps/oauth2/tests/Db/ClientMapperTest.php14
-rw-r--r--apps/oauth2/tests/Settings/AdminTest.php2
-rw-r--r--apps/provisioning_api/tests/Controller/AppConfigControllerTest.php6
-rw-r--r--apps/provisioning_api/tests/Controller/AppsControllerTest.php16
-rw-r--r--apps/provisioning_api/tests/Controller/GroupsControllerTest.php62
-rw-r--r--apps/provisioning_api/tests/Controller/UsersControllerTest.php416
-rw-r--r--apps/provisioning_api/tests/Middleware/ProvisioningApiMiddlewareTest.php2
-rw-r--r--apps/settings/tests/Controller/AdminSettingsControllerTest.php4
-rw-r--r--apps/settings/tests/Controller/AppSettingsControllerTest.php2
-rw-r--r--apps/settings/tests/Controller/CertificateControllerTest.php2
-rw-r--r--apps/settings/tests/Controller/CheckSetupControllerTest.php2
-rw-r--r--apps/settings/tests/Controller/UsersControllerTest.php3
-rw-r--r--apps/settings/tests/Mailer/NewUserMailHelperTest.php2
-rw-r--r--apps/settings/tests/Middleware/SubadminMiddlewareTest.php12
-rw-r--r--apps/settings/tests/Personal/Security/AuthtokensTest.php2
-rw-r--r--apps/settings/tests/Settings/Admin/MailTest.php2
-rw-r--r--apps/settings/tests/Settings/Admin/SecurityTest.php2
-rw-r--r--apps/settings/tests/Settings/Admin/ServerTest.php2
-rw-r--r--apps/settings/tests/Settings/Admin/SharingTest.php2
-rw-r--r--apps/settings/tests/Settings/Personal/SecurityTest.php2
-rw-r--r--apps/sharebymail/tests/CapabilitiesTest.php2
-rw-r--r--apps/sharebymail/tests/SettingsTest.php2
-rw-r--r--apps/sharebymail/tests/ShareByMailProviderTest.php34
-rw-r--r--apps/systemtags/tests/Activity/SettingTest.php2
-rw-r--r--apps/systemtags/tests/Settings/AdminTest.php2
-rw-r--r--apps/theming/tests/Controller/IconControllerTest.php2
-rw-r--r--apps/theming/tests/Controller/ThemingControllerTest.php2
-rw-r--r--apps/theming/tests/ImageManagerTest.php12
-rw-r--r--apps/theming/tests/Settings/AdminTest.php2
-rw-r--r--apps/theming/tests/Settings/SectionTest.php2
-rw-r--r--apps/theming/tests/ThemingDefaultsTest.php2
-rw-r--r--apps/twofactor_backupcodes/tests/Unit/BackgroundJob/CheckBackupCodeTest.php2
-rw-r--r--apps/twofactor_backupcodes/tests/Unit/BackgroundJob/RememberBackupCodesJobTest.php2
-rw-r--r--apps/twofactor_backupcodes/tests/Unit/Notification/NotifierTest.php12
-rw-r--r--apps/updatenotification/tests/Controller/AdminControllerTest.php2
-rw-r--r--apps/updatenotification/tests/Notification/BackgroundJobTest.php2
-rw-r--r--apps/updatenotification/tests/Notification/NotifierTest.php2
-rw-r--r--apps/updatenotification/tests/ResetTokenBackgroundJobTest.php2
-rw-r--r--apps/updatenotification/tests/Settings/AdminTest.php2
-rw-r--r--apps/updatenotification/tests/UpdateCheckerTest.php2
-rw-r--r--apps/user_ldap/lib/WizardResult.php4
-rw-r--r--apps/user_ldap/tests/AccessTest.php18
-rw-r--r--apps/user_ldap/tests/ConfigurationTest.php2
-rw-r--r--apps/user_ldap/tests/ConnectionTest.php2
-rw-r--r--apps/user_ldap/tests/GroupLDAPPluginTest.php48
-rw-r--r--apps/user_ldap/tests/Group_LDAPTest.php30
-rw-r--r--apps/user_ldap/tests/HelperTest.php2
-rw-r--r--apps/user_ldap/tests/Jobs/SyncTest.php2
-rw-r--r--apps/user_ldap/tests/LDAPProviderTest.php88
-rw-r--r--apps/user_ldap/tests/LDAPTest.php2
-rw-r--r--apps/user_ldap/tests/Migration/AbstractUUIDFixTest.php2
-rw-r--r--apps/user_ldap/tests/Migration/UUIDFixGroupTest.php2
-rw-r--r--apps/user_ldap/tests/Migration/UUIDFixInsertTest.php2
-rw-r--r--apps/user_ldap/tests/Migration/UUIDFixUserTest.php2
-rw-r--r--apps/user_ldap/tests/Settings/AdminTest.php2
-rw-r--r--apps/user_ldap/tests/Settings/SectionTest.php2
-rw-r--r--apps/user_ldap/tests/User/DeletedUsersIndexTest.php4
-rw-r--r--apps/user_ldap/tests/User/ManagerTest.php2
-rw-r--r--apps/user_ldap/tests/User/UserTest.php8
-rw-r--r--apps/user_ldap/tests/UserLDAPPluginTest.php64
-rw-r--r--apps/user_ldap/tests/User_LDAPTest.php34
-rw-r--r--apps/user_ldap/tests/User_ProxyTest.php2
-rw-r--r--apps/workflowengine/tests/Check/RequestUserAgentTest.php2
225 files changed, 1293 insertions, 1278 deletions
diff --git a/apps/admin_audit/tests/Actions/SecurityTest.php b/apps/admin_audit/tests/Actions/SecurityTest.php
index c7295452482..92fdaa98682 100644
--- a/apps/admin_audit/tests/Actions/SecurityTest.php
+++ b/apps/admin_audit/tests/Actions/SecurityTest.php
@@ -39,7 +39,7 @@ class SecurityTest extends TestCase {
/** @var IUser|\PHPUnit_Framework_MockObject_MockObject */
private $user;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->logger = $this->createMock(ILogger::class);
diff --git a/apps/comments/tests/Unit/Collaboration/CommentersSorterTest.php b/apps/comments/tests/Unit/Collaboration/CommentersSorterTest.php
index 727014b8fcb..a1cc6f915e3 100644
--- a/apps/comments/tests/Unit/Collaboration/CommentersSorterTest.php
+++ b/apps/comments/tests/Unit/Collaboration/CommentersSorterTest.php
@@ -36,7 +36,7 @@ class CommentersSorterTest extends TestCase {
/** @var CommentersSorter */
protected $sorter;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->commentsManager = $this->createMock(ICommentsManager::class);
diff --git a/apps/comments/tests/Unit/JSSettingsHelperTest.php b/apps/comments/tests/Unit/JSSettingsHelperTest.php
index 4133daef3ce..4b580024da4 100644
--- a/apps/comments/tests/Unit/JSSettingsHelperTest.php
+++ b/apps/comments/tests/Unit/JSSettingsHelperTest.php
@@ -34,7 +34,7 @@ class JSSettingsHelperTest extends TestCase {
/** @var JSSettingsHelper */
protected $helper;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->c = $this->createMock(IServerContainer::class);
diff --git a/apps/comments/tests/Unit/Notification/NotifierTest.php b/apps/comments/tests/Unit/Notification/NotifierTest.php
index 1fb1cd7736e..617fcaf09b1 100644
--- a/apps/comments/tests/Unit/Notification/NotifierTest.php
+++ b/apps/comments/tests/Unit/Notification/NotifierTest.php
@@ -339,10 +339,10 @@ class NotifierTest extends TestCase {
$this->notifier->prepare($this->notification, $this->lc);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testPrepareDifferentApp() {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->folder
->expects($this->never())
->method('getById');
@@ -376,10 +376,10 @@ class NotifierTest extends TestCase {
$this->notifier->prepare($this->notification, $this->lc);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testPrepareNotFound() {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->folder
->expects($this->never())
->method('getById');
@@ -414,10 +414,10 @@ class NotifierTest extends TestCase {
$this->notifier->prepare($this->notification, $this->lc);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testPrepareDifferentSubject() {
+ $this->expectException(\InvalidArgumentException::class);
+
$displayName = 'Huraga';
/** @var IUser|\PHPUnit_Framework_MockObject_MockObject $user */
@@ -477,10 +477,10 @@ class NotifierTest extends TestCase {
$this->notifier->prepare($this->notification, $this->lc);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testPrepareNotFiles() {
+ $this->expectException(\InvalidArgumentException::class);
+
$displayName = 'Huraga';
/** @var IUser|\PHPUnit_Framework_MockObject_MockObject $user */
@@ -541,10 +541,10 @@ class NotifierTest extends TestCase {
$this->notifier->prepare($this->notification, $this->lc);
}
- /**
- * @expectedException \OCP\Notification\AlreadyProcessedException
- */
+
public function testPrepareUnresolvableFileID() {
+ $this->expectException(\OCP\Notification\AlreadyProcessedException::class);
+
$displayName = 'Huraga';
/** @var IUser|\PHPUnit_Framework_MockObject_MockObject $user */
diff --git a/apps/dav/lib/CalDAV/CachedSubscription.php b/apps/dav/lib/CalDAV/CachedSubscription.php
index 2d27f5b42c0..8331e2a8de1 100644
--- a/apps/dav/lib/CalDAV/CachedSubscription.php
+++ b/apps/dav/lib/CalDAV/CachedSubscription.php
@@ -108,9 +108,7 @@ class CachedSubscription extends \Sabre\CalDAV\Calendar {
return parent::getOwner();
}
- /**
- *
- */
+
public function delete() {
$this->caldavBackend->deleteSubscription($this->calendarInfo['id']);
}
diff --git a/apps/dav/lib/CalDAV/CalendarHome.php b/apps/dav/lib/CalDAV/CalendarHome.php
index 3e1ee361687..23c7d692c6c 100644
--- a/apps/dav/lib/CalDAV/CalendarHome.php
+++ b/apps/dav/lib/CalDAV/CalendarHome.php
@@ -154,9 +154,7 @@ class CalendarHome extends \Sabre\CalDAV\CalendarHome {
return $this->caldavBackend->calendarSearch($principalUri, $filters, $limit, $offset);
}
- /**
- *
- */
+
public function enableCachedSubscriptionsForThisRequest() {
$this->returnCachedSubscriptions = true;
}
diff --git a/apps/dav/tests/unit/Avatars/AvatarHomeTest.php b/apps/dav/tests/unit/Avatars/AvatarHomeTest.php
index e5a2bfa862f..4a8d9895dd7 100644
--- a/apps/dav/tests/unit/Avatars/AvatarHomeTest.php
+++ b/apps/dav/tests/unit/Avatars/AvatarHomeTest.php
@@ -40,17 +40,18 @@ class AvatarHomeTest extends TestCase {
/** @var IAvatarManager | \PHPUnit_Framework_MockObject_MockObject */
private $avatarManager;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->avatarManager = $this->createMock(IAvatarManager::class);
$this->home = new AvatarHome(['uri' => 'principals/users/admin'], $this->avatarManager);
}
/**
- * @expectedException \Sabre\DAV\Exception\Forbidden
* @dataProvider providesForbiddenMethods
*/
public function testForbiddenMethods($method) {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$this->home->$method('');
}
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);
diff --git a/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php b/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php
index 02468e9686f..f3abfbbde9e 100644
--- a/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php
+++ b/apps/dav/tests/unit/CardDAV/AddressBookImplTest.php
@@ -55,7 +55,7 @@ class AddressBookImplTest extends TestCase {
/** @var VCard | \PHPUnit_Framework_MockObject_MockObject */
private $vCard;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->addressBookInfo = [
diff --git a/apps/dav/tests/unit/CardDAV/AddressBookTest.php b/apps/dav/tests/unit/CardDAV/AddressBookTest.php
index 8fa6023f0d2..e801eb22b53 100644
--- a/apps/dav/tests/unit/CardDAV/AddressBookTest.php
+++ b/apps/dav/tests/unit/CardDAV/AddressBookTest.php
@@ -51,10 +51,10 @@ class AddressBookTest extends TestCase {
$c->delete();
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testDeleteFromGroup() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
/** @var \PHPUnit_Framework_MockObject_MockObject | CardDavBackend $backend */
$backend = $this->getMockBuilder(CardDavBackend::class)->disableOriginalConstructor()->getMock();
$backend->expects($this->never())->method('updateShares');
@@ -73,10 +73,10 @@ class AddressBookTest extends TestCase {
$c->delete();
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testPropPatch() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
/** @var \PHPUnit_Framework_MockObject_MockObject | CardDavBackend $backend */
$backend = $this->getMockBuilder(CardDavBackend::class)->disableOriginalConstructor()->getMock();
$calendarInfo = [
diff --git a/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php b/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php
index 6bfda95a70e..82333143958 100644
--- a/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php
+++ b/apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php
@@ -52,7 +52,7 @@ class BirthdayServiceTest extends TestCase {
/** @var IL10N | \PHPUnit_Framework_MockObject_MockObject */
private $l10n;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->calDav = $this->createMock(CalDavBackend::class);
diff --git a/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php b/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php
index adc6df952ac..f2a85cb9dbb 100644
--- a/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php
+++ b/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php
@@ -121,7 +121,7 @@ class CardDavBackendTest extends TestCase {
'N:TestNoUID;;;;'.PHP_EOL.
'END:VCARD';
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->userManager = $this->createMock(IUserManager::class);
@@ -159,7 +159,7 @@ class CardDavBackendTest extends TestCase {
$this->tearDown();
}
- public function tearDown(): void {
+ protected function tearDown(): void {
parent::tearDown();
if (is_null($this->backend)) {
@@ -631,10 +631,10 @@ class CardDavBackendTest extends TestCase {
$this->invokePrivate($this->backend, 'getCardId', [1, 'uri']));
}
- /**
- * @expectedException InvalidArgumentException
- */
+
public function testGetCardIdFailed() {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->invokePrivate($this->backend, 'getCardId', [1, 'uri']);
}
@@ -784,10 +784,10 @@ class CardDavBackendTest extends TestCase {
$this->assertSame('uri', $this->backend->getCardUri($id));
}
- /**
- * @expectedException InvalidArgumentException
- */
+
public function testGetCardUriFailed() {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->backend->getCardUri(1);
}
diff --git a/apps/dav/tests/unit/CardDAV/ConverterTest.php b/apps/dav/tests/unit/CardDAV/ConverterTest.php
index 8484d3447f2..e308bd71cfc 100644
--- a/apps/dav/tests/unit/CardDAV/ConverterTest.php
+++ b/apps/dav/tests/unit/CardDAV/ConverterTest.php
@@ -39,7 +39,7 @@ class ConverterTest extends TestCase {
/** @var AccountManager | PHPUnit_Framework_MockObject_MockObject */
private $accountManager;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->accountManager = $this->createMock(AccountManager::class);
diff --git a/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php b/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php
index 3fee2bcc827..d7f8ce5d159 100644
--- a/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php
+++ b/apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php
@@ -53,7 +53,7 @@ class ImageExportPluginTest extends TestCase {
/** @var PhotoCache|\PHPUnit_Framework_MockObject_MockObject */
private $cache;
- function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(RequestInterface::class);
diff --git a/apps/dav/tests/unit/CardDAV/Sharing/PluginTest.php b/apps/dav/tests/unit/CardDAV/Sharing/PluginTest.php
index 105612b5cb9..1cb7bc31f2f 100644
--- a/apps/dav/tests/unit/CardDAV/Sharing/PluginTest.php
+++ b/apps/dav/tests/unit/CardDAV/Sharing/PluginTest.php
@@ -44,7 +44,7 @@ class PluginTest extends TestCase {
/** @var IShareable | \PHPUnit_Framework_MockObject_MockObject */
private $book;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
/** @var Auth | \PHPUnit_Framework_MockObject_MockObject $authBackend */
diff --git a/apps/dav/tests/unit/Command/ListCalendarsTest.php b/apps/dav/tests/unit/Command/ListCalendarsTest.php
index 9cd02805133..0b381857573 100644
--- a/apps/dav/tests/unit/Command/ListCalendarsTest.php
+++ b/apps/dav/tests/unit/Command/ListCalendarsTest.php
@@ -58,11 +58,11 @@ class ListCalendarsTest extends TestCase {
);
}
- /**
- * @expectedException InvalidArgumentException
- */
+
public function testWithBadUser()
{
+ $this->expectException(\InvalidArgumentException::class);
+
$this->userManager->expects($this->once())
->method('userExists')
->with(self::USERNAME)
diff --git a/apps/dav/tests/unit/Command/MoveCalendarTest.php b/apps/dav/tests/unit/Command/MoveCalendarTest.php
index 50c1a57e0a8..c097427b239 100644
--- a/apps/dav/tests/unit/Command/MoveCalendarTest.php
+++ b/apps/dav/tests/unit/Command/MoveCalendarTest.php
@@ -89,12 +89,13 @@ class MoveCalendarTest extends TestCase {
/**
* @dataProvider dataExecute
*
- * @expectedException InvalidArgumentException
* @param $userOriginExists
* @param $userDestinationExists
*/
public function testWithBadUserOrigin($userOriginExists, $userDestinationExists)
{
+ $this->expectException(\InvalidArgumentException::class);
+
$this->userManager->expects($this->at(0))
->method('userExists')
->with('user')
@@ -115,12 +116,12 @@ class MoveCalendarTest extends TestCase {
]);
}
- /**
- * @expectedException InvalidArgumentException
- * @expectedExceptionMessage User <user> has no calendar named <personal>. You can run occ dav:list-calendars to list calendars URIs for this user.
- */
+
public function testMoveWithInexistantCalendar()
{
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('User <user> has no calendar named <personal>. You can run occ dav:list-calendars to list calendars URIs for this user.');
+
$this->userManager->expects($this->at(0))
->method('userExists')
->with('user')
@@ -143,12 +144,12 @@ class MoveCalendarTest extends TestCase {
]);
}
- /**
- * @expectedException InvalidArgumentException
- * @expectedExceptionMessage User <user2> already has a calendar named <personal>.
- */
+
public function testMoveWithExistingDestinationCalendar()
{
+ $this->expectException(\InvalidArgumentException::class);
+ $this->expectExceptionMessage('User <user2> already has a calendar named <personal>.');
+
$this->userManager->expects($this->at(0))
->method('userExists')
->with('user')
diff --git a/apps/dav/tests/unit/Command/RemoveInvalidSharesTest.php b/apps/dav/tests/unit/Command/RemoveInvalidSharesTest.php
index 1e415ceafca..7847273c975 100644
--- a/apps/dav/tests/unit/Command/RemoveInvalidSharesTest.php
+++ b/apps/dav/tests/unit/Command/RemoveInvalidSharesTest.php
@@ -37,7 +37,7 @@ use Test\TestCase;
*/
class RemoveInvalidSharesTest extends TestCase {
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$db = \OC::$server->getDatabaseConnection();
diff --git a/apps/dav/tests/unit/Comments/CommentsNodeTest.php b/apps/dav/tests/unit/Comments/CommentsNodeTest.php
index 3c230ccfd43..b709fd01e01 100644
--- a/apps/dav/tests/unit/Comments/CommentsNodeTest.php
+++ b/apps/dav/tests/unit/Comments/CommentsNodeTest.php
@@ -47,7 +47,7 @@ class CommentsNodeTest extends \Test\TestCase {
protected $logger;
protected $userSession;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->commentsManager = $this->getMockBuilder(ICommentsManager::class)
@@ -107,10 +107,10 @@ class CommentsNodeTest extends \Test\TestCase {
$this->node->delete();
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testDeleteForbidden() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$user = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
@@ -149,10 +149,10 @@ class CommentsNodeTest extends \Test\TestCase {
$this->assertSame($this->node->getName(), $id);
}
- /**
- * @expectedException \Sabre\DAV\Exception\MethodNotAllowed
- */
+
public function testSetName() {
+ $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class);
+
$this->node->setName('666');
}
@@ -194,11 +194,11 @@ class CommentsNodeTest extends \Test\TestCase {
$this->assertTrue($this->node->updateComment($msg));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage buh!
- */
+
public function testUpdateCommentLogException() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('buh!');
+
$msg = null;
$user = $this->getMockBuilder(IUser::class)
@@ -235,11 +235,11 @@ class CommentsNodeTest extends \Test\TestCase {
$this->node->updateComment($msg);
}
- /**
- * @expectedException \Sabre\DAV\Exception\BadRequest
- * @expectedExceptionMessage Message exceeds allowed character limit of
- */
+
public function testUpdateCommentMessageTooLongException() {
+ $this->expectException(\Sabre\DAV\Exception\BadRequest::class);
+ $this->expectExceptionMessage('Message exceeds allowed character limit of');
+
$user = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
@@ -274,10 +274,10 @@ class CommentsNodeTest extends \Test\TestCase {
$this->node->updateComment('foo');
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testUpdateForbiddenByUser() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$msg = 'HaXX0r';
$user = $this->getMockBuilder(IUser::class)
@@ -309,10 +309,10 @@ class CommentsNodeTest extends \Test\TestCase {
$this->node->updateComment($msg);
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testUpdateForbiddenByType() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$msg = 'HaXX0r';
$user = $this->getMockBuilder(IUser::class)
@@ -339,10 +339,10 @@ class CommentsNodeTest extends \Test\TestCase {
$this->node->updateComment($msg);
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testUpdateForbiddenByNotLoggedIn() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$msg = 'HaXX0r';
$this->userSession->expects($this->once())
diff --git a/apps/dav/tests/unit/Comments/CommentsPluginTest.php b/apps/dav/tests/unit/Comments/CommentsPluginTest.php
index 537989d9404..6cf23d1d42e 100644
--- a/apps/dav/tests/unit/Comments/CommentsPluginTest.php
+++ b/apps/dav/tests/unit/Comments/CommentsPluginTest.php
@@ -54,7 +54,7 @@ class CommentsPluginTest extends \Test\TestCase {
/** @var CommentsPluginImplementation */
private $plugin;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->tree = $this->getMockBuilder(Tree::class)
->disableOriginalConstructor()
@@ -170,10 +170,10 @@ class CommentsPluginTest extends \Test\TestCase {
$this->plugin->httpPost($request, $response);
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotFound
- */
+
public function testCreateCommentInvalidObject() {
+ $this->expectException(\Sabre\DAV\Exception\NotFound::class);
+
$commentData = [
'actorType' => 'users',
'verb' => 'comment',
@@ -252,10 +252,10 @@ class CommentsPluginTest extends \Test\TestCase {
$this->plugin->httpPost($request, $response);
}
- /**
- * @expectedException \Sabre\DAV\Exception\BadRequest
- */
+
public function testCreateCommentInvalidActor() {
+ $this->expectException(\Sabre\DAV\Exception\BadRequest::class);
+
$commentData = [
'actorType' => 'robots',
'verb' => 'comment',
@@ -340,10 +340,10 @@ class CommentsPluginTest extends \Test\TestCase {
$this->plugin->httpPost($request, $response);
}
- /**
- * @expectedException \Sabre\DAV\Exception\UnsupportedMediaType
- */
+
public function testCreateCommentUnsupportedMediaType() {
+ $this->expectException(\Sabre\DAV\Exception\UnsupportedMediaType::class);
+
$commentData = [
'actorType' => 'users',
'verb' => 'comment',
@@ -428,10 +428,10 @@ class CommentsPluginTest extends \Test\TestCase {
$this->plugin->httpPost($request, $response);
}
- /**
- * @expectedException \Sabre\DAV\Exception\BadRequest
- */
+
public function testCreateCommentInvalidPayload() {
+ $this->expectException(\Sabre\DAV\Exception\BadRequest::class);
+
$commentData = [
'actorType' => 'users',
'verb' => '',
@@ -522,11 +522,11 @@ class CommentsPluginTest extends \Test\TestCase {
$this->plugin->httpPost($request, $response);
}
- /**
- * @expectedException \Sabre\DAV\Exception\BadRequest
- * @expectedExceptionMessage Message exceeds allowed character limit of
- */
+
public function testCreateCommentMessageTooLong() {
+ $this->expectException(\Sabre\DAV\Exception\BadRequest::class);
+ $this->expectExceptionMessage('Message exceeds allowed character limit of');
+
$commentData = [
'actorType' => 'users',
'verb' => 'comment',
@@ -616,10 +616,10 @@ class CommentsPluginTest extends \Test\TestCase {
$this->plugin->httpPost($request, $response);
}
- /**
- * @expectedException \Sabre\DAV\Exception\ReportNotSupported
- */
+
public function testOnReportInvalidNode() {
+ $this->expectException(\Sabre\DAV\Exception\ReportNotSupported::class);
+
$path = 'totally/unrelated/13';
$this->tree->expects($this->any())
@@ -639,10 +639,10 @@ class CommentsPluginTest extends \Test\TestCase {
$this->plugin->onReport(CommentsPluginImplementation::REPORT_NAME, [], '/' . $path);
}
- /**
- * @expectedException \Sabre\DAV\Exception\ReportNotSupported
- */
+
public function testOnReportInvalidReportName() {
+ $this->expectException(\Sabre\DAV\Exception\ReportNotSupported::class);
+
$path = 'comments/files/42';
$this->tree->expects($this->any())
diff --git a/apps/dav/tests/unit/Comments/EntityCollectionTest.php b/apps/dav/tests/unit/Comments/EntityCollectionTest.php
index 2097c7ef03a..bb3992401f2 100644
--- a/apps/dav/tests/unit/Comments/EntityCollectionTest.php
+++ b/apps/dav/tests/unit/Comments/EntityCollectionTest.php
@@ -45,7 +45,7 @@ class EntityCollectionTest extends \Test\TestCase {
/** @var IUserSession|\PHPUnit_Framework_MockObject_MockObject */
protected $userSession;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->commentsManager = $this->getMockBuilder(ICommentsManager::class)
@@ -89,10 +89,10 @@ class EntityCollectionTest extends \Test\TestCase {
$this->assertTrue($node instanceof \OCA\DAV\Comments\CommentNode);
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotFound
- */
+
public function testGetChildException() {
+ $this->expectException(\Sabre\DAV\Exception\NotFound::class);
+
$this->commentsManager->expects($this->once())
->method('get')
->with('55')
diff --git a/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php b/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php
index 9286b46d2b0..038dea82fee 100644
--- a/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php
+++ b/apps/dav/tests/unit/Comments/EntityTypeCollectionTest.php
@@ -46,7 +46,7 @@ class EntityTypeCollectionTest extends \Test\TestCase {
protected $childMap = [];
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->commentsManager = $this->getMockBuilder(ICommentsManager::class)
@@ -92,17 +92,17 @@ class EntityTypeCollectionTest extends \Test\TestCase {
$this->assertTrue($ec instanceof EntityCollectionImplemantation);
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotFound
- */
+
public function testGetChildException() {
+ $this->expectException(\Sabre\DAV\Exception\NotFound::class);
+
$this->collection->getChild('17');
}
- /**
- * @expectedException \Sabre\DAV\Exception\MethodNotAllowed
- */
+
public function testGetChildren() {
+ $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class);
+
$this->collection->getChildren();
}
}
diff --git a/apps/dav/tests/unit/Comments/RootCollectionTest.php b/apps/dav/tests/unit/Comments/RootCollectionTest.php
index a0e72bcd425..cee5afc0eb3 100644
--- a/apps/dav/tests/unit/Comments/RootCollectionTest.php
+++ b/apps/dav/tests/unit/Comments/RootCollectionTest.php
@@ -53,7 +53,7 @@ class RootCollectionTest extends \Test\TestCase {
/** @var \OCP\IUser|\PHPUnit_Framework_MockObject_MockObject */
protected $user;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->user = $this->getMockBuilder(IUser::class)
@@ -106,17 +106,17 @@ class RootCollectionTest extends \Test\TestCase {
});
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testCreateFile() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$this->collection->createFile('foo');
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testCreateDirectory() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$this->collection->createDirectory('foo');
}
@@ -126,18 +126,18 @@ class RootCollectionTest extends \Test\TestCase {
$this->assertTrue($etc instanceof EntityTypeCollectionImplementation);
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotFound
- */
+
public function testGetChildInvalid() {
+ $this->expectException(\Sabre\DAV\Exception\NotFound::class);
+
$this->prepareForInitCollections();
$this->collection->getChild('robots');
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotAuthenticated
- */
+
public function testGetChildNoAuth() {
+ $this->expectException(\Sabre\DAV\Exception\NotAuthenticated::class);
+
$this->collection->getChild('files');
}
@@ -150,10 +150,10 @@ class RootCollectionTest extends \Test\TestCase {
}
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotAuthenticated
- */
+
public function testGetChildrenNoAuth() {
+ $this->expectException(\Sabre\DAV\Exception\NotAuthenticated::class);
+
$this->collection->getChildren();
}
@@ -167,17 +167,17 @@ class RootCollectionTest extends \Test\TestCase {
$this->assertFalse($this->collection->childExists('robots'));
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotAuthenticated
- */
+
public function testChildExistsNoAuth() {
+ $this->expectException(\Sabre\DAV\Exception\NotAuthenticated::class);
+
$this->collection->childExists('files');
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testDelete() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$this->collection->delete();
}
@@ -185,10 +185,10 @@ class RootCollectionTest extends \Test\TestCase {
$this->assertSame('comments', $this->collection->getName());
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testSetName() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$this->collection->setName('foobar');
}
diff --git a/apps/dav/tests/unit/Connector/Sabre/AuthTest.php b/apps/dav/tests/unit/Connector/Sabre/AuthTest.php
index 447a10afc79..60ec3186ed6 100644
--- a/apps/dav/tests/unit/Connector/Sabre/AuthTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/AuthTest.php
@@ -60,7 +60,7 @@ class AuthTest extends TestCase {
/** @var Throttler */
private $throttler;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->session = $this->getMockBuilder(ISession::class)
->disableOriginalConstructor()->getMock();
@@ -220,10 +220,10 @@ class AuthTest extends TestCase {
$this->assertFalse($this->invokePrivate($this->auth, 'validateUserPass', ['MyTestUser', 'MyTestPassword']));
}
- /**
- * @expectedException \OCA\DAV\Connector\Sabre\Exception\PasswordLoginForbidden
- */
+
public function testValidateUserPassWithPasswordLoginForbidden() {
+ $this->expectException(\OCA\DAV\Connector\Sabre\Exception\PasswordLoginForbidden::class);
+
$this->userSession
->expects($this->once())
->method('isLoggedIn')
@@ -329,11 +329,11 @@ class AuthTest extends TestCase {
$this->auth->check($request, $response);
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotAuthenticated
- * @expectedExceptionMessage 2FA challenge not passed.
- */
+
public function testAuthenticateAlreadyLoggedInWithoutTwoFactorChallengePassed() {
+ $this->expectException(\Sabre\DAV\Exception\NotAuthenticated::class);
+ $this->expectExceptionMessage('2FA challenge not passed.');
+
$request = $this->getMockBuilder(RequestInterface::class)
->disableOriginalConstructor()
->getMock();
@@ -383,11 +383,11 @@ class AuthTest extends TestCase {
$this->auth->check($request, $response);
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotAuthenticated
- * @expectedExceptionMessage CSRF check not passed.
- */
+
public function testAuthenticateAlreadyLoggedInWithoutCsrfTokenAndIncorrectlyDavAuthenticated() {
+ $this->expectException(\Sabre\DAV\Exception\NotAuthenticated::class);
+ $this->expectExceptionMessage('CSRF check not passed.');
+
$request = $this->getMockBuilder(RequestInterface::class)
->disableOriginalConstructor()
->getMock();
@@ -564,11 +564,11 @@ class AuthTest extends TestCase {
$this->assertEquals([false, 'No \'Authorization: Basic\' header found. Either the client didn\'t send one, or the server is misconfigured'], $response);
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotAuthenticated
- * @expectedExceptionMessage Cannot authenticate over ajax calls
- */
+
public function testAuthenticateNoBasicAuthenticateHeadersProvidedWithAjax() {
+ $this->expectException(\Sabre\DAV\Exception\NotAuthenticated::class);
+ $this->expectExceptionMessage('Cannot authenticate over ajax calls');
+
/** @var \Sabre\HTTP\RequestInterface $httpRequest */
$httpRequest = $this->getMockBuilder(RequestInterface::class)
->disableOriginalConstructor()
diff --git a/apps/dav/tests/unit/Connector/Sabre/BearerAuthTest.php b/apps/dav/tests/unit/Connector/Sabre/BearerAuthTest.php
index 2af8fc4c74d..b69c8af45ae 100644
--- a/apps/dav/tests/unit/Connector/Sabre/BearerAuthTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/BearerAuthTest.php
@@ -45,7 +45,7 @@ class BearerAuthTest extends TestCase {
/** @var BearerAuth */
private $bearerAuth;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->userSession = $this->createMock(\OC\User\Session::class);
diff --git a/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php
index 03c1ef1ff93..a79186f59a5 100644
--- a/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php
@@ -42,7 +42,7 @@ class BlockLegacyClientPluginTest extends TestCase {
/** @var BlockLegacyClientPlugin */
private $blockLegacyClientVersionPlugin;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->getMockBuilder(IConfig::class)
@@ -67,10 +67,11 @@ class BlockLegacyClientPluginTest extends TestCase {
/**
* @dataProvider oldDesktopClientProvider
* @param string $userAgent
- * @expectedException \Sabre\DAV\Exception\Forbidden
- * @expectedExceptionMessage Unsupported client version.
*/
public function testBeforeHandlerException($userAgent) {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+ $this->expectExceptionMessage('Unsupported client version.');
+
/** @var \Sabre\HTTP\RequestInterface | PHPUnit_Framework_MockObject_MockObject $request */
$request = $this->createMock('\Sabre\HTTP\RequestInterface');
$request
diff --git a/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php
index b605aba2bc2..2eda470b255 100644
--- a/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php
@@ -40,7 +40,7 @@ class CommentsPropertiesPluginTest extends \Test\TestCase {
protected $userSession;
protected $server;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->commentsManager = $this->getMockBuilder(ICommentsManager::class)
diff --git a/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php
index 5685580c03a..69ebc8d2a34 100644
--- a/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php
@@ -45,7 +45,7 @@ class CopyEtagHeaderPluginTest extends TestCase {
/** @var Server */
private $server;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->server = new \Sabre\DAV\Server();
$this->plugin = new CopyEtagHeaderPlugin();
diff --git a/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php b/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php
index 69f67f607b2..de44606fc19 100644
--- a/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php
@@ -67,7 +67,7 @@ class CustomPropertiesBackendTest extends \Test\TestCase {
*/
private $user;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->server = new \Sabre\DAV\Server();
$this->tree = $this->getMockBuilder(Tree::class)
@@ -90,7 +90,7 @@ class CustomPropertiesBackendTest extends \Test\TestCase {
);
}
- public function tearDown(): void {
+ protected function tearDown(): void {
$connection = \OC::$server->getDatabaseConnection();
$deleteStatement = $connection->prepare(
'DELETE FROM `*PREFIX*properties`' .
diff --git a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
index ee64eb5bce6..a93ef7ee962 100644
--- a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php
@@ -97,10 +97,10 @@ class DirectoryTest extends \Test\TestCase {
return new Directory($this->view, $this->info);
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testDeleteRootFolderFails() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$this->info->expects($this->any())
->method('isDeletable')
->will($this->returnValue(true));
@@ -110,10 +110,10 @@ class DirectoryTest extends \Test\TestCase {
$dir->delete();
}
- /**
- * @expectedException \OCA\DAV\Connector\Sabre\Exception\Forbidden
- */
+
public function testDeleteForbidden() {
+ $this->expectException(\OCA\DAV\Connector\Sabre\Exception\Forbidden::class);
+
// deletion allowed
$this->info->expects($this->once())
->method('isDeletable')
@@ -129,9 +129,7 @@ class DirectoryTest extends \Test\TestCase {
$dir->delete();
}
- /**
- *
- */
+
public function testDeleteFolderWhenAllowed() {
// deletion allowed
$this->info->expects($this->once())
@@ -148,10 +146,10 @@ class DirectoryTest extends \Test\TestCase {
$dir->delete();
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testDeleteFolderFailsWhenNotAllowed() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$this->info->expects($this->once())
->method('isDeletable')
->will($this->returnValue(false));
@@ -160,10 +158,10 @@ class DirectoryTest extends \Test\TestCase {
$dir->delete();
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testDeleteFolderThrowsWhenDeletionFailed() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
// deletion allowed
$this->info->expects($this->once())
->method('isDeletable')
@@ -218,10 +216,10 @@ class DirectoryTest extends \Test\TestCase {
$dir->getChildren();
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testGetChildrenNoPermission() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$info = $this->createMock(FileInfo::class);
$info->expects($this->any())
->method('isReadable')
@@ -231,10 +229,10 @@ class DirectoryTest extends \Test\TestCase {
$dir->getChildren();
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotFound
- */
+
public function testGetChildNoPermission() {
+ $this->expectException(\Sabre\DAV\Exception\NotFound::class);
+
$this->info->expects($this->any())
->method('isReadable')
->will($this->returnValue(false));
@@ -243,10 +241,10 @@ class DirectoryTest extends \Test\TestCase {
$dir->getChild('test');
}
- /**
- * @expectedException \Sabre\DAV\Exception\ServiceUnavailable
- */
+
public function testGetChildThrowStorageNotAvailableException() {
+ $this->expectException(\Sabre\DAV\Exception\ServiceUnavailable::class);
+
$this->view->expects($this->once())
->method('getFileInfo')
->willThrowException(new \OCP\Files\StorageNotAvailableException());
@@ -255,10 +253,10 @@ class DirectoryTest extends \Test\TestCase {
$dir->getChild('.');
}
- /**
- * @expectedException \OCA\DAV\Connector\Sabre\Exception\InvalidPath
- */
+
public function testGetChildThrowInvalidPath() {
+ $this->expectException(\OCA\DAV\Connector\Sabre\Exception\InvalidPath::class);
+
$this->view->expects($this->once())
->method('verifyPath')
->willThrowException(new \OCP\Files\InvalidPathException());
@@ -334,9 +332,10 @@ class DirectoryTest extends \Test\TestCase {
/**
* @dataProvider moveFailedProvider
- * @expectedException \Sabre\DAV\Exception\Forbidden
*/
public function testMoveFailed($source, $destination, $updatables, $deletables) {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$this->moveTest($source, $destination, $updatables, $deletables);
}
@@ -350,9 +349,10 @@ class DirectoryTest extends \Test\TestCase {
/**
* @dataProvider moveFailedInvalidCharsProvider
- * @expectedException \OCA\DAV\Connector\Sabre\Exception\InvalidPath
*/
public function testMoveFailedInvalidChars($source, $destination, $updatables, $deletables) {
+ $this->expectException(\OCA\DAV\Connector\Sabre\Exception\InvalidPath::class);
+
$this->moveTest($source, $destination, $updatables, $deletables);
}
@@ -403,11 +403,11 @@ class DirectoryTest extends \Test\TestCase {
$this->assertTrue($targetNode->moveInto(basename($destination), $source, $sourceNode));
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- * @expectedExceptionMessage Could not copy directory b, target exists
- */
+
public function testFailingMove() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+ $this->expectExceptionMessage('Could not copy directory b, target exists');
+
$source = 'a/b';
$destination = 'c/b';
$updatables = ['a' => true, 'a/b' => true, 'b' => true, 'c/b' => false];
diff --git a/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php b/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php
index 1d22579bdd1..e6555be814d 100644
--- a/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php
@@ -41,7 +41,7 @@ class DummyGetResponsePluginTest extends TestCase {
/** @var DummyGetResponsePlugin */
private $dummyGetResponsePlugin;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->dummyGetResponsePlugin = new DummyGetResponsePlugin();
diff --git a/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php
index c2c808a8d95..49b252eb1a1 100644
--- a/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php
@@ -44,7 +44,7 @@ class FakeLockerPluginTest extends TestCase {
/** @var FakeLockerPlugin */
private $fakeLockerPlugin;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->fakeLockerPlugin = new FakeLockerPlugin();
}
diff --git a/apps/dav/tests/unit/Connector/Sabre/FileTest.php b/apps/dav/tests/unit/Connector/Sabre/FileTest.php
index d0c18f6cd9e..a3cf4560387 100644
--- a/apps/dav/tests/unit/Connector/Sabre/FileTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/FileTest.php
@@ -62,7 +62,7 @@ class FileTest extends TestCase {
/** @var IConfig | \PHPUnit_Framework_MockObject_MockObject */
protected $config;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
unset($_SERVER['HTTP_OC_CHUNKED']);
unset($_SERVER['CONTENT_LENGTH']);
@@ -78,7 +78,7 @@ class FileTest extends TestCase {
$this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
}
- public function tearDown(): void {
+ protected function tearDown(): void {
$userManager = \OC::$server->getUserManager();
$userManager->get($this->user)->delete();
unset($_SERVER['HTTP_OC_CHUNKED']);
@@ -815,9 +815,10 @@ class FileTest extends TestCase {
/**
* Test setting name with setName() with invalid chars
*
- * @expectedException \OCA\DAV\Connector\Sabre\Exception\InvalidPath
*/
public function testSetNameInvalidChars() {
+ $this->expectException(\OCA\DAV\Connector\Sabre\Exception\InvalidPath::class);
+
// setup
$view = $this->getMockBuilder(View::class)
->setMethods(['getRelativePath'])
@@ -834,8 +835,7 @@ class FileTest extends TestCase {
$file->setName('/super*star.txt');
}
- /**
- */
+
public function testUploadAbort() {
// setup
$view = $this->getMockBuilder(View::class)
@@ -879,9 +879,7 @@ class FileTest extends TestCase {
$this->assertEmpty($this->listPartFiles($view, ''), 'No stray part files');
}
- /**
- *
- */
+
public function testDeleteWhenAllowed() {
// setup
$view = $this->getMockBuilder(View::class)
@@ -901,10 +899,10 @@ class FileTest extends TestCase {
$file->delete();
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testDeleteThrowsWhenDeletionNotAllowed() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
// setup
$view = $this->getMockBuilder(View::class)
->getMock();
@@ -919,10 +917,10 @@ class FileTest extends TestCase {
$file->delete();
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testDeleteThrowsWhenDeletionFailed() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
// setup
$view = $this->getMockBuilder(View::class)
->getMock();
@@ -942,10 +940,10 @@ class FileTest extends TestCase {
$file->delete();
}
- /**
- * @expectedException \OCA\DAV\Connector\Sabre\Exception\Forbidden
- */
+
public function testDeleteThrowsWhenDeletionThrows() {
+ $this->expectException(\OCA\DAV\Connector\Sabre\Exception\Forbidden::class);
+
// setup
$view = $this->getMockBuilder(View::class)
->getMock();
@@ -1112,10 +1110,10 @@ class FileTest extends TestCase {
];
}
- /**
- * @expectedException \Sabre\DAV\Exception\ServiceUnavailable
- */
+
public function testGetFopenFails() {
+ $this->expectException(\Sabre\DAV\Exception\ServiceUnavailable::class);
+
$view = $this->getMockBuilder(View::class)
->setMethods(['fopen'])
->getMock();
@@ -1132,10 +1130,10 @@ class FileTest extends TestCase {
$file->get();
}
- /**
- * @expectedException \OCA\DAV\Connector\Sabre\Exception\Forbidden
- */
+
public function testGetFopenThrows() {
+ $this->expectException(\OCA\DAV\Connector\Sabre\Exception\Forbidden::class);
+
$view = $this->getMockBuilder(View::class)
->setMethods(['fopen'])
->getMock();
@@ -1152,10 +1150,10 @@ class FileTest extends TestCase {
$file->get();
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotFound
- */
+
public function testGetThrowsIfNoPermission() {
+ $this->expectException(\Sabre\DAV\Exception\NotFound::class);
+
$view = $this->getMockBuilder(View::class)
->setMethods(['fopen'])
->getMock();
diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php
index 564059cd1dc..45c11d0011a 100644
--- a/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php
@@ -97,7 +97,7 @@ class FilesPluginTest extends TestCase {
*/
private $previewManager;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->server = $this->getMockBuilder(Server::class)
->disableOriginalConstructor()
@@ -462,10 +462,11 @@ class FilesPluginTest extends TestCase {
* FolderA is an incoming shared folder and there are no delete permissions.
* Thus moving /FolderA/test.txt to /test.txt should fail already on that check
*
- * @expectedException \Sabre\DAV\Exception\Forbidden
- * @expectedExceptionMessage FolderA/test.txt cannot be deleted
*/
public function testMoveSrcNotDeletable() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+ $this->expectExceptionMessage('FolderA/test.txt cannot be deleted');
+
$fileInfoFolderATestTXT = $this->getMockBuilder(FileInfo::class)
->disableOriginalConstructor()
->getMock();
@@ -507,11 +508,11 @@ class FilesPluginTest extends TestCase {
$this->plugin->checkMove('FolderA/test.txt', 'test.txt');
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotFound
- * @expectedExceptionMessage FolderA/test.txt does not exist
- */
+
public function testMoveSrcNotExist() {
+ $this->expectException(\Sabre\DAV\Exception\NotFound::class);
+ $this->expectExceptionMessage('FolderA/test.txt does not exist');
+
$node = $this->getMockBuilder(Node::class)
->disableOriginalConstructor()
->getMock();
diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
index ea58c50480c..14c6af122a2 100644
--- a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
@@ -85,7 +85,7 @@ class FilesReportPluginTest extends \Test\TestCase {
/** @var IAppManager|\PHPUnit_Framework_MockObject_MockObject * */
private $appManager;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->tree = $this->getMockBuilder(Tree::class)
->disableOriginalConstructor()
@@ -603,10 +603,10 @@ class FilesReportPluginTest extends \Test\TestCase {
$this->assertEquals(['222'], array_values($this->invokePrivate($this->plugin, 'processFilterRules', [$rules])));
}
- /**
- * @expectedException \OCP\SystemTag\TagNotFoundException
- */
+
public function testProcessFilterRulesInvisibleTagAsUser() {
+ $this->expectException(\OCP\SystemTag\TagNotFoundException::class);
+
$this->groupManager->expects($this->any())
->method('isAdmin')
->will($this->returnValue(false));
diff --git a/apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php b/apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php
index a604757520d..a9c8929dee6 100644
--- a/apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php
@@ -39,18 +39,18 @@ class MaintenancePluginTest extends TestCase {
/** @var MaintenancePlugin */
private $maintenancePlugin;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->getMockBuilder(IConfig::class)->getMock();
$this->maintenancePlugin = new MaintenancePlugin($this->config);
}
- /**
- * @expectedException \Sabre\DAV\Exception\ServiceUnavailable
- * @expectedExceptionMessage System in maintenance mode.
- */
+
public function testMaintenanceMode() {
+ $this->expectException(\Sabre\DAV\Exception\ServiceUnavailable::class);
+ $this->expectExceptionMessage('System in maintenance mode.');
+
$this->config
->expects($this->exactly(1))
->method('getSystemValueBool')
diff --git a/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php b/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php
index cd575e4ff3c..1c71d396de2 100644
--- a/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php
@@ -103,9 +103,10 @@ class ObjectTreeTest extends \Test\TestCase {
/**
* @dataProvider copyDataProvider
- * @expectedException \Sabre\DAV\Exception\Forbidden
*/
public function testCopyFailNotCreatable($sourcePath, $targetPath, $targetParent) {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$view = $this->createMock(View::class);
$view->expects($this->never())
->method('verifyPath');
@@ -268,10 +269,10 @@ class ObjectTreeTest extends \Test\TestCase {
);
}
- /**
- * @expectedException \OCA\DAV\Connector\Sabre\Exception\InvalidPath
- */
+
public function testGetNodeForPathInvalidPath() {
+ $this->expectException(\OCA\DAV\Connector\Sabre\Exception\InvalidPath::class);
+
$path = '/foo\bar';
diff --git a/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php b/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php
index 5320bd28302..7836191450b 100644
--- a/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php
@@ -65,7 +65,7 @@ class PrincipalTest extends TestCase {
/** @var ProxyMapper | \PHPUnit_Framework_MockObject_MockObject */
private $proxyMapper;
- public function setUp(): void {
+ protected function setUp(): void {
$this->userManager = $this->createMock(IUserManager::class);
$this->groupManager = $this->createMock(IGroupManager::class);
$this->shareManager = $this->createMock(IManager::class);
@@ -209,11 +209,11 @@ class PrincipalTest extends TestCase {
$this->assertSame([], $response);
}
- /**
- * @expectedException \Sabre\DAV\Exception
- * @expectedExceptionMessage Principal not found
- */
+
public function testGetGroupMemberSetEmpty() {
+ $this->expectException(\Sabre\DAV\Exception::class);
+ $this->expectExceptionMessage('Principal not found');
+
$this->userManager
->expects($this->once())
->method('get')
@@ -334,11 +334,11 @@ class PrincipalTest extends TestCase {
$this->assertSame($expectedResponse, $response);
}
- /**
- * @expectedException \Sabre\DAV\Exception
- * @expectedExceptionMessage Principal not found
- */
+
public function testGetGroupMembershipEmpty() {
+ $this->expectException(\Sabre\DAV\Exception::class);
+ $this->expectExceptionMessage('Principal not found');
+
$this->userManager
->expects($this->once())
->method('get')
@@ -348,11 +348,11 @@ class PrincipalTest extends TestCase {
$this->connector->getGroupMembership('principals/users/foo');
}
- /**
- * @expectedException \Sabre\DAV\Exception
- * @expectedExceptionMessage Setting members of the group is not supported yet
- */
+
public function testSetGroupMembership() {
+ $this->expectException(\Sabre\DAV\Exception::class);
+ $this->expectExceptionMessage('Setting members of the group is not supported yet');
+
$this->connector->setGroupMemberSet('principals/users/foo', ['foo']);
}
diff --git a/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php
index e5d229733c5..d09ed9cf681 100644
--- a/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php
@@ -85,10 +85,11 @@ class QuotaPluginTest extends TestCase {
}
/**
- * @expectedException \Sabre\DAV\Exception\InsufficientStorage
* @dataProvider quotaExceededProvider
*/
public function testCheckExceededQuota($quota, $headers) {
+ $this->expectException(\Sabre\DAV\Exception\InsufficientStorage::class);
+
$this->init($quota);
$this->plugin->expects($this->never())
->method('getFileChunking');
@@ -209,9 +210,10 @@ class QuotaPluginTest extends TestCase {
/**
* @dataProvider quotaChunkedFailProvider
- * @expectedException \Sabre\DAV\Exception\InsufficientStorage
*/
public function testCheckQuotaChunkedFail($quota, $chunkTotalSize, $headers) {
+ $this->expectException(\Sabre\DAV\Exception\InsufficientStorage::class);
+
$this->init($quota, 'sub/test.txt');
$mockChunking = $this->getMockBuilder(\OC_FileChunking::class)
diff --git a/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php
index 85d285f2c3b..96c2d3ba092 100644
--- a/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php
@@ -66,7 +66,7 @@ class SharesPluginTest extends \Test\TestCase {
*/
private $plugin;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->server = new \Sabre\DAV\Server();
$this->tree = $this->createMock(Tree::class);
diff --git a/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php
index 384441f4495..a805a776ad8 100644
--- a/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php
+++ b/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php
@@ -70,7 +70,7 @@ class TagsPluginTest extends \Test\TestCase {
*/
private $plugin;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->server = new \Sabre\DAV\Server();
$this->tree = $this->getMockBuilder(Tree::class)
diff --git a/apps/dav/tests/unit/Controller/BirthdayCalendarControllerTest.php b/apps/dav/tests/unit/Controller/BirthdayCalendarControllerTest.php
index 509ccb7e353..cc1273f5418 100644
--- a/apps/dav/tests/unit/Controller/BirthdayCalendarControllerTest.php
+++ b/apps/dav/tests/unit/Controller/BirthdayCalendarControllerTest.php
@@ -57,7 +57,7 @@ class BirthdayCalendarControllerTest extends TestCase {
/** @var BirthdayCalendarController|\PHPUnit_Framework_MockObject_MockObject */
private $controller;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
diff --git a/apps/dav/tests/unit/Controller/DirectControllerTest.php b/apps/dav/tests/unit/Controller/DirectControllerTest.php
index 18034891dc8..21282762745 100644
--- a/apps/dav/tests/unit/Controller/DirectControllerTest.php
+++ b/apps/dav/tests/unit/Controller/DirectControllerTest.php
@@ -59,7 +59,7 @@ class DirectControllerTest extends TestCase {
/** @var DirectController */
private $controller;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->rootFolder = $this->createMock(IRootFolder::class);
diff --git a/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php b/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php
index 44ca70b9342..c465f62eba7 100644
--- a/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php
+++ b/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php
@@ -52,7 +52,7 @@ class InvitationResponseControllerTest extends TestCase {
/** @var InvitationResponseServer|\PHPUnit_Framework_MockObject_MockObject */
private $responseServer;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->dbConnection = $this->createMock(IDBConnection::class);
diff --git a/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php b/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php
index d43e42b93b7..9c4c20c945b 100644
--- a/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php
+++ b/apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php
@@ -45,7 +45,7 @@ class CustomPropertiesBackendTest extends TestCase {
/** @var CustomPropertiesBackend | \PHPUnit_Framework_MockObject_MockObject */
private $backend;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->tree = $this->createMock(Tree::class);
diff --git a/apps/dav/tests/unit/DAV/GroupPrincipalTest.php b/apps/dav/tests/unit/DAV/GroupPrincipalTest.php
index 356299dab56..f0fda89ee92 100644
--- a/apps/dav/tests/unit/DAV/GroupPrincipalTest.php
+++ b/apps/dav/tests/unit/DAV/GroupPrincipalTest.php
@@ -49,7 +49,7 @@ class GroupPrincipalTest extends \Test\TestCase {
/** @var GroupPrincipalBackend */
private $connector;
- public function setUp(): void {
+ protected function setUp(): void {
$this->groupManager = $this->createMock(IGroupManager::class);
$this->userSession = $this->createMock(IUserSession::class);
$this->shareManager = $this->createMock(IManager::class);
@@ -174,11 +174,11 @@ class GroupPrincipalTest extends \Test\TestCase {
$this->assertSame([], $response);
}
- /**
- * @expectedException \Sabre\DAV\Exception
- * @expectedExceptionMessage Setting members of the group is not supported yet
- */
+
public function testSetGroupMembership() {
+ $this->expectException(\Sabre\DAV\Exception::class);
+ $this->expectExceptionMessage('Setting members of the group is not supported yet');
+
$this->connector->setGroupMemberSet('principals/groups/foo', ['foo']);
}
diff --git a/apps/dav/tests/unit/DAV/HookManagerTest.php b/apps/dav/tests/unit/DAV/HookManagerTest.php
index 6b64abc8442..2a5f52cc4bd 100644
--- a/apps/dav/tests/unit/DAV/HookManagerTest.php
+++ b/apps/dav/tests/unit/DAV/HookManagerTest.php
@@ -46,7 +46,7 @@ class HookManagerTest extends TestCase {
/** @var EventDispatcherInterface | \PHPUnit_Framework_MockObject_MockObject */
private $eventDispatcher;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->eventDispatcher = $this->createMock(EventDispatcherInterface::class);
$this->l10n = $this->createMock(IL10N::class);
diff --git a/apps/dav/tests/unit/DAV/Sharing/PluginTest.php b/apps/dav/tests/unit/DAV/Sharing/PluginTest.php
index 38eb86baf27..69a76c3f8f9 100644
--- a/apps/dav/tests/unit/DAV/Sharing/PluginTest.php
+++ b/apps/dav/tests/unit/DAV/Sharing/PluginTest.php
@@ -44,7 +44,7 @@ class PluginTest extends TestCase {
/** @var IShareable | \PHPUnit_Framework_MockObject_MockObject */
private $book;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
/** @var Auth | \PHPUnit_Framework_MockObject_MockObject $authBackend */
diff --git a/apps/dav/tests/unit/DAV/SystemPrincipalBackendTest.php b/apps/dav/tests/unit/DAV/SystemPrincipalBackendTest.php
index 5833847cfed..32d6d47c206 100644
--- a/apps/dav/tests/unit/DAV/SystemPrincipalBackendTest.php
+++ b/apps/dav/tests/unit/DAV/SystemPrincipalBackendTest.php
@@ -80,13 +80,14 @@ class SystemPrincipalBackendTest extends TestCase {
/**
* @dataProvider providesPrincipalForGetGroupMemberSet
- * @expectedException \Sabre\DAV\Exception
- * @expectedExceptionMessage Principal not found
*
* @param string $principal
* @throws \Sabre\DAV\Exception
*/
public function testGetGroupMemberSetExceptional($principal) {
+ $this->expectException(\Sabre\DAV\Exception::class);
+ $this->expectExceptionMessage('Principal not found');
+
$backend = new SystemPrincipalBackend();
$backend->getGroupMemberSet($principal);
}
@@ -109,13 +110,14 @@ class SystemPrincipalBackendTest extends TestCase {
/**
* @dataProvider providesPrincipalForGetGroupMembership
- * @expectedException \Sabre\DAV\Exception
- * @expectedExceptionMessage Principal not found
*
* @param string $principal
* @throws \Sabre\DAV\Exception
*/
public function testGetGroupMembershipExceptional($principal) {
+ $this->expectException(\Sabre\DAV\Exception::class);
+ $this->expectExceptionMessage('Principal not found');
+
$backend = new SystemPrincipalBackend();
$backend->getGroupMembership($principal);
}
diff --git a/apps/dav/tests/unit/Direct/DirectFileTest.php b/apps/dav/tests/unit/Direct/DirectFileTest.php
index c48b34bb175..5d2831c5bde 100644
--- a/apps/dav/tests/unit/Direct/DirectFileTest.php
+++ b/apps/dav/tests/unit/Direct/DirectFileTest.php
@@ -49,7 +49,7 @@ class DirectFileTest extends TestCase {
/** @var DirectFile */
private $directFile;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->direct = Direct::fromParams([
diff --git a/apps/dav/tests/unit/Direct/DirectHomeTest.php b/apps/dav/tests/unit/Direct/DirectHomeTest.php
index 8a976ff5dbf..ca71be06274 100644
--- a/apps/dav/tests/unit/Direct/DirectHomeTest.php
+++ b/apps/dav/tests/unit/Direct/DirectHomeTest.php
@@ -58,7 +58,7 @@ class DirectHomeTest extends TestCase {
/** @var DirectHome */
private $directHome;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->directMapper = $this->createMock(DirectMapper::class);
diff --git a/apps/dav/tests/unit/Files/FileSearchBackendTest.php b/apps/dav/tests/unit/Files/FileSearchBackendTest.php
index b524af5f390..723fb9f4049 100644
--- a/apps/dav/tests/unit/Files/FileSearchBackendTest.php
+++ b/apps/dav/tests/unit/Files/FileSearchBackendTest.php
@@ -258,10 +258,10 @@ class FileSearchBackendTest extends TestCase {
$this->assertEquals('/files/test/test/path', $result[0]->href);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testSearchInvalidProp() {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->tree->expects($this->any())
->method('getNodeForPath')
->willReturn($this->davFolder);
@@ -295,10 +295,10 @@ class FileSearchBackendTest extends TestCase {
return new Query($select, $from, $where, $orderBy, $limit);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testSearchNonFolder() {
+ $this->expectException(\InvalidArgumentException::class);
+
$davNode = $this->createMock(File::class);
$this->tree->expects($this->any())
diff --git a/apps/dav/tests/unit/Files/Sharing/FilesDropPluginTest.php b/apps/dav/tests/unit/Files/Sharing/FilesDropPluginTest.php
index f311b0f2cb3..344b6b7df51 100644
--- a/apps/dav/tests/unit/Files/Sharing/FilesDropPluginTest.php
+++ b/apps/dav/tests/unit/Files/Sharing/FilesDropPluginTest.php
@@ -48,7 +48,7 @@ class FilesDropPluginTest extends TestCase {
/** @var ResponseInterface|\PHPUnit_Framework_MockObject_MockObject */
private $response;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->view = $this->createMock(View::class);
diff --git a/apps/dav/tests/unit/Migration/CalDAVRemoveEmptyValueTest.php b/apps/dav/tests/unit/Migration/CalDAVRemoveEmptyValueTest.php
index 063bf485501..63dd3480b20 100644
--- a/apps/dav/tests/unit/Migration/CalDAVRemoveEmptyValueTest.php
+++ b/apps/dav/tests/unit/Migration/CalDAVRemoveEmptyValueTest.php
@@ -89,7 +89,7 @@ CREATED:20151214T091032Z
END:VEVENT
END:VCALENDAR';
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->logger = $this->createMock(ILogger::class);
diff --git a/apps/dav/tests/unit/Provisioning/Apple/AppleProvisioningNodeTest.php b/apps/dav/tests/unit/Provisioning/Apple/AppleProvisioningNodeTest.php
index 2f65fc7c45f..0253592ede0 100644
--- a/apps/dav/tests/unit/Provisioning/Apple/AppleProvisioningNodeTest.php
+++ b/apps/dav/tests/unit/Provisioning/Apple/AppleProvisioningNodeTest.php
@@ -34,7 +34,7 @@ class AppleProvisioningNodeTest extends TestCase {
/** @var AppleProvisioningNode */
private $node;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->timeFactory = $this->createMock(ITimeFactory::class);
@@ -45,11 +45,11 @@ class AppleProvisioningNodeTest extends TestCase {
$this->assertEquals('apple-provisioning.mobileconfig', $this->node->getName());
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- * @expectedExceptionMessage Renaming apple-provisioning.mobileconfig is forbidden
- */
+
public function testSetName() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+ $this->expectExceptionMessage('Renaming apple-provisioning.mobileconfig is forbidden');
+
$this->node->setName('foo');
}
@@ -57,11 +57,11 @@ class AppleProvisioningNodeTest extends TestCase {
$this->assertEquals(null, $this->node->getLastModified());
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- * @expectedExceptionMessage apple-provisioning.mobileconfig may not be deleted
- */
+
public function testDelete() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+ $this->expectExceptionMessage('apple-provisioning.mobileconfig may not be deleted');
+
$this->node->delete();
}
@@ -76,11 +76,11 @@ class AppleProvisioningNodeTest extends TestCase {
], $this->node->getProperties([]));
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- * @expectedExceptionMessage apple-provisioning.mobileconfig's properties may not be altered.
- */
+
public function testGetPropPatch() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+ $this->expectExceptionMessage('apple-provisioning.mobileconfig\'s properties may not be altered.');
+
$propPatch = $this->createMock(PropPatch::class);
$this->node->propPatch($propPatch);
diff --git a/apps/dav/tests/unit/Provisioning/Apple/AppleProvisioningPluginTest.php b/apps/dav/tests/unit/Provisioning/Apple/AppleProvisioningPluginTest.php
index eeadf349710..e6d5b6217d0 100644
--- a/apps/dav/tests/unit/Provisioning/Apple/AppleProvisioningPluginTest.php
+++ b/apps/dav/tests/unit/Provisioning/Apple/AppleProvisioningPluginTest.php
@@ -59,7 +59,7 @@ class AppleProvisioningPluginTest extends TestCase {
/** @var AppleProvisioningPlugin */
protected $plugin;
- 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/Settings/CalDAVSettingsTest.php b/apps/dav/tests/unit/Settings/CalDAVSettingsTest.php
index 17bcf9fba97..3f201eba17e 100644
--- a/apps/dav/tests/unit/Settings/CalDAVSettingsTest.php
+++ b/apps/dav/tests/unit/Settings/CalDAVSettingsTest.php
@@ -35,7 +35,7 @@ class CalDAVSettingsTest extends TestCase {
/** @var CalDAVSettings */
private $settings;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
diff --git a/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php b/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php
index 926c652b77e..bd4afe9fb10 100644
--- a/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php
+++ b/apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php
@@ -144,10 +144,10 @@ class SystemTagMappingNodeTest extends \Test\TestCase {
$this->assertInstanceOf($expectedException, $thrown);
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotFound
- */
+
public function testDeleteTagNotFound() {
+ $this->expectException(\Sabre\DAV\Exception\NotFound::class);
+
// assuming the tag existed at the time the node was created,
// but got deleted concurrently in the database
$tag = new SystemTag(1, 'Test', true, true);
diff --git a/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php b/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php
index d2bd59bff65..53df8c91969 100644
--- a/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php
+++ b/apps/dav/tests/unit/SystemTag/SystemTagNodeTest.php
@@ -81,10 +81,10 @@ class SystemTagNodeTest extends \Test\TestCase {
$this->assertEquals($tag, $node->getSystemTag());
}
- /**
- * @expectedException \Sabre\DAV\Exception\MethodNotAllowed
- */
+
public function testSetName() {
+ $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class);
+
$this->getTagNode()->setName('2');
}
@@ -198,10 +198,10 @@ class SystemTagNodeTest extends \Test\TestCase {
$this->assertInstanceOf($expectedException, $thrown);
}
- /**
- * @expectedException \Sabre\DAV\Exception\Conflict
- */
+
public function testUpdateTagAlreadyExists() {
+ $this->expectException(\Sabre\DAV\Exception\Conflict::class);
+
$tag = new SystemTag(1, 'tag1', true, true);
$this->tagManager->expects($this->any())
->method('canUserSeeTag')
@@ -218,10 +218,10 @@ class SystemTagNodeTest extends \Test\TestCase {
$this->getTagNode(false, $tag)->update('Renamed', true, true);
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotFound
- */
+
public function testUpdateTagNotFound() {
+ $this->expectException(\Sabre\DAV\Exception\NotFound::class);
+
$tag = new SystemTag(1, 'tag1', true, true);
$this->tagManager->expects($this->any())
->method('canUserSeeTag')
@@ -286,10 +286,10 @@ class SystemTagNodeTest extends \Test\TestCase {
$this->getTagNode(false, $tag)->delete();
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotFound
- */
+
public function testDeleteTagNotFound() {
+ $this->expectException(\Sabre\DAV\Exception\NotFound::class);
+
$tag = new SystemTag(1, 'tag1', true, true);
$this->tagManager->expects($this->any())
->method('canUserSeeTag')
diff --git a/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php b/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php
index 1282807842a..8ac14ff6cbc 100644
--- a/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php
+++ b/apps/dav/tests/unit/SystemTag/SystemTagPluginTest.php
@@ -85,7 +85,7 @@ class SystemTagPluginTest extends \Test\TestCase {
*/
private $plugin;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->tree = $this->getMockBuilder(Tree::class)
->disableOriginalConstructor()
@@ -234,10 +234,10 @@ class SystemTagPluginTest extends \Test\TestCase {
$this->assertEquals($expectedProperties, $result[200]);
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testGetPropertiesForbidden() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$systemTag = new SystemTag(1, 'Test', true, false);
$requestedProperties = [
self::ID_PROPERTYNAME,
@@ -331,10 +331,10 @@ class SystemTagPluginTest extends \Test\TestCase {
$this->assertEquals(200, $result[self::USERVISIBLE_PROPERTYNAME]);
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testUpdatePropertiesForbidden() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$systemTag = new SystemTag(1, 'Test', true, false);
$this->user->expects($this->any())
->method('getUID')
@@ -385,10 +385,11 @@ class SystemTagPluginTest extends \Test\TestCase {
}
/**
* @dataProvider createTagInsufficientPermissionsProvider
- * @expectedException \Sabre\DAV\Exception\BadRequest
- * @expectedExceptionMessage Not sufficient permissions
*/
public function testCreateNotAssignableTagAsRegularUser($userVisible, $userAssignable, $groups) {
+ $this->expectException(\Sabre\DAV\Exception\BadRequest::class);
+ $this->expectExceptionMessage('Not sufficient permissions');
+
$this->user->expects($this->once())
->method('getUID')
->willReturn('admin');
@@ -658,10 +659,10 @@ class SystemTagPluginTest extends \Test\TestCase {
$this->plugin->httpPost($request, $response);
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotFound
- */
+
public function testCreateTagToUnknownNode() {
+ $this->expectException(\Sabre\DAV\Exception\NotFound::class);
+
$node = $this->getMockBuilder(SystemTagsObjectMappingCollection::class)
->disableOriginalConstructor()
->getMock();
@@ -692,9 +693,10 @@ class SystemTagPluginTest extends \Test\TestCase {
/**
* @dataProvider nodeClassProvider
- * @expectedException \Sabre\DAV\Exception\Conflict
*/
public function testCreateTagConflict($nodeClass) {
+ $this->expectException(\Sabre\DAV\Exception\Conflict::class);
+
$this->user->expects($this->once())
->method('getUID')
->willReturn('admin');
diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php
index da46843a5b2..496caebc907 100644
--- a/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php
+++ b/apps/dav/tests/unit/SystemTag/SystemTagsByIdCollectionTest.php
@@ -80,17 +80,17 @@ class SystemTagsByIdCollectionTest extends \Test\TestCase {
return [[true], [false]];
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testForbiddenCreateFile() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$this->getNode()->createFile('555');
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testForbiddenCreateDirectory() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$this->getNode()->createDirectory('789');
}
@@ -113,10 +113,10 @@ class SystemTagsByIdCollectionTest extends \Test\TestCase {
$this->assertEquals($tag, $childNode->getSystemTag());
}
- /**
- * @expectedException \Sabre\DAV\Exception\BadRequest
- */
+
public function testGetChildInvalidName() {
+ $this->expectException(\Sabre\DAV\Exception\BadRequest::class);
+
$this->tagManager->expects($this->once())
->method('getTagsByIds')
->with(['invalid'])
@@ -125,10 +125,10 @@ class SystemTagsByIdCollectionTest extends \Test\TestCase {
$this->getNode()->getChild('invalid');
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotFound
- */
+
public function testGetChildNotFound() {
+ $this->expectException(\Sabre\DAV\Exception\NotFound::class);
+
$this->tagManager->expects($this->once())
->method('getTagsByIds')
->with(['444'])
@@ -137,10 +137,10 @@ class SystemTagsByIdCollectionTest extends \Test\TestCase {
$this->getNode()->getChild('444');
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotFound
- */
+
public function testGetChildUserNotVisible() {
+ $this->expectException(\Sabre\DAV\Exception\NotFound::class);
+
$tag = new SystemTag(123, 'Test', false, false);
$this->tagManager->expects($this->once())
@@ -231,10 +231,10 @@ class SystemTagsByIdCollectionTest extends \Test\TestCase {
$this->assertFalse($this->getNode()->childExists('123'));
}
- /**
- * @expectedException \Sabre\DAV\Exception\BadRequest
- */
+
public function testChildExistsBadRequest() {
+ $this->expectException(\Sabre\DAV\Exception\BadRequest::class);
+
$this->tagManager->expects($this->once())
->method('getTagsByIds')
->with(['invalid'])
diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php
index ff56ae3d447..7efe6b19c78 100644
--- a/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php
+++ b/apps/dav/tests/unit/SystemTag/SystemTagsObjectMappingCollectionTest.php
@@ -133,10 +133,10 @@ class SystemTagsObjectMappingCollectionTest extends \Test\TestCase {
$this->assertInstanceOf($expectedException, $thrown);
}
- /**
- * @expectedException \Sabre\DAV\Exception\PreconditionFailed
- */
+
public function testAssignTagNotFound() {
+ $this->expectException(\Sabre\DAV\Exception\PreconditionFailed::class);
+
$this->tagManager->expects($this->once())
->method('getTagsByIds')
->with(['555'])
@@ -145,10 +145,10 @@ class SystemTagsObjectMappingCollectionTest extends \Test\TestCase {
$this->getNode()->createFile('555');
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testForbiddenCreateDirectory() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$this->getNode()->createDirectory('789');
}
@@ -175,10 +175,10 @@ class SystemTagsObjectMappingCollectionTest extends \Test\TestCase {
$this->assertEquals('555', $childNode->getName());
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotFound
- */
+
public function testGetChildNonVisible() {
+ $this->expectException(\Sabre\DAV\Exception\NotFound::class);
+
$tag = new SystemTag(555, 'TheTag', false, false);
$this->tagManager->expects($this->once())
->method('canUserSeeTag')
@@ -198,10 +198,10 @@ class SystemTagsObjectMappingCollectionTest extends \Test\TestCase {
$this->getNode()->getChild('555');
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotFound
- */
+
public function testGetChildRelationNotFound() {
+ $this->expectException(\Sabre\DAV\Exception\NotFound::class);
+
$this->tagMapper->expects($this->once())
->method('haveTag')
->with([111], 'files', '777')
@@ -210,10 +210,10 @@ class SystemTagsObjectMappingCollectionTest extends \Test\TestCase {
$this->getNode()->getChild('777');
}
- /**
- * @expectedException \Sabre\DAV\Exception\BadRequest
- */
+
public function testGetChildInvalidId() {
+ $this->expectException(\Sabre\DAV\Exception\BadRequest::class);
+
$this->tagMapper->expects($this->once())
->method('haveTag')
->with([111], 'files', 'badid')
@@ -222,10 +222,10 @@ class SystemTagsObjectMappingCollectionTest extends \Test\TestCase {
$this->getNode()->getChild('badid');
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotFound
- */
+
public function testGetChildTagDoesNotExist() {
+ $this->expectException(\Sabre\DAV\Exception\NotFound::class);
+
$this->tagMapper->expects($this->once())
->method('haveTag')
->with([111], 'files', '777')
@@ -326,10 +326,10 @@ class SystemTagsObjectMappingCollectionTest extends \Test\TestCase {
$this->assertFalse($this->getNode()->childExists('555'));
}
- /**
- * @expectedException \Sabre\DAV\Exception\BadRequest
- */
+
public function testChildExistsInvalidId() {
+ $this->expectException(\Sabre\DAV\Exception\BadRequest::class);
+
$this->tagMapper->expects($this->once())
->method('haveTag')
->with([111], 'files', '555')
@@ -338,17 +338,17 @@ class SystemTagsObjectMappingCollectionTest extends \Test\TestCase {
$this->getNode()->childExists('555');
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testDelete() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$this->getNode()->delete();
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testSetName() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$this->getNode()->setName('somethingelse');
}
diff --git a/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php b/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php
index 5e4e539b1e7..90b6e703a71 100644
--- a/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php
+++ b/apps/dav/tests/unit/SystemTag/SystemTagsObjectTypeCollectionTest.php
@@ -98,17 +98,17 @@ class SystemTagsObjectTypeCollectionTest extends \Test\TestCase {
);
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testForbiddenCreateFile() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$this->node->createFile('555');
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testForbiddenCreateDirectory() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$this->node->createDirectory('789');
}
@@ -123,10 +123,10 @@ class SystemTagsObjectTypeCollectionTest extends \Test\TestCase {
$this->assertEquals('555', $childNode->getName());
}
- /**
- * @expectedException \Sabre\DAV\Exception\NotFound
- */
+
public function testGetChildWithoutAccess() {
+ $this->expectException(\Sabre\DAV\Exception\NotFound::class);
+
$this->userFolder->expects($this->once())
->method('getById')
->with('555')
@@ -134,10 +134,10 @@ class SystemTagsObjectTypeCollectionTest extends \Test\TestCase {
$this->node->getChild('555');
}
- /**
- * @expectedException \Sabre\DAV\Exception\MethodNotAllowed
- */
+
public function testGetChildren() {
+ $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class);
+
$this->node->getChildren();
}
@@ -157,17 +157,17 @@ class SystemTagsObjectTypeCollectionTest extends \Test\TestCase {
$this->assertFalse($this->node->childExists('555'));
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testDelete() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$this->node->delete();
}
- /**
- * @expectedException \Sabre\DAV\Exception\Forbidden
- */
+
public function testSetName() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$this->node->setName('somethingelse');
}
diff --git a/apps/dav/tests/unit/Upload/ChunkingPluginTest.php b/apps/dav/tests/unit/Upload/ChunkingPluginTest.php
index bc2b434bcf7..3135ced2612 100644
--- a/apps/dav/tests/unit/Upload/ChunkingPluginTest.php
+++ b/apps/dav/tests/unit/Upload/ChunkingPluginTest.php
@@ -51,7 +51,7 @@ class ChunkingPluginTest extends TestCase {
/** @var ResponseInterface | \PHPUnit_Framework_MockObject_MockObject */
private $response;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->server = $this->getMockBuilder('\Sabre\DAV\Server')
@@ -141,11 +141,11 @@ class ChunkingPluginTest extends TestCase {
$this->assertFalse($this->plugin->beforeMove('source', 'target'));
}
- /**
- * @expectedException \Sabre\DAV\Exception\BadRequest
- * @expectedExceptionMessage Chunks on server do not sum up to 4 but to 3 bytes
- */
+
public function testBeforeMoveSizeIsWrong() {
+ $this->expectException(\Sabre\DAV\Exception\BadRequest::class);
+ $this->expectExceptionMessage('Chunks on server do not sum up to 4 but to 3 bytes');
+
$sourceNode = $this->createMock(FutureFile::class);
$sourceNode->expects($this->once())
->method('getSize')
diff --git a/apps/dav/tests/unit/Upload/FutureFileTest.php b/apps/dav/tests/unit/Upload/FutureFileTest.php
index 94be4ea66dd..cfe3491d13f 100644
--- a/apps/dav/tests/unit/Upload/FutureFileTest.php
+++ b/apps/dav/tests/unit/Upload/FutureFileTest.php
@@ -73,18 +73,18 @@ class FutureFileTest extends \Test\TestCase {
$f->delete();
}
- /**
- * @expectedException Sabre\DAV\Exception\Forbidden
- */
+
public function testPut() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$f = $this->mockFutureFile();
$f->put('');
}
- /**
- * @expectedException Sabre\DAV\Exception\Forbidden
- */
+
public function testSetName() {
+ $this->expectException(\Sabre\DAV\Exception\Forbidden::class);
+
$f = $this->mockFutureFile();
$f->setName('');
}
diff --git a/apps/encryption/tests/Command/TestEnableMasterKey.php b/apps/encryption/tests/Command/TestEnableMasterKey.php
index ef6bd9eec22..927cc1328df 100644
--- a/apps/encryption/tests/Command/TestEnableMasterKey.php
+++ b/apps/encryption/tests/Command/TestEnableMasterKey.php
@@ -53,7 +53,7 @@ class TestEnableMasterKey extends TestCase {
/** @var \Symfony\Component\Console\Input\InputInterface | \PHPUnit_Framework_MockObject_MockObject */
protected $input;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->util = $this->getMockBuilder(Util::class)
diff --git a/apps/encryption/tests/Crypto/CryptTest.php b/apps/encryption/tests/Crypto/CryptTest.php
index 1731f25d532..053c4ce8f03 100644
--- a/apps/encryption/tests/Crypto/CryptTest.php
+++ b/apps/encryption/tests/Crypto/CryptTest.php
@@ -53,7 +53,7 @@ class CryptTest extends TestCase {
/** @var Crypt */
private $crypt;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->logger = $this->getMockBuilder(ILogger::class)
@@ -132,9 +132,10 @@ class CryptTest extends TestCase {
/**
* test generateHeader with invalid key format
*
- * @expectedException \InvalidArgumentException
*/
public function testGenerateHeaderInvalid() {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->crypt->generateHeader('unknown');
}
@@ -252,9 +253,10 @@ class CryptTest extends TestCase {
/**
* @dataProvider dataTestHasSignatureFail
- * @expectedException \OCP\Encryption\Exceptions\GenericEncryptionException
*/
public function testHasSignatureFail($cipher) {
+ $this->expectException(\OCP\Encryption\Exceptions\GenericEncryptionException::class);
+
$data = 'encryptedContent00iv001234567890123456xx';
$this->invokePrivate($this->crypt, 'hasSignature', array($data, $cipher));
}
@@ -371,9 +373,10 @@ class CryptTest extends TestCase {
/**
* test exception if cipher is unknown
*
- * @expectedException \InvalidArgumentException
*/
public function testGetKeySizeFailure() {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->invokePrivate($this->crypt, 'getKeySize', ['foo']);
}
diff --git a/apps/encryption/tests/Crypto/DecryptAllTest.php b/apps/encryption/tests/Crypto/DecryptAllTest.php
index b314bb5b543..1b94d1d96cf 100644
--- a/apps/encryption/tests/Crypto/DecryptAllTest.php
+++ b/apps/encryption/tests/Crypto/DecryptAllTest.php
@@ -53,7 +53,7 @@ class DecryptAllTest extends TestCase {
/** @var QuestionHelper | \PHPUnit_Framework_MockObject_MockObject */
protected $questionHelper;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->util = $this->getMockBuilder(Util::class)
diff --git a/apps/encryption/tests/Crypto/EncryptAllTest.php b/apps/encryption/tests/Crypto/EncryptAllTest.php
index f5f042aac66..f8be7210054 100644
--- a/apps/encryption/tests/Crypto/EncryptAllTest.php
+++ b/apps/encryption/tests/Crypto/EncryptAllTest.php
@@ -90,7 +90,7 @@ class EncryptAllTest extends TestCase {
/** @var EncryptAll */
protected $encryptAll;
- function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->setupUser = $this->getMockBuilder(Setup::class)
->disableOriginalConstructor()->getMock();
diff --git a/apps/encryption/tests/Crypto/EncryptionTest.php b/apps/encryption/tests/Crypto/EncryptionTest.php
index 4136673a6ec..94e0729317f 100644
--- a/apps/encryption/tests/Crypto/EncryptionTest.php
+++ b/apps/encryption/tests/Crypto/EncryptionTest.php
@@ -73,7 +73,7 @@ class EncryptionTest extends TestCase {
/** @var \OCP\Files\Storage|\PHPUnit_Framework_MockObject_MockObject */
private $storageMock;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->storageMock = $this->getMockBuilder(Storage::class)
@@ -131,9 +131,10 @@ class EncryptionTest extends TestCase {
/**
* test if public key from owner is missing
*
- * @expectedException \OCA\Encryption\Exceptions\PublicKeyMissingException
*/
public function testEndUser2() {
+ $this->expectException(\OCA\Encryption\Exceptions\PublicKeyMissingException::class);
+
$this->instance->begin('/foo/bar', 'user2', 'r', array(), array('users' => array('user1', 'user2', 'user3')));
$this->endTest();
}
@@ -431,11 +432,11 @@ class EncryptionTest extends TestCase {
);
}
- /**
- * @expectedException \OC\Encryption\Exceptions\DecryptionFailedException
- * @expectedExceptionMessage Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you.
- */
+
public function testDecrypt() {
+ $this->expectException(\OC\Encryption\Exceptions\DecryptionFailedException::class);
+ $this->expectExceptionMessage('Can not decrypt this file, probably this is a shared file. Please ask the file owner to reshare the file with you.');
+
$this->instance->decrypt('abc');
}
diff --git a/apps/encryption/tests/HookManagerTest.php b/apps/encryption/tests/HookManagerTest.php
index 5ff76f918d4..39797942256 100644
--- a/apps/encryption/tests/HookManagerTest.php
+++ b/apps/encryption/tests/HookManagerTest.php
@@ -38,9 +38,7 @@ class HookManagerTest extends TestCase {
*/
private static $instance;
- /**
- *
- */
+
public function testRegisterHookWithArray() {
self::$instance->registerHook([
$this->getMockBuilder(IHook::class)->disableOriginalConstructor()->getMock(),
@@ -54,9 +52,7 @@ class HookManagerTest extends TestCase {
}
- /**
- *
- */
+
public static function setUpBeforeClass(): void {
parent::setUpBeforeClass();
// have to make instance static to preserve data between tests
@@ -64,9 +60,7 @@ class HookManagerTest extends TestCase {
}
- /**
- *
- */
+
public function testRegisterHooksWithInstance() {
$mock = $this->getMockBuilder(IHook::class)->disableOriginalConstructor()->getMock();
/** @var \OCA\Encryption\Hooks\Contracts\IHook $mock */
diff --git a/apps/encryption/tests/KeyManagerTest.php b/apps/encryption/tests/KeyManagerTest.php
index 6e5c51db3c8..fd2cac6461b 100644
--- a/apps/encryption/tests/KeyManagerTest.php
+++ b/apps/encryption/tests/KeyManagerTest.php
@@ -79,7 +79,7 @@ class KeyManagerTest extends TestCase {
/** @var \OCP\IConfig|\PHPUnit_Framework_MockObject_MockObject */
private $configMock;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->userId = 'user1';
$this->systemKeyId = 'systemKeyId';
@@ -220,10 +220,10 @@ class KeyManagerTest extends TestCase {
];
}
- /**
- * @expectedException \OCA\Encryption\Exceptions\PrivateKeyMissingException
- */
+
public function testUserHasKeysMissingPrivateKey() {
+ $this->expectException(\OCA\Encryption\Exceptions\PrivateKeyMissingException::class);
+
$this->keyStorageMock->expects($this->exactly(2))
->method('getUserKey')
->willReturnCallback(function ($uid, $keyID, $encryptionModuleId) {
@@ -236,10 +236,10 @@ class KeyManagerTest extends TestCase {
$this->instance->userHasKeys($this->userId);
}
- /**
- * @expectedException \OCA\Encryption\Exceptions\PublicKeyMissingException
- */
+
public function testUserHasKeysMissingPublicKey() {
+ $this->expectException(\OCA\Encryption\Exceptions\PublicKeyMissingException::class);
+
$this->keyStorageMock->expects($this->exactly(2))
->method('getUserKey')
->willReturnCallback(function ($uid, $keyID, $encryptionModuleId){
@@ -536,10 +536,10 @@ class KeyManagerTest extends TestCase {
);
}
- /**
- * @expectedException \Exception
- */
+
public function testGetMasterKeyPasswordException() {
+ $this->expectException(\Exception::class);
+
$this->configMock->expects($this->once())->method('getSystemValue')->with('secret')
->willReturn('');
diff --git a/apps/encryption/tests/SessionTest.php b/apps/encryption/tests/SessionTest.php
index 25c652b36af..5a0a65c77b3 100644
--- a/apps/encryption/tests/SessionTest.php
+++ b/apps/encryption/tests/SessionTest.php
@@ -41,11 +41,11 @@ class SessionTest extends TestCase {
/** @var \OCP\ISession|\PHPUnit_Framework_MockObject_MockObject */
private $sessionMock;
- /**
- * @expectedException \OCA\Encryption\Exceptions\PrivateKeyMissingException
- * @expectedExceptionMessage Private Key missing for user: please try to log-out and log-in again
- */
+
public function testThatGetPrivateKeyThrowsExceptionWhenNotSet() {
+ $this->expectException(\OCA\Encryption\Exceptions\PrivateKeyMissingException::class);
+ $this->expectExceptionMessage('Private Key missing for user: please try to log-out and log-in again');
+
$this->instance->getPrivateKey();
}
@@ -84,42 +84,44 @@ class SessionTest extends TestCase {
}
/**
- * @expectedException \Exception
* @expectExceptionMessage 'Please activate decrypt all mode first'
*/
public function testGetDecryptAllUidException() {
+ $this->expectException(\Exception::class);
+
$this->instance->getDecryptAllUid();
}
/**
- * @expectedException \Exception
* @expectExceptionMessage 'No uid found while in decrypt all mode'
*/
public function testGetDecryptAllUidException2() {
+ $this->expectException(\Exception::class);
+
$this->instance->prepareDecryptAll(null, 'key');
$this->instance->getDecryptAllUid();
}
/**
- * @expectedException \OCA\Encryption\Exceptions\PrivateKeyMissingException
* @expectExceptionMessage 'Please activate decrypt all mode first'
*/
public function testGetDecryptAllKeyException() {
+ $this->expectException(\OCA\Encryption\Exceptions\PrivateKeyMissingException::class);
+
$this->instance->getDecryptAllKey();
}
/**
- * @expectedException \OCA\Encryption\Exceptions\PrivateKeyMissingException
* @expectExceptionMessage 'No key found while in decrypt all mode'
*/
public function testGetDecryptAllKeyException2() {
+ $this->expectException(\OCA\Encryption\Exceptions\PrivateKeyMissingException::class);
+
$this->instance->prepareDecryptAll('user', null);
$this->instance->getDecryptAllKey();
}
- /**
- *
- */
+
public function testSetAndGetStatusWillSetAndReturn() {
// Check if get status will return 0 if it has not been set before
$this->assertEquals(0, $this->instance->getStatus());
@@ -186,9 +188,7 @@ class SessionTest extends TestCase {
return null;
}
- /**
- *
- */
+
public function testClearWillRemoveValues() {
$this->instance->setPrivateKey('privateKey');
$this->instance->setStatus('initStatus');
@@ -198,9 +198,7 @@ class SessionTest extends TestCase {
$this->assertEmpty(self::$tempStorage);
}
- /**
- *
- */
+
protected function setUp(): void {
parent::setUp();
$this->sessionMock = $this->createMock(ISession::class);
diff --git a/apps/encryption/tests/Settings/AdminTest.php b/apps/encryption/tests/Settings/AdminTest.php
index 9df483916b7..8f68f06b6bd 100644
--- a/apps/encryption/tests/Settings/AdminTest.php
+++ b/apps/encryption/tests/Settings/AdminTest.php
@@ -50,7 +50,7 @@ class AdminTest extends TestCase {
/** @var ISession */
private $session;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->l = $this->getMockBuilder(IL10N::class)->getMock();
diff --git a/apps/federatedfilesharing/tests/AddressHandlerTest.php b/apps/federatedfilesharing/tests/AddressHandlerTest.php
index efea34dbab2..e6ef4ddd7f3 100644
--- a/apps/federatedfilesharing/tests/AddressHandlerTest.php
+++ b/apps/federatedfilesharing/tests/AddressHandlerTest.php
@@ -46,7 +46,7 @@ class AddressHandlerTest extends \Test\TestCase {
/** @var CloudIdManager */
private $cloudIdManager;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)
@@ -125,9 +125,10 @@ class AddressHandlerTest extends \Test\TestCase {
* @dataProvider dataTestSplitUserRemoteError
*
* @param string $id
- * @expectedException \OC\HintException
*/
public function testSplitUserRemoteError($id) {
+ $this->expectException(\OC\HintException::class);
+
$this->addressHandler->splitUserRemote($id);
}
diff --git a/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php b/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php
index 88f486f3c69..405d83cc91c 100644
--- a/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php
+++ b/apps/federatedfilesharing/tests/Controller/MountPublicLinkControllerTest.php
@@ -84,7 +84,7 @@ class MountPublicLinkControllerTest extends \Test\TestCase {
/** @var ICloudIdManager */
private $cloudIdManager;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->getMockBuilder(IRequest::class)->disableOriginalConstructor()->getMock();
diff --git a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php
index 31d13df8f31..1e0863fe1ce 100644
--- a/apps/federatedfilesharing/tests/FederatedShareProviderTest.php
+++ b/apps/federatedfilesharing/tests/FederatedShareProviderTest.php
@@ -85,7 +85,7 @@ class FederatedShareProviderTest extends \Test\TestCase {
/** @var \PHPUnit_Framework_MockObject_MockObject|ICloudFederationProviderManager */
private $cloudFederationProviderManager;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
@@ -131,7 +131,7 @@ class FederatedShareProviderTest extends \Test\TestCase {
$this->shareManager = \OC::$server->getShareManager();
}
- public function tearDown(): void {
+ protected function tearDown(): void {
$this->connection->getQueryBuilder()->delete('share')->execute();
parent::tearDown();
diff --git a/apps/federatedfilesharing/tests/NotificationsTest.php b/apps/federatedfilesharing/tests/NotificationsTest.php
index 769184f1628..abc8e9495bc 100644
--- a/apps/federatedfilesharing/tests/NotificationsTest.php
+++ b/apps/federatedfilesharing/tests/NotificationsTest.php
@@ -53,7 +53,7 @@ class NotificationsTest extends \Test\TestCase {
/** @var ICloudFederationFactory|\PHPUnit_Framework_MockObject_MockObject */
private $cloudFederationFactory;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->jobList = $this->getMockBuilder('OCP\BackgroundJob\IJobList')->getMock();
diff --git a/apps/federatedfilesharing/tests/Settings/AdminTest.php b/apps/federatedfilesharing/tests/Settings/AdminTest.php
index bca8ad73426..7eccf846f4b 100644
--- a/apps/federatedfilesharing/tests/Settings/AdminTest.php
+++ b/apps/federatedfilesharing/tests/Settings/AdminTest.php
@@ -38,7 +38,7 @@ class AdminTest extends TestCase {
/** @var IConfig|\PHPUnit_Framework_MockObject_MockObject */
private $gsConfig;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->federatedShareProvider = $this->createMock(FederatedShareProvider::class);
$this->gsConfig = $this->createMock(IConfig::class);
diff --git a/apps/federatedfilesharing/tests/TokenHandlerTest.php b/apps/federatedfilesharing/tests/TokenHandlerTest.php
index bd3c0f92911..56039b1f801 100644
--- a/apps/federatedfilesharing/tests/TokenHandlerTest.php
+++ b/apps/federatedfilesharing/tests/TokenHandlerTest.php
@@ -39,7 +39,7 @@ class TokenHandlerTest extends \Test\TestCase {
/** @var int */
private $expectedTokenLength = 15;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->secureRandom = $this->getMockBuilder(ISecureRandom::class)->getMock();
diff --git a/apps/federation/tests/BackgroundJob/GetSharedSecretTest.php b/apps/federation/tests/BackgroundJob/GetSharedSecretTest.php
index b4e8365b502..c0d7c2f6b7d 100644
--- a/apps/federation/tests/BackgroundJob/GetSharedSecretTest.php
+++ b/apps/federation/tests/BackgroundJob/GetSharedSecretTest.php
@@ -81,7 +81,7 @@ class GetSharedSecretTest extends TestCase {
/** @var GetSharedSecret */
private $getSharedSecret;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->httpClientService = $this->createMock(IClientService::class);
diff --git a/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php b/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php
index d97919942af..3eed5b89f7f 100644
--- a/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php
+++ b/apps/federation/tests/BackgroundJob/RequestSharedSecretTest.php
@@ -73,7 +73,7 @@ class RequestSharedSecretTest extends TestCase {
/** @var RequestSharedSecret */
private $requestSharedSecret;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->httpClientService = $this->createMock(IClientService::class);
diff --git a/apps/federation/tests/Controller/OCSAuthAPIControllerTest.php b/apps/federation/tests/Controller/OCSAuthAPIControllerTest.php
index c625d960e5a..d862faeae1b 100644
--- a/apps/federation/tests/Controller/OCSAuthAPIControllerTest.php
+++ b/apps/federation/tests/Controller/OCSAuthAPIControllerTest.php
@@ -67,7 +67,7 @@ class OCSAuthAPIControllerTest extends TestCase {
/** @var int simulated timestamp */
private $currentTime = 1234567;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
diff --git a/apps/federation/tests/Controller/SettingsControllerTest.php b/apps/federation/tests/Controller/SettingsControllerTest.php
index 9b283b50903..2aa2a454f66 100644
--- a/apps/federation/tests/Controller/SettingsControllerTest.php
+++ b/apps/federation/tests/Controller/SettingsControllerTest.php
@@ -45,7 +45,7 @@ class SettingsControllerTest extends TestCase {
/** @var \PHPUnit_Framework_MockObject_MockObject | \OCA\Federation\TrustedServers */
private $trustedServers;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->getMockBuilder(IRequest::class)->getMock();
@@ -84,12 +84,13 @@ class SettingsControllerTest extends TestCase {
/**
* @dataProvider checkServerFails
- * @expectedException \OC\HintException
*
* @param bool $isTrustedServer
* @param bool $isOwnCloud
*/
public function testAddServerFail($isTrustedServer, $isOwnCloud) {
+ $this->expectException(\OC\HintException::class);
+
$this->trustedServers
->expects($this->any())
->method('isTrustedServer')
@@ -132,12 +133,13 @@ class SettingsControllerTest extends TestCase {
/**
* @dataProvider checkServerFails
- * @expectedException \OC\HintException
*
* @param bool $isTrustedServer
* @param bool $isOwnCloud
*/
public function testCheckServerFail($isTrustedServer, $isOwnCloud) {
+ $this->expectException(\OC\HintException::class);
+
$this->trustedServers
->expects($this->any())
->method('isTrustedServer')
diff --git a/apps/federation/tests/DbHandlerTest.php b/apps/federation/tests/DbHandlerTest.php
index 348f5b70308..8d1eaa0ebc3 100644
--- a/apps/federation/tests/DbHandlerTest.php
+++ b/apps/federation/tests/DbHandlerTest.php
@@ -49,7 +49,7 @@ class DbHandlerTest extends TestCase {
/** @var string */
private $dbTable = 'trusted_servers';
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
@@ -65,7 +65,7 @@ class DbHandlerTest extends TestCase {
$this->assertEmpty($result, 'we need to start with a empty trusted_servers table');
}
- public function tearDown(): void {
+ protected function tearDown(): void {
parent::tearDown();
$query = $this->connection->getQueryBuilder()->delete($this->dbTable);
$query->execute();
diff --git a/apps/federation/tests/HooksTest.php b/apps/federation/tests/HooksTest.php
index ad6e0bf8a77..027db171990 100644
--- a/apps/federation/tests/HooksTest.php
+++ b/apps/federation/tests/HooksTest.php
@@ -36,7 +36,7 @@ class HooksTest extends TestCase {
/** @var Hooks */
private $hooks;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->trustedServers = $this->getMockBuilder('OCA\Federation\TrustedServers')
diff --git a/apps/federation/tests/Middleware/AddServerMiddlewareTest.php b/apps/federation/tests/Middleware/AddServerMiddlewareTest.php
index 4423233b93e..1557fb08330 100644
--- a/apps/federation/tests/Middleware/AddServerMiddlewareTest.php
+++ b/apps/federation/tests/Middleware/AddServerMiddlewareTest.php
@@ -48,7 +48,7 @@ class AddServerMiddlewareTest extends TestCase {
/** @var \PHPUnit_Framework_MockObject_MockObject | SettingsController */
private $controller;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->logger = $this->getMockBuilder(ILogger::class)->getMock();
diff --git a/apps/federation/tests/Settings/AdminTest.php b/apps/federation/tests/Settings/AdminTest.php
index 0fc1f7c25ab..ed7c049cc44 100644
--- a/apps/federation/tests/Settings/AdminTest.php
+++ b/apps/federation/tests/Settings/AdminTest.php
@@ -34,7 +34,7 @@ class AdminTest extends TestCase {
/** @var TrustedServers */
private $trustedServers;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->trustedServers = $this->getMockBuilder('\OCA\Federation\TrustedServers')->disableOriginalConstructor()->getMock();
$this->admin = new Admin(
diff --git a/apps/federation/tests/SyncFederationAddressbooksTest.php b/apps/federation/tests/SyncFederationAddressbooksTest.php
index e1c810bde97..09b567e9435 100644
--- a/apps/federation/tests/SyncFederationAddressbooksTest.php
+++ b/apps/federation/tests/SyncFederationAddressbooksTest.php
@@ -38,7 +38,7 @@ class SyncFederationAddressbooksTest extends \Test\TestCase {
/** @var \PHPUnit_Framework_MockObject_MockObject | DiscoveryService */
private $discoveryService;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->discoveryService = $this->getMockBuilder(DiscoveryService::class)
diff --git a/apps/federation/tests/TrustedServersTest.php b/apps/federation/tests/TrustedServersTest.php
index 82e5654e63f..2b1f8174e09 100644
--- a/apps/federation/tests/TrustedServersTest.php
+++ b/apps/federation/tests/TrustedServersTest.php
@@ -76,7 +76,7 @@ class TrustedServersTest extends TestCase {
/** @var \PHPUnit_Framework_MockObject_MockObject|ITimeFactory */
private $timeFactory;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->dbHandler = $this->getMockBuilder(DbHandler::class)
@@ -352,10 +352,11 @@ class TrustedServersTest extends TestCase {
/**
* @dataProvider dataTestCheckOwnCloudVersionTooLow
- * @expectedException \OC\HintException
- * @expectedExceptionMessage Remote server version is too low. 9.0 is required.
*/
public function testCheckOwnCloudVersionTooLow($status) {
+ $this->expectException(\OC\HintException::class);
+ $this->expectExceptionMessage('Remote server version is too low. 9.0 is required.');
+
$this->invokePrivate($this->trustedServers, 'checkOwnCloudVersion', [$status]);
}
diff --git a/apps/files/tests/Activity/Filter/GenericTest.php b/apps/files/tests/Activity/Filter/GenericTest.php
index f2b1acba3b3..8cae50c99c9 100644
--- a/apps/files/tests/Activity/Filter/GenericTest.php
+++ b/apps/files/tests/Activity/Filter/GenericTest.php
@@ -60,7 +60,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());
}
/**
@@ -70,7 +70,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());
}
/**
@@ -81,7 +81,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);
}
@@ -93,7 +93,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());
}
@@ -104,7 +104,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([]));
}
/**
@@ -114,6 +114,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/files/tests/Activity/ProviderTest.php b/apps/files/tests/Activity/ProviderTest.php
index da1f014ad05..cb8a2175307 100644
--- a/apps/files/tests/Activity/ProviderTest.php
+++ b/apps/files/tests/Activity/ProviderTest.php
@@ -55,7 +55,7 @@ class ProviderTest extends TestCase {
/** @var IEventMerger|\PHPUnit_Framework_MockObject_MockObject */
protected $eventMerger;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->l10nFactory = $this->createMock(IFactory::class);
@@ -136,10 +136,10 @@ class ProviderTest extends TestCase {
$this->assertSame('link-' . $id, $result['link']);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testGetFileThrows() {
+ $this->expectException(\InvalidArgumentException::class);
+
$provider = $this->getProvider();
self::invokePrivate($provider, 'getFile', ['/Foo/Bar.txt', null]);
}
diff --git a/apps/files/tests/Activity/Setting/GenericTest.php b/apps/files/tests/Activity/Setting/GenericTest.php
index a8df291cb80..e93919ffd4d 100644
--- a/apps/files/tests/Activity/Setting/GenericTest.php
+++ b/apps/files/tests/Activity/Setting/GenericTest.php
@@ -61,7 +61,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());
}
/**
@@ -71,7 +71,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());
}
/**
@@ -82,7 +82,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);
}
@@ -94,7 +94,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());
}
/**
@@ -104,7 +104,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());
}
/**
@@ -114,7 +114,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());
}
/**
@@ -124,6 +124,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/files/tests/BackgroundJob/ScanFilesTest.php b/apps/files/tests/BackgroundJob/ScanFilesTest.php
index 8539c6ba7d3..f4110cfbad0 100644
--- a/apps/files/tests/BackgroundJob/ScanFilesTest.php
+++ b/apps/files/tests/BackgroundJob/ScanFilesTest.php
@@ -42,7 +42,7 @@ class ScanFilesTest extends TestCase {
/** @var ScanFiles */
private $scanFiles;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
diff --git a/apps/files/tests/Controller/ApiControllerTest.php b/apps/files/tests/Controller/ApiControllerTest.php
index e5fbe7d3868..bd27fc2537d 100644
--- a/apps/files/tests/Controller/ApiControllerTest.php
+++ b/apps/files/tests/Controller/ApiControllerTest.php
@@ -68,7 +68,7 @@ class ApiControllerTest extends TestCase {
/** @var Folder|\PHPUnit_Framework_MockObject_MockObject */
private $userFolder;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->getMockBuilder(IRequest::class)
diff --git a/apps/files/tests/Controller/ViewControllerTest.php b/apps/files/tests/Controller/ViewControllerTest.php
index c57be81b487..0e109128c5b 100644
--- a/apps/files/tests/Controller/ViewControllerTest.php
+++ b/apps/files/tests/Controller/ViewControllerTest.php
@@ -76,7 +76,7 @@ class ViewControllerTest extends TestCase {
/** @var Helper|\PHPUnit_Framework_MockObject_MockObject */
private $activityHelper;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->getMockBuilder(IRequest::class)->getMock();
$this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)->getMock();
diff --git a/apps/files_external/tests/Auth/Password/GlobalAuth.php b/apps/files_external/tests/Auth/Password/GlobalAuth.php
index 15f8f5f47a9..7c28f1b3f53 100644
--- a/apps/files_external/tests/Auth/Password/GlobalAuth.php
+++ b/apps/files_external/tests/Auth/Password/GlobalAuth.php
@@ -105,10 +105,10 @@ class GlobalAuthTest extends TestCase {
], $storage->getBackendOptions());
}
- /**
- * @expectedException \OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException
- */
+
public function testNoCredentialsPersonal() {
+ $this->expectException(\OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException::class);
+
$this->credentialsManager->expects($this->never())
->method('retrieve');
diff --git a/apps/files_external/tests/Config/UserPlaceholderHandlerTest.php b/apps/files_external/tests/Config/UserPlaceholderHandlerTest.php
index 006bb458370..ba064b8fb6f 100644
--- a/apps/files_external/tests/Config/UserPlaceholderHandlerTest.php
+++ b/apps/files_external/tests/Config/UserPlaceholderHandlerTest.php
@@ -50,7 +50,7 @@ class UserPlaceholderHandlerTest extends \Test\TestCase {
/** @var UserPlaceholderHandler */
protected $handler;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->user = $this->createMock(IUser::class);
diff --git a/apps/files_external/tests/Controller/AjaxControllerTest.php b/apps/files_external/tests/Controller/AjaxControllerTest.php
index a940f49fc2a..6bb9c3418ee 100644
--- a/apps/files_external/tests/Controller/AjaxControllerTest.php
+++ b/apps/files_external/tests/Controller/AjaxControllerTest.php
@@ -48,7 +48,7 @@ class AjaxControllerTest extends TestCase {
/** @var AjaxController */
private $ajaxController;
- public function setUp(): void {
+ protected function setUp(): void {
$this->request = $this->createMock(IRequest::class);
$this->rsa = $this->getMockBuilder('\\OCA\\Files_External\\Lib\\Auth\\PublicKey\\RSA')
->disableOriginalConstructor()
diff --git a/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php b/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php
index bcc8d3e2d98..458714e463a 100644
--- a/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php
+++ b/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php
@@ -34,7 +34,7 @@ use OCP\ILogger;
use OCP\IRequest;
class GlobalStoragesControllerTest extends StoragesControllerTest {
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->service = $this->getMockBuilder('\OCA\Files_External\Service\GlobalStoragesService')
->disableOriginalConstructor()
diff --git a/apps/files_external/tests/Controller/StoragesControllerTest.php b/apps/files_external/tests/Controller/StoragesControllerTest.php
index 184b7a6c699..d865b3e8d0f 100644
--- a/apps/files_external/tests/Controller/StoragesControllerTest.php
+++ b/apps/files_external/tests/Controller/StoragesControllerTest.php
@@ -46,11 +46,11 @@ abstract class StoragesControllerTest extends \Test\TestCase {
*/
protected $service;
- public function setUp(): void {
+ protected function setUp(): void {
\OC_Mount_Config::$skipTest = true;
}
- public function tearDown(): void {
+ protected function tearDown(): void {
\OC_Mount_Config::$skipTest = false;
}
diff --git a/apps/files_external/tests/Controller/UserStoragesControllerTest.php b/apps/files_external/tests/Controller/UserStoragesControllerTest.php
index ddd6d01717e..f130af7c76f 100644
--- a/apps/files_external/tests/Controller/UserStoragesControllerTest.php
+++ b/apps/files_external/tests/Controller/UserStoragesControllerTest.php
@@ -42,7 +42,7 @@ class UserStoragesControllerTest extends StoragesControllerTest {
*/
private $oldAllowedBackends;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->service = $this->getMockBuilder('\OCA\Files_External\Service\UserStoragesService')
->disableOriginalConstructor()
diff --git a/apps/files_external/tests/Service/BackendServiceTest.php b/apps/files_external/tests/Service/BackendServiceTest.php
index 8cd1e680dea..526098dc2b4 100644
--- a/apps/files_external/tests/Service/BackendServiceTest.php
+++ b/apps/files_external/tests/Service/BackendServiceTest.php
@@ -234,9 +234,10 @@ class BackendServiceTest extends \Test\TestCase {
/**
* @dataProvider invalidConfigPlaceholderProvider
- * @expectedException \RuntimeException
*/
public function testRegisterConfigHandlerInvalid(array $placeholders) {
+ $this->expectException(\RuntimeException::class);
+
$service = new BackendService($this->config);
$mock = $this->createMock(IConfigHandler::class);
$cb = function () use ($mock) { return $mock; };
diff --git a/apps/files_external/tests/Service/DBConfigServiceTest.php b/apps/files_external/tests/Service/DBConfigServiceTest.php
index 375f1e7018a..7a04a8f61b7 100644
--- a/apps/files_external/tests/Service/DBConfigServiceTest.php
+++ b/apps/files_external/tests/Service/DBConfigServiceTest.php
@@ -44,13 +44,13 @@ class DBConfigServiceTest extends TestCase {
private $mounts = [];
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
$this->dbConfig = new DBConfigService($this->connection, \OC::$server->getCrypto());
}
- public function tearDown(): void {
+ protected function tearDown(): void {
foreach ($this->mounts as $mount) {
$this->dbConfig->removeMount($mount);
}
diff --git a/apps/files_external/tests/Service/GlobalStoragesServiceTest.php b/apps/files_external/tests/Service/GlobalStoragesServiceTest.php
index c4d1055521a..37ae71696f0 100644
--- a/apps/files_external/tests/Service/GlobalStoragesServiceTest.php
+++ b/apps/files_external/tests/Service/GlobalStoragesServiceTest.php
@@ -33,12 +33,12 @@ use OCA\Files_External\Service\GlobalStoragesService;
* @group DB
*/
class GlobalStoragesServiceTest extends StoragesServiceTest {
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->service = new GlobalStoragesService($this->backendService, $this->dbConfig, $this->mountCache);
}
- public function tearDown(): void {
+ protected function tearDown(): void {
@unlink($this->dataDir . '/mount.json');
parent::tearDown();
}
@@ -471,8 +471,7 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
}
}
- /**
- */
+
public function testHooksRenameMountPoint() {
$storage = $this->makeTestStorageData();
$storage->setApplicableUsers(['user1', 'user2']);
diff --git a/apps/files_external/tests/Service/StoragesServiceTest.php b/apps/files_external/tests/Service/StoragesServiceTest.php
index 4e2b73f2612..140bbdc772b 100644
--- a/apps/files_external/tests/Service/StoragesServiceTest.php
+++ b/apps/files_external/tests/Service/StoragesServiceTest.php
@@ -92,7 +92,7 @@ abstract class StoragesServiceTest extends \Test\TestCase {
*/
protected $mountCache;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->dbConfig = new CleaningDBConfig(\OC::$server->getDatabaseConnection(), \OC::$server->getCrypto());
self::$hookCalls = array();
@@ -175,7 +175,7 @@ abstract class StoragesServiceTest extends \Test\TestCase {
->willReturn($containerMock);
}
- public function tearDown(): void {
+ protected function tearDown(): void {
\OC_Mount_Config::$skipTest = false;
self::$hookCalls = array();
if ($this->dbConfig) {
@@ -252,10 +252,10 @@ abstract class StoragesServiceTest extends \Test\TestCase {
}
- /**
- * @expectedException \OCA\Files_External\NotFoundException
- */
+
public function testNonExistingStorage() {
+ $this->expectException(\OCA\Files_External\NotFoundException::class);
+
$backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB');
$authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism');
$storage = new StorageConfig(255);
@@ -334,10 +334,10 @@ abstract class StoragesServiceTest extends \Test\TestCase {
$this->assertCount($expectedCountAfterDeletion, $storages, "expected $expectedCountAfterDeletion storages, got " . json_encode($storages));
}
- /**
- * @expectedException \OCA\Files_External\NotFoundException
- */
+
public function testDeleteUnexistingStorage() {
+ $this->expectException(\OCA\Files_External\NotFoundException::class);
+
$this->service->removeStorage(255);
}
diff --git a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php
index 9a6100d8075..83a0d9c7fd7 100644
--- a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php
+++ b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php
@@ -60,7 +60,7 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
const GROUP_ID = 'test_group';
const GROUP_ID2 = 'test_group2';
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->globalStoragesService = $this->service;
@@ -158,10 +158,10 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
}
- /**
- * @expectedException \DomainException
- */
+
public function testAddStorage($storageParams = null) {
+ $this->expectException(\DomainException::class);
+
$backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB');
$authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism');
@@ -174,10 +174,10 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
$this->service->addStorage($storage);
}
- /**
- * @expectedException \DomainException
- */
+
public function testUpdateStorage($storageParams = null) {
+ $this->expectException(\DomainException::class);
+
$backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB');
$authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism');
@@ -194,18 +194,19 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
$this->service->updateStorage($retrievedStorage);
}
- /**
- * @expectedException \DomainException
- */
+
public function testNonExistingStorage() {
+ $this->expectException(\DomainException::class);
+
parent::testNonExistingStorage();
}
/**
- * @expectedException \DomainException
* @dataProvider deleteStorageDataProvider
*/
public function testDeleteStorage($backendOptions, $rustyStorageId, $expectedCountAfterDeletion) {
+ $this->expectException(\DomainException::class);
+
$backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB');
$authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism');
@@ -221,10 +222,10 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
$this->service->removeStorage($id);
}
- /**
- * @expectedException \DomainException
- */
+
public function testDeleteUnexistingStorage() {
+ $this->expectException(\DomainException::class);
+
parent::testDeleteUnexistingStorage();
}
diff --git a/apps/files_external/tests/Service/UserStoragesServiceTest.php b/apps/files_external/tests/Service/UserStoragesServiceTest.php
index ce0b3ab65b1..7b9d16211e0 100644
--- a/apps/files_external/tests/Service/UserStoragesServiceTest.php
+++ b/apps/files_external/tests/Service/UserStoragesServiceTest.php
@@ -50,7 +50,7 @@ class UserStoragesServiceTest extends StoragesServiceTest {
*/
protected $globalStoragesService;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->globalStoragesService = new GlobalStoragesService($this->backendService, $this->dbConfig, $this->mountCache);
@@ -189,10 +189,10 @@ class UserStoragesServiceTest extends StoragesServiceTest {
);
}
- /**
- * @expectedException \OCA\Files_External\NotFoundException
- */
+
public function testGetAdminStorage() {
+ $this->expectException(\OCA\Files_External\NotFoundException::class);
+
$backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\SMB');
$authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism');
diff --git a/apps/files_external/tests/Settings/AdminTest.php b/apps/files_external/tests/Settings/AdminTest.php
index 3889fe456e4..1d24cbbde10 100644
--- a/apps/files_external/tests/Settings/AdminTest.php
+++ b/apps/files_external/tests/Settings/AdminTest.php
@@ -43,7 +43,7 @@ class AdminTest extends TestCase {
/** @var GlobalAuth|\PHPUnit_Framework_MockObject_MockObject */
private $globalAuth;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->encryptionManager = $this->createMock(IManager::class);
$this->globalStoragesService = $this->createMock(GlobalStoragesService::class);
diff --git a/apps/files_external/tests/Settings/SectionTest.php b/apps/files_external/tests/Settings/SectionTest.php
index 3a8a4f5f780..b9ce3e3aa9a 100644
--- a/apps/files_external/tests/Settings/SectionTest.php
+++ b/apps/files_external/tests/Settings/SectionTest.php
@@ -37,7 +37,7 @@ class SectionTest extends TestCase {
/** @var Section */
private $section;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)->disableOriginalConstructor()->getMock();
$this->l = $this->getMockBuilder(IL10N::class)->disableOriginalConstructor()->getMock();
diff --git a/apps/files_external/tests/Storage/SFTP_KeyTest.php b/apps/files_external/tests/Storage/SFTP_KeyTest.php
index fe40c0fbd95..4e8e6431a72 100644
--- a/apps/files_external/tests/Storage/SFTP_KeyTest.php
+++ b/apps/files_external/tests/Storage/SFTP_KeyTest.php
@@ -60,10 +60,10 @@ class SFTP_KeyTest extends \Test\Files\Storage\Storage {
parent::tearDown();
}
- /**
- * @expectedException InvalidArgumentException
- */
+
public function testInvalidAddressShouldThrowException() {
+ $this->expectException(\InvalidArgumentException::class);
+
// I'd use example.com for this, but someone decided to break the spec and make it resolve
$this->instance->assertHostAddressValid('notarealaddress...');
}
@@ -72,24 +72,24 @@ class SFTP_KeyTest extends \Test\Files\Storage\Storage {
$this->assertTrue($this->instance->assertHostAddressValid('localhost'));
}
- /**
- * @expectedException InvalidArgumentException
- */
+
public function testNegativePortNumberShouldThrowException() {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->instance->assertPortNumberValid('-1');
}
- /**
- * @expectedException InvalidArgumentException
- */
+
public function testNonNumericalPortNumberShouldThrowException() {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->instance->assertPortNumberValid('a');
}
- /**
- * @expectedException InvalidArgumentException
- */
- public function testHighPortNumberShouldThrowException() {
+
+ public function testHighPortNumberShouldThrowException() {
+ $this->expectException(\InvalidArgumentException::class);
+
$this->instance->assertPortNumberValid('65536');
}
diff --git a/apps/files_sharing/tests/CapabilitiesTest.php b/apps/files_sharing/tests/CapabilitiesTest.php
index 493f607dba2..3f8dd85c10b 100644
--- a/apps/files_sharing/tests/CapabilitiesTest.php
+++ b/apps/files_sharing/tests/CapabilitiesTest.php
@@ -92,7 +92,7 @@ class CapabilitiesTest extends \Test\TestCase {
['core', 'shareapi_allow_links', 'yes', 'no'],
];
$result = $this->getResults($map);
- $this->assertInternalType('array', $result['public']);
+ $this->assertIsArray($result['public']);
$this->assertFalse($result['public']['enabled']);
}
@@ -102,7 +102,7 @@ class CapabilitiesTest extends \Test\TestCase {
['core', 'shareapi_allow_links', 'yes', 'yes'],
];
$result = $this->getResults($map);
- $this->assertInternalType('array', $result['public']);
+ $this->assertIsArray($result['public']);
$this->assertTrue($result['public']['enabled']);
}
@@ -138,7 +138,7 @@ class CapabilitiesTest extends \Test\TestCase {
];
$result = $this->getResults($map);
$this->assertArrayHasKey('expire_date', $result['public']);
- $this->assertInternalType('array', $result['public']['expire_date']);
+ $this->assertIsArray($result['public']['expire_date']);
$this->assertFalse($result['public']['expire_date']['enabled']);
}
@@ -152,7 +152,7 @@ class CapabilitiesTest extends \Test\TestCase {
];
$result = $this->getResults($map);
$this->assertArrayHasKey('expire_date', $result['public']);
- $this->assertInternalType('array', $result['public']['expire_date']);
+ $this->assertIsArray($result['public']['expire_date']);
$this->assertTrue($result['public']['expire_date']['enabled']);
$this->assertArrayHasKey('days', $result['public']['expire_date']);
$this->assertFalse($result['public']['expire_date']['enforced']);
@@ -167,7 +167,7 @@ class CapabilitiesTest extends \Test\TestCase {
];
$result = $this->getResults($map);
$this->assertArrayHasKey('expire_date', $result['public']);
- $this->assertInternalType('array', $result['public']['expire_date']);
+ $this->assertIsArray($result['public']['expire_date']);
$this->assertTrue($result['public']['expire_date']['enforced']);
}
diff --git a/apps/files_sharing/tests/Collaboration/ShareRecipientSorterTest.php b/apps/files_sharing/tests/Collaboration/ShareRecipientSorterTest.php
index 93bef4afbf6..146bb565a81 100644
--- a/apps/files_sharing/tests/Collaboration/ShareRecipientSorterTest.php
+++ b/apps/files_sharing/tests/Collaboration/ShareRecipientSorterTest.php
@@ -43,7 +43,7 @@ class ShareRecipientSorterTest extends TestCase {
/** @var ShareRecipientSorter */
protected $sorter;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->shareManager = $this->createMock(IManager::class);
diff --git a/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php b/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php
index 4e100cf2099..102210e3b1e 100644
--- a/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php
+++ b/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php
@@ -110,7 +110,7 @@ class CleanupRemoteStoragesTest extends TestCase {
$this->command = new CleanupRemoteStorages($this->connection);
}
- public function tearDown(): void {
+ protected function tearDown(): void {
$storageQuery = \OC::$server->getDatabaseConnection()->getQueryBuilder();
$storageQuery->delete('storages')
->where($storageQuery->expr()->eq('id', $storageQuery->createParameter('id')));
diff --git a/apps/files_sharing/tests/Controller/ExternalShareControllerTest.php b/apps/files_sharing/tests/Controller/ExternalShareControllerTest.php
index d2237acbd7f..5296a1ad0c3 100644
--- a/apps/files_sharing/tests/Controller/ExternalShareControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ExternalShareControllerTest.php
@@ -43,7 +43,7 @@ class ExternalShareControllerTest extends \Test\TestCase {
/** @var IClientService */
private $clientService;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->getMockBuilder('\\OCP\\IRequest')
->disableOriginalConstructor()->getMock();
diff --git a/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php b/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php
index cbe3872bb67..834796bf431 100644
--- a/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php
+++ b/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php
@@ -54,7 +54,7 @@ class PublicPreviewControllerTest extends TestCase {
/** @var PublicPreviewController */
private $controller;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->previewManager = $this->createMock(IPreview::class);
diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
index 7a50a752044..ae7fc54599c 100644
--- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
@@ -164,11 +164,11 @@ class ShareAPIControllerTest extends TestCase {
return \OC::$server->getShareManager()->newShare();
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Wrong share ID, share doesn't exist
- */
+
public function testDeleteShareShareNotFound() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Wrong share ID, share doesn\'t exist');
+
$this->shareManager
->expects($this->exactly(3))
->method('getShareById')
@@ -212,11 +212,11 @@ class ShareAPIControllerTest extends TestCase {
$this->assertEquals($expected->getData(), $result->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Could not delete share
- */
+
public function testDeleteShareLocked() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Could not delete share');
+
$node = $this->getMockBuilder(File::class)->getMock();
$share = $this->newShare();
@@ -401,10 +401,11 @@ class ShareAPIControllerTest extends TestCase {
/**
* You cannot remove a share if you're not
* in the group the share is shared with
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Wrong share ID, share doesn't exist
*/
public function testDeleteSharedWithGroupIDontBelongTo() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Wrong share ID, share doesn\'t exist');
+
$node = $this->getMockBuilder(File::class)->getMock();
$share = $this->newShare();
@@ -767,11 +768,11 @@ class ShareAPIControllerTest extends TestCase {
$this->assertEquals($result, $ocs->getShare($share->getId())->getData()[0]);
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Wrong share ID, share doesn't exist
- */
+
public function testGetShareInvalidNode() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Wrong share ID, share doesn\'t exist');
+
$share = \OC::$server->getShareManager()->newShare();
$share->setSharedBy('initiator')
->setSharedWith('recipient')
@@ -1533,19 +1534,19 @@ class ShareAPIControllerTest extends TestCase {
$this->assertEquals($expected, $this->invokePrivate($this->ocs, 'canAccessShare', [$share]));
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Please specify a file or folder path
- */
+
public function testCreateShareNoPath() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Please specify a file or folder path');
+
$this->ocs->createShare();
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Wrong path, file/folder doesn't exist
- */
+
public function testCreateShareInvalidPath() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Wrong path, file/folder doesn\'t exist');
+
$userFolder = $this->getMockBuilder(Folder::class)->getMock();
$this->rootFolder->expects($this->once())
->method('getUserFolder')
@@ -1560,11 +1561,11 @@ class ShareAPIControllerTest extends TestCase {
$this->ocs->createShare('invalid-path');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage invalid permissions
- */
+
public function testCreateShareInvalidPermissions() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('invalid permissions');
+
$share = $this->newShare();
$this->shareManager->method('newShare')->willReturn($share);
@@ -1587,11 +1588,11 @@ class ShareAPIControllerTest extends TestCase {
$this->ocs->createShare('valid-path', 32);
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Please specify a valid user
- */
+
public function testCreateShareUserNoShareWith() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Please specify a valid user');
+
$share = $this->newShare();
$this->shareManager->method('newShare')->willReturn($share);
@@ -1619,11 +1620,11 @@ class ShareAPIControllerTest extends TestCase {
$this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER);
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Please specify a valid user
- */
+
public function testCreateShareUserNoValidShareWith() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Please specify a valid user');
+
$share = $this->newShare();
$this->shareManager->method('newShare')->willReturn($share);
@@ -1719,11 +1720,11 @@ class ShareAPIControllerTest extends TestCase {
$this->assertEquals($expected->getData(), $result->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Please specify a valid group
- */
+
public function testCreateShareGroupNoValidShareWith() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Please specify a valid group');
+
$share = $this->newShare();
$this->shareManager->method('newShare')->willReturn($share);
$this->shareManager->method('createShare')->will($this->returnArgument(0));
@@ -1828,11 +1829,11 @@ class ShareAPIControllerTest extends TestCase {
$this->assertEquals($expected->getData(), $result->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Group sharing is disabled by the administrator
- */
+
public function testCreateShareGroupNotAllowed() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Group sharing is disabled by the administrator');
+
$share = $this->newShare();
$this->shareManager->method('newShare')->willReturn($share);
@@ -1862,11 +1863,11 @@ class ShareAPIControllerTest extends TestCase {
$this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, 'invalidGroup');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Public link sharing is disabled by the administrator
- */
+
public function testCreateShareLinkNoLinksAllowed() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Public link sharing is disabled by the administrator');
+
$this->request
->method('getParam')
->will($this->returnValueMap([
@@ -1888,11 +1889,11 @@ class ShareAPIControllerTest extends TestCase {
$this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK);
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSForbiddenException
- * @expectedExceptionMessage Public upload disabled by the administrator
- */
+
public function testCreateShareLinkNoPublicUpload() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSForbiddenException::class);
+ $this->expectExceptionMessage('Public upload disabled by the administrator');
+
$path = $this->getMockBuilder(Folder::class)->getMock();
$storage = $this->createMock(Storage::class);
$storage->method('instanceOfStorage')
@@ -1908,11 +1909,11 @@ class ShareAPIControllerTest extends TestCase {
$this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'true');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Public upload is only possible for publicly shared folders
- */
+
public function testCreateShareLinkPublicUploadFile() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Public upload is only possible for publicly shared folders');
+
$path = $this->getMockBuilder(File::class)->getMock();
$storage = $this->createMock(Storage::class);
$storage->method('instanceOfStorage')
@@ -2034,11 +2035,11 @@ class ShareAPIControllerTest extends TestCase {
$this->assertEquals($expected->getData(), $result->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSForbiddenException
- * @expectedExceptionMessage Sharing valid-path sending the password by Nextcloud Talk failed because Nextcloud Talk is not enabled
- */
+
public function testCreateShareLinkSendPasswordByTalkWithTalkDisabled() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSForbiddenException::class);
+ $this->expectExceptionMessage('Sharing valid-path sending the password by Nextcloud Talk failed because Nextcloud Talk is not enabled');
+
$ocs = $this->mockFormatShare();
$path = $this->getMockBuilder(Folder::class)->getMock();
@@ -2109,11 +2110,11 @@ class ShareAPIControllerTest extends TestCase {
$this->assertEquals($expected->getData(), $result->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Invalid date, date format must be YYYY-MM-DD
- */
+
public function testCreateShareInvalidExpireDate() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Invalid date, date format must be YYYY-MM-DD');
+
$ocs = $this->mockFormatShare();
$path = $this->getMockBuilder(Folder::class)->getMock();
@@ -2210,11 +2211,11 @@ class ShareAPIControllerTest extends TestCase {
$this->assertEquals($expected->getData(), $result->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSForbiddenException
- * @expectedExceptionMessage Sharing valid-path failed because the back end does not support room shares
- */
+
public function testCreateShareRoomHelperNotAvailable() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSForbiddenException::class);
+ $this->expectExceptionMessage('Sharing valid-path failed because the back end does not support room shares');
+
$ocs = $this->mockFormatShare();
$share = $this->newShare();
@@ -2251,11 +2252,11 @@ class ShareAPIControllerTest extends TestCase {
$ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_ROOM, 'recipientRoom');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Exception thrown by the helper
- */
+
public function testCreateShareRoomHelperThrowException() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Exception thrown by the helper');
+
$ocs = $this->mockFormatShare();
$share = $this->newShare();
@@ -2369,11 +2370,11 @@ class ShareAPIControllerTest extends TestCase {
$ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, 'validUser');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException
- * @expectedExceptionMessage Wrong share ID, share doesn't exist
- */
+
public function testUpdateShareCantAccess() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class);
+ $this->expectExceptionMessage('Wrong share ID, share doesn\'t exist');
+
$node = $this->getMockBuilder(Folder::class)->getMock();
$share = $this->newShare();
$share->setNode($node);
@@ -2396,11 +2397,11 @@ class ShareAPIControllerTest extends TestCase {
$this->ocs->updateShare(42);
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSBadRequestException
- * @expectedExceptionMessage Wrong or no update parameter given
- */
+
public function testUpdateNoParametersLink() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSBadRequestException::class);
+ $this->expectExceptionMessage('Wrong or no update parameter given');
+
$node = $this->getMockBuilder(Folder::class)->getMock();
$share = $this->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
@@ -2417,11 +2418,11 @@ class ShareAPIControllerTest extends TestCase {
$this->ocs->updateShare(42);
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSBadRequestException
- * @expectedExceptionMessage Wrong or no update parameter given
- */
+
public function testUpdateNoParametersOther() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSBadRequestException::class);
+ $this->expectExceptionMessage('Wrong or no update parameter given');
+
$node = $this->getMockBuilder(Folder::class)->getMock();
$share = $this->newShare();
$share->setPermissions(\OCP\Constants::PERMISSION_ALL)
@@ -2606,11 +2607,11 @@ class ShareAPIControllerTest extends TestCase {
$this->assertEquals($expected->getData(), $result->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSBadRequestException
- * @expectedExceptionMessage Invalid date. Format must be YYYY-MM-DD
- */
+
public function testUpdateLinkShareInvalidDate() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSBadRequestException::class);
+ $this->expectExceptionMessage('Invalid date. Format must be YYYY-MM-DD');
+
$ocs = $this->mockFormatShare();
$folder = $this->getMockBuilder(Folder::class)->getMock();
@@ -2645,10 +2646,11 @@ class ShareAPIControllerTest extends TestCase {
/**
* @dataProvider publicUploadParamsProvider
- * @expectedException \OCP\AppFramework\OCS\OCSForbiddenException
- * @expectedExceptionMessage Public upload disabled by the administrator
*/
public function testUpdateLinkSharePublicUploadNotAllowed($permissions, $publicUpload, $expireDate, $password) {
+ $this->expectException(\OCP\AppFramework\OCS\OCSForbiddenException::class);
+ $this->expectExceptionMessage('Public upload disabled by the administrator');
+
$ocs = $this->mockFormatShare();
$folder = $this->getMockBuilder(Folder::class)->getMock();
@@ -2665,11 +2667,11 @@ class ShareAPIControllerTest extends TestCase {
$ocs->updateShare(42, $permissions, $password, null, $publicUpload, $expireDate);
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSBadRequestException
- * @expectedExceptionMessage Public upload is only possible for publicly shared folders
- */
+
public function testUpdateLinkSharePublicUploadOnFile() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSBadRequestException::class);
+ $this->expectExceptionMessage('Public upload is only possible for publicly shared folders');
+
$ocs = $this->mockFormatShare();
$file = $this->getMockBuilder(File::class)->getMock();
@@ -2778,11 +2780,11 @@ class ShareAPIControllerTest extends TestCase {
$this->assertEquals($expected->getData(), $result->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSForbiddenException
- * @expectedExceptionMessage Sharing sending the password by Nextcloud Talk failed because Nextcloud Talk is not enabled
- */
+
public function testUpdateLinkShareSendPasswordByTalkWithTalkDisabledDoesNotChangeOther() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSForbiddenException::class);
+ $this->expectExceptionMessage('Sharing sending the password by Nextcloud Talk failed because Nextcloud Talk is not enabled');
+
$ocs = $this->mockFormatShare();
$date = new \DateTime('2000-01-01');
diff --git a/apps/files_sharing/tests/Controller/ShareControllerTest.php b/apps/files_sharing/tests/Controller/ShareControllerTest.php
index ec6fc9a598d..55981f00238 100644
--- a/apps/files_sharing/tests/Controller/ShareControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareControllerTest.php
@@ -532,10 +532,10 @@ class ShareControllerTest extends \Test\TestCase {
self::assertEquals($expectedResponse, $response);
}
- /**
- * @expectedException \OCP\Files\NotFoundException
- */
+
public function testShowShareInvalid() {
+ $this->expectException(\OCP\Files\NotFoundException::class);
+
$this->shareController->setToken('token');
$owner = $this->getMockBuilder(IUser::class)->getMock();
diff --git a/apps/files_sharing/tests/Controller/ShareInfoControllerTest.php b/apps/files_sharing/tests/Controller/ShareInfoControllerTest.php
index b8d87d5cd68..f2feb6e7fcc 100644
--- a/apps/files_sharing/tests/Controller/ShareInfoControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareInfoControllerTest.php
@@ -45,7 +45,7 @@ class ShareInfoControllerTest extends TestCase {
private $shareManager;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->shareManager = $this->createMock(ShareManager::class);
diff --git a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
index 20790fc0bfa..99f86525913 100644
--- a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php
@@ -397,11 +397,11 @@ class ShareesAPIControllerTest extends TestCase {
$this->assertSame($expected, $this->invokePrivate($this->sharees, 'isRemoteSharingAllowed', [$itemType]));
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSBadRequestException
- * @expectedExceptionMessage Missing itemType
- */
+
public function testSearchNoItemType() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSBadRequestException::class);
+ $this->expectExceptionMessage('Missing itemType');
+
$this->sharees->search('', null, 1, 10, [], false);
}
diff --git a/apps/files_sharing/tests/LockingTest.php b/apps/files_sharing/tests/LockingTest.php
index 47394fc588f..49f49da643f 100644
--- a/apps/files_sharing/tests/LockingTest.php
+++ b/apps/files_sharing/tests/LockingTest.php
@@ -46,7 +46,7 @@ class LockingTest extends TestCase {
private $ownerUid;
private $recipientUid;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->userBackend = new \Test\Util\User\Dummy();
@@ -74,15 +74,15 @@ class LockingTest extends TestCase {
$this->assertTrue(Filesystem::file_exists('bar.txt'));
}
- public function tearDown(): void {
+ protected function tearDown(): void {
\OC::$server->getUserManager()->removeBackend($this->userBackend);
parent::tearDown();
}
- /**
- * @expectedException \OCP\Lock\LockedException
- */
+
public function testLockAsRecipient() {
+ $this->expectException(\OCP\Lock\LockedException::class);
+
$this->loginAsUser($this->ownerUid);
Filesystem::initMountPoints($this->recipientUid);
diff --git a/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php b/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php
index 06d33859a28..31ca88cc4fc 100644
--- a/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php
+++ b/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php
@@ -44,7 +44,7 @@ class OCSShareAPIMiddlewareTest extends \Test\TestCase {
/** @var OCSShareAPIMiddleware */
private $middleware;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->shareManager = $this->createMock(IManager::class);
diff --git a/apps/files_sharing/tests/Middleware/ShareInfoMiddlewareTest.php b/apps/files_sharing/tests/Middleware/ShareInfoMiddlewareTest.php
index e6744d5fd1d..db698d94f11 100644
--- a/apps/files_sharing/tests/Middleware/ShareInfoMiddlewareTest.php
+++ b/apps/files_sharing/tests/Middleware/ShareInfoMiddlewareTest.php
@@ -41,7 +41,7 @@ class ShareInfoMiddlewareTest extends TestCase {
/** @var ShareInfoMiddleware */
private $middleware;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->shareManager = $this->createMock(ShareManager::class);
diff --git a/apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php b/apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php
index e3fb602acd6..7a2baba16e0 100644
--- a/apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php
+++ b/apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php
@@ -198,11 +198,11 @@ class SharingCheckMiddlewareTest extends \Test\TestCase {
$this->sharingCheckMiddleware->beforeController($controller, 'myMethod');
}
- /**
- * @expectedException \OCP\Files\NotFoundException
- * @expectedExceptionMessage Sharing is disabled.
- */
+
public function testBeforeControllerWithSharingDisabled() {
+ $this->expectException(\OCP\Files\NotFoundException::class);
+ $this->expectExceptionMessage('Sharing is disabled.');
+
$this->appManager
->expects($this->once())
->method('isEnabledForUser')
@@ -212,11 +212,11 @@ class SharingCheckMiddlewareTest extends \Test\TestCase {
$this->sharingCheckMiddleware->beforeController($this->controllerMock, 'myMethod');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage My Exception message
- */
+
public function testAfterExceptionWithRegularException() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('My Exception message');
+
$this->sharingCheckMiddleware->afterException($this->controllerMock, 'myMethod', new \Exception('My Exception message'));
}
diff --git a/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php b/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php
index 418ede9179a..b98b0b9fcd8 100644
--- a/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php
+++ b/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php
@@ -47,7 +47,7 @@ class SetPasswordColumnTest extends TestCase {
private $table = 'share';
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->connection = \OC::$server->getDatabaseConnection();
@@ -57,7 +57,7 @@ class SetPasswordColumnTest extends TestCase {
$this->cleanDB();
}
- public function tearDown(): void {
+ protected function tearDown(): void {
parent::tearDown();
$this->cleanDB();
}
diff --git a/apps/files_sharing/tests/MountProviderTest.php b/apps/files_sharing/tests/MountProviderTest.php
index 5b20524da47..06ca2060477 100644
--- a/apps/files_sharing/tests/MountProviderTest.php
+++ b/apps/files_sharing/tests/MountProviderTest.php
@@ -59,7 +59,7 @@ class MountProviderTest extends \Test\TestCase {
/** @var ILogger | \PHPUnit_Framework_MockObject_MockObject */
private $logger;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->getMockBuilder(IConfig::class)->getMock();
diff --git a/apps/files_trashbin/tests/CapabilitiesTest.php b/apps/files_trashbin/tests/CapabilitiesTest.php
index 9a891e86522..c600617fcf3 100644
--- a/apps/files_trashbin/tests/CapabilitiesTest.php
+++ b/apps/files_trashbin/tests/CapabilitiesTest.php
@@ -27,7 +27,7 @@ class CapabilitiesTest extends TestCase {
/** @var Capabilities */
private $capabilities;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->capabilities = new Capabilities();
}
diff --git a/apps/files_trashbin/tests/Command/CleanUpTest.php b/apps/files_trashbin/tests/Command/CleanUpTest.php
index 74231ada18b..530c6ff2549 100644
--- a/apps/files_trashbin/tests/Command/CleanUpTest.php
+++ b/apps/files_trashbin/tests/Command/CleanUpTest.php
@@ -61,7 +61,7 @@ class CleanUpTest extends TestCase {
/** @var string */
protected $user0 = 'user0';
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')
->disableOriginalConstructor()->getMock();
diff --git a/apps/files_trashbin/tests/Controller/PreviewControllerTest.php b/apps/files_trashbin/tests/Controller/PreviewControllerTest.php
index a6891a6c07b..689c32cbceb 100644
--- a/apps/files_trashbin/tests/Controller/PreviewControllerTest.php
+++ b/apps/files_trashbin/tests/Controller/PreviewControllerTest.php
@@ -65,7 +65,7 @@ class PreviewControllerTest extends TestCase {
/** @var IUserSession|\PHPUnit_Framework_MockObject_MockObject */
private $userSession;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->rootFolder = $this->createMock(IRootFolder::class);
diff --git a/apps/files_versions/tests/Command/CleanupTest.php b/apps/files_versions/tests/Command/CleanupTest.php
index ace8e842e7b..69f822fcb84 100644
--- a/apps/files_versions/tests/Command/CleanupTest.php
+++ b/apps/files_versions/tests/Command/CleanupTest.php
@@ -48,7 +48,7 @@ class CleanupTest extends TestCase {
/** @var \PHPUnit_Framework_MockObject_MockObject | IRootFolder */
protected $rootFolder;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->rootFolder = $this->getMockBuilder('OCP\Files\IRootFolder')
diff --git a/apps/files_versions/tests/Controller/PreviewControllerTest.php b/apps/files_versions/tests/Controller/PreviewControllerTest.php
index e771b82a42d..79afb8bd536 100644
--- a/apps/files_versions/tests/Controller/PreviewControllerTest.php
+++ b/apps/files_versions/tests/Controller/PreviewControllerTest.php
@@ -64,7 +64,7 @@ class PreviewControllerTest extends TestCase {
/** @var IVersionManager|\PHPUnit_Framework_MockObject_MockObject */
private $versionManager;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->rootFolder = $this->createMock(IRootFolder::class);
diff --git a/apps/files_versions/tests/VersioningTest.php b/apps/files_versions/tests/VersioningTest.php
index d878ea9c3da..3f51f619629 100644
--- a/apps/files_versions/tests/VersioningTest.php
+++ b/apps/files_versions/tests/VersioningTest.php
@@ -620,10 +620,10 @@ class VersioningTest extends \Test\TestCase {
$this->assertFalse(\OCA\Files_Versions\Storage::expire('/void/unexist.txt', self::TEST_VERSIONS_USER));
}
- /**
- * @expectedException \OC\User\NoUserException
- */
+
public function testExpireNonexistingUser() {
+ $this->expectException(\OC\User\NoUserException::class);
+
$this->logout();
// needed to have a FS setup (the background job does this)
\OC_Util::setupFS(self::TEST_VERSIONS_USER);
diff --git a/apps/oauth2/tests/Controller/LoginRedirectorControllerTest.php b/apps/oauth2/tests/Controller/LoginRedirectorControllerTest.php
index 3b18290ff8d..fb116ec2265 100644
--- a/apps/oauth2/tests/Controller/LoginRedirectorControllerTest.php
+++ b/apps/oauth2/tests/Controller/LoginRedirectorControllerTest.php
@@ -48,7 +48,7 @@ class LoginRedirectorControllerTest extends TestCase {
/** @var IL10N */
private $l;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
diff --git a/apps/oauth2/tests/Controller/OauthApiControllerTest.php b/apps/oauth2/tests/Controller/OauthApiControllerTest.php
index 1c7bed848a7..613f97c9ced 100644
--- a/apps/oauth2/tests/Controller/OauthApiControllerTest.php
+++ b/apps/oauth2/tests/Controller/OauthApiControllerTest.php
@@ -61,7 +61,7 @@ class OauthApiControllerTest extends TestCase {
/** @var OauthApiController */
private $oauthApiController;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
diff --git a/apps/oauth2/tests/Controller/SettingsControllerTest.php b/apps/oauth2/tests/Controller/SettingsControllerTest.php
index 6519f9cf087..2be63267a75 100644
--- a/apps/oauth2/tests/Controller/SettingsControllerTest.php
+++ b/apps/oauth2/tests/Controller/SettingsControllerTest.php
@@ -47,7 +47,7 @@ class SettingsControllerTest extends TestCase {
/** @var SettingsController */
private $settingsController;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
diff --git a/apps/oauth2/tests/Db/AccessTokenMapperTest.php b/apps/oauth2/tests/Db/AccessTokenMapperTest.php
index 8d60b10d145..dc5ecb27efb 100644
--- a/apps/oauth2/tests/Db/AccessTokenMapperTest.php
+++ b/apps/oauth2/tests/Db/AccessTokenMapperTest.php
@@ -32,7 +32,7 @@ class AccessTokenMapperTest extends TestCase {
/** @var AccessTokenMapper */
private $accessTokenMapper;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->accessTokenMapper = new AccessTokenMapper(\OC::$server->getDatabaseConnection());
}
@@ -52,10 +52,10 @@ class AccessTokenMapperTest extends TestCase {
$this->accessTokenMapper->delete($token);
}
- /**
- * @expectedException \OCA\OAuth2\Exceptions\AccessTokenNotFoundException
- */
+
public function testDeleteByClientId() {
+ $this->expectException(\OCA\OAuth2\Exceptions\AccessTokenNotFoundException::class);
+
$this->accessTokenMapper->deleteByClientId(1234);
$token = new AccessToken();
$token->setClientId(1234);
diff --git a/apps/oauth2/tests/Db/ClientMapperTest.php b/apps/oauth2/tests/Db/ClientMapperTest.php
index 78400672cbb..1448cff109e 100644
--- a/apps/oauth2/tests/Db/ClientMapperTest.php
+++ b/apps/oauth2/tests/Db/ClientMapperTest.php
@@ -32,7 +32,7 @@ class ClientMapperTest extends TestCase {
/** @var ClientMapper */
private $clientMapper;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->clientMapper = new ClientMapper(\OC::$server->getDatabaseConnection());
}
@@ -48,10 +48,10 @@ class ClientMapperTest extends TestCase {
$this->assertEquals($client, $this->clientMapper->getByIdentifier('MyAwesomeClientIdentifier'));
}
- /**
- * @expectedException \OCA\OAuth2\Exceptions\ClientNotFoundException
- */
+
public function testGetByIdentifierNotExisting() {
+ $this->expectException(\OCA\OAuth2\Exceptions\ClientNotFoundException::class);
+
$this->clientMapper->getByIdentifier('MyTotallyNotExistingClient');
}
@@ -66,10 +66,10 @@ class ClientMapperTest extends TestCase {
$this->assertEquals($client, $this->clientMapper->getByUid($client->getId()));
}
- /**
- * @expectedException \OCA\OAuth2\Exceptions\ClientNotFoundException
- */
+
public function testGetByUidNotExisting() {
+ $this->expectException(\OCA\OAuth2\Exceptions\ClientNotFoundException::class);
+
$this->clientMapper->getByUid(1234);
}
diff --git a/apps/oauth2/tests/Settings/AdminTest.php b/apps/oauth2/tests/Settings/AdminTest.php
index ec8787db83f..2e5b0dcadba 100644
--- a/apps/oauth2/tests/Settings/AdminTest.php
+++ b/apps/oauth2/tests/Settings/AdminTest.php
@@ -40,7 +40,7 @@ class AdminTest extends TestCase {
/** @var ClientMapper|MockObject */
private $clientMapper;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->initialStateService = $this->createMock(IInitialStateService::class);
diff --git a/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php b/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php
index b7d40a6caac..ecc7393ad8f 100644
--- a/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php
@@ -332,10 +332,11 @@ class AppConfigControllerTest extends TestCase {
/**
* @dataProvider dataVerifyAppIdThrows
- * @expectedException \InvalidArgumentException
* @param string $app
*/
public function testVerifyAppIdThrows($app) {
+ $this->expectException(\InvalidArgumentException::class);
+
$api = $this->getInstance();
$this->invokePrivate($api, 'verifyAppId', [$app]);
}
@@ -377,12 +378,13 @@ class AppConfigControllerTest extends TestCase {
/**
* @dataProvider dataVerifyConfigKeyThrows
- * @expectedException \InvalidArgumentException
* @param string $app
* @param string $key
* @param string $value
*/
public function testVerifyConfigKeyThrows($app, $key, $value) {
+ $this->expectException(\InvalidArgumentException::class);
+
$api = $this->getInstance();
$this->invokePrivate($api, 'verifyConfigKey', [$app, $key, $value]);
}
diff --git a/apps/provisioning_api/tests/Controller/AppsControllerTest.php b/apps/provisioning_api/tests/Controller/AppsControllerTest.php
index 1056d3ba4c1..5cd440e4202 100644
--- a/apps/provisioning_api/tests/Controller/AppsControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/AppsControllerTest.php
@@ -72,11 +72,11 @@ class AppsControllerTest extends \OCA\Provisioning_API\Tests\TestCase {
$this->assertEquals($expected, $result->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 998
- */
+
public function testGetAppInfoOnBadAppID() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(998);
+
$this->api->getAppInfo('not_provisioning_api');
}
@@ -109,11 +109,11 @@ class AppsControllerTest extends \OCA\Provisioning_API\Tests\TestCase {
$this->assertEquals(count($disabled), count($data['apps']));
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- */
+
public function testGetAppsInvalidFilter() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(101);
+
$this->api->getApps('foo');
}
}
diff --git a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php
index 676b809169e..6204907f76e 100644
--- a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php
@@ -284,11 +284,11 @@ class GroupsControllerTest extends \Test\TestCase {
$this->assertEquals(['users' => ['user1', 'user2']], $result->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 403
- */
+
public function testGetGroupAsIrrelevantSubadmin() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(403);
+
$group = $this->createGroup('group');
$otherGroup = $this->createGroup('otherGroup');
$this->asSubAdminOfGroup($otherGroup);
@@ -329,23 +329,23 @@ class GroupsControllerTest extends \Test\TestCase {
$this->assertEquals(['users' => ['user1', 'user2']], $result->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 404
- * @expectedExceptionMessage The requested group could not be found
- */
+
public function testGetGroupNonExisting() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('The requested group could not be found');
+ $this->expectExceptionCode(404);
+
$this->asUser();
$this->api->getGroup($this->getUniqueID());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- * @expectedExceptionMessage Group does not exist
- */
+
public function testGetSubAdminsOfGroupsNotExists() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Group does not exist');
+ $this->expectExceptionCode(101);
+
$this->api->getSubAdminsOfGroup('NonExistingGroup');
}
@@ -387,20 +387,20 @@ class GroupsControllerTest extends \Test\TestCase {
$this->assertEquals([], $result->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- * @expectedExceptionMessage Invalid group name
- */
+
public function testAddGroupEmptyGroup() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Invalid group name');
+ $this->expectExceptionCode(101);
+
$this->api->addGroup('');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 102
- */
+
public function testAddGroupExistingGroup() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(102);
+
$this->groupManager
->method('groupExists')
->with('ExistingGroup')
@@ -437,19 +437,19 @@ class GroupsControllerTest extends \Test\TestCase {
$this->api->addGroup('Iñtërnâtiônàlizætiøn');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- */
+
public function testDeleteGroupNonExisting() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(101);
+
$this->api->deleteGroup('NonExistingGroup');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 102
- */
+
public function testDeleteAdminGroup() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(102);
+
$this->groupManager
->method('groupExists')
->with('admin')
diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
index 0c4fcd5071c..c4bfff6d69b 100644
--- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
@@ -219,11 +219,11 @@ class UsersControllerTest extends TestCase {
$this->assertEquals($expected, $this->api->getUsers('MyCustomSearch')->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 102
- */
+
public function testAddUserAlreadyExisting() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(102);
+
$this->userManager
->expects($this->once())
->method('userExists')
@@ -253,12 +253,12 @@ class UsersControllerTest extends TestCase {
$this->api->addUser('AlreadyExistingUser', 'password', '', '', []);
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 104
- * @expectedExceptionMessage group NonExistingGroup does not exist
- */
+
public function testAddUserNonExistingGroup() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('group NonExistingGroup does not exist');
+ $this->expectExceptionCode(104);
+
$this->userManager
->expects($this->once())
->method('userExists')
@@ -289,12 +289,12 @@ class UsersControllerTest extends TestCase {
$this->api->addUser('NewUser', 'pass', '', '', ['NonExistingGroup']);
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 104
- * @expectedExceptionMessage group NonExistingGroup does not exist
- */
+
public function testAddUserExistingGroupNonExistingGroup() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('group NonExistingGroup does not exist');
+ $this->expectExceptionCode(104);
+
$this->userManager
->expects($this->once())
->method('userExists')
@@ -479,12 +479,12 @@ class UsersControllerTest extends TestCase {
));
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 111
- * @expectedExceptionMessage Could not create non-existing user id
- */
+
public function testAddUserFailedToGenerateUserID() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Could not create non-existing user id');
+ $this->expectExceptionCode(111);
+
$this->config
->expects($this->any())
->method('getAppValue')
@@ -522,12 +522,12 @@ class UsersControllerTest extends TestCase {
$this->api->addUser('', 'PasswordOfTheNewUser')->getData();
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 110
- * @expectedExceptionMessage Required email address was not provided
- */
+
public function testAddUserEmailRequired() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Required email address was not provided');
+ $this->expectExceptionCode(110);
+
$this->config
->expects($this->any())
->method('getAppValue')
@@ -629,12 +629,12 @@ class UsersControllerTest extends TestCase {
));
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- * @expectedExceptionMessage Bad request
- */
+
public function testAddUserUnsuccessful() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Bad request');
+ $this->expectExceptionCode(101);
+
$exception = new Exception('User backend not found.');
$this->userManager
->expects($this->once())
@@ -674,12 +674,12 @@ class UsersControllerTest extends TestCase {
$this->api->addUser('NewUser', 'PasswordOfTheNewUser');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 106
- * @expectedExceptionMessage no group specified (required for subadmins)
- */
+
public function testAddUserAsSubAdminNoGroup() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('no group specified (required for subadmins)');
+ $this->expectExceptionCode(106);
+
$loggedInUser = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
@@ -707,12 +707,12 @@ class UsersControllerTest extends TestCase {
$this->api->addUser('NewUser', 'PasswordOfTheNewUser', '', '', []);
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 105
- * @expectedExceptionMessage insufficient privileges for group ExistingGroup
- */
+
public function testAddUserAsSubAdminValidGroupNotSubAdmin() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('insufficient privileges for group ExistingGroup');
+ $this->expectExceptionCode(105);
+
$loggedInUser = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
@@ -850,12 +850,12 @@ class UsersControllerTest extends TestCase {
));
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 404
- * @expectedExceptionMessage User does not exist
- */
+
public function testGetUserTargetDoesNotExist() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('User does not exist');
+ $this->expectExceptionCode(404);
+
$loggedInUser = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
@@ -1142,11 +1142,11 @@ class UsersControllerTest extends TestCase {
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 997
- */
+
public function testGetUserDataAsSubAdminAndUserIsNotAccessible() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(997);
+
$loggedInUser = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
@@ -1376,11 +1376,11 @@ class UsersControllerTest extends TestCase {
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 102
- */
+
public function testEditUserRegularUserSelfEditChangeEmailInvalid() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(102);
+
$loggedInUser = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
@@ -1445,11 +1445,11 @@ class UsersControllerTest extends TestCase {
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 997
- */
+
public function testEditUserRegularUserSelfEditChangeQuota() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(997);
+
$loggedInUser = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
@@ -1510,12 +1510,12 @@ class UsersControllerTest extends TestCase {
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 103
- * @expectedExceptionMessage Invalid quota value ABC
- */
+
public function testEditUserAdminUserSelfEditChangeInvalidQuota() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Invalid quota value ABC');
+ $this->expectExceptionCode(103);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
@@ -1635,9 +1635,10 @@ class UsersControllerTest extends TestCase {
/**
* @dataProvider dataEditUserSelfEditChangeLanguageButForced
- * @expectedException \OCP\AppFramework\OCS\OCSException
*/
public function testEditUserSelfEditChangeLanguageButForced($forced) {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+
$this->config->expects($this->any())
->method('getSystemValue')
->willReturnMap([
@@ -1719,9 +1720,10 @@ class UsersControllerTest extends TestCase {
/**
* @dataProvider dataEditUserSelfEditChangeLanguageButForced
- * @expectedException \OCP\AppFramework\OCS\OCSException
*/
public function testEditUserAdminEditChangeLanguageInvalidLanguage() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+
$this->l10nFactory->expects($this->once())
->method('findAvailableLanguages')
@@ -1801,11 +1803,11 @@ class UsersControllerTest extends TestCase {
$this->assertEquals([], $this->api->editUser('UserToEdit', 'quota', '3042824')->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 997
- */
+
public function testEditUserSubadminUserInaccessible() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(997);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
@@ -1841,11 +1843,11 @@ class UsersControllerTest extends TestCase {
$this->api->editUser('UserToEdit', 'quota', 'value');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- */
+
public function testDeleteUserNotExistingUser() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(101);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
@@ -1864,11 +1866,11 @@ class UsersControllerTest extends TestCase {
$this->api->deleteUser('UserToDelete');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- */
+
public function testDeleteUserSelf() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(101);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
@@ -1925,11 +1927,11 @@ class UsersControllerTest extends TestCase {
$this->assertEquals([], $this->api->deleteUser('UserToDelete')->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- */
+
public function testDeleteUnsuccessfulUserAsAdmin() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(101);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
@@ -2006,11 +2008,11 @@ class UsersControllerTest extends TestCase {
$this->assertEquals([], $this->api->deleteUser('UserToDelete')->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- */
+
public function testDeleteUnsuccessfulUserAsSubadmin() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(101);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
@@ -2054,11 +2056,11 @@ class UsersControllerTest extends TestCase {
$this->api->deleteUser('UserToDelete');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 997
- */
+
public function testDeleteUserAsSubAdminAndUserIsNotAccessible() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(997);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
@@ -2098,11 +2100,11 @@ class UsersControllerTest extends TestCase {
$this->api->deleteUser('UserToDelete');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 998
- */
+
public function testGetUsersGroupsTargetUserNotExisting() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(998);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$this->userSession
->expects($this->once())
@@ -2235,11 +2237,11 @@ class UsersControllerTest extends TestCase {
$this->assertEquals(['groups' => ['Group1']], $this->api->getUsersGroups('UserToLookup')->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 997
- */
+
public function testGetUsersGroupsForSubAdminUserAndUserIsInaccessible() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(997);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->exactly(2))
@@ -2284,11 +2286,11 @@ class UsersControllerTest extends TestCase {
$this->api->getUsersGroups('UserToLookup');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 102
- */
+
public function testAddToGroupWithTargetGroupNotExisting() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(102);
+
$this->groupManager->expects($this->once())
->method('get')
->with('GroupToAddTo')
@@ -2297,19 +2299,19 @@ class UsersControllerTest extends TestCase {
$this->api->addToGroup('TargetUser', 'GroupToAddTo');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- */
+
public function testAddToGroupWithNoGroupSpecified() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(101);
+
$this->api->addToGroup('TargetUser');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 103
- */
+
public function testAddToGroupWithTargetUserNotExisting() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(103);
+
$targetGroup = $this->createMock(IGroup::class);
$this->groupManager->expects($this->once())
->method('get')
@@ -2319,11 +2321,11 @@ class UsersControllerTest extends TestCase {
$this->api->addToGroup('TargetUser', 'GroupToAddTo');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 104
- */
+
public function testAddToGroupNoSubadmin() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(104);
+
$targetUser = $this->createMock(IUser::class);
$loggedInUser = $this->createMock(IUser::class);
$loggedInUser->expects($this->once())
@@ -2453,11 +2455,11 @@ class UsersControllerTest extends TestCase {
$this->assertEquals(new DataResponse(), $this->api->addToGroup('TargetUser', 'GroupToAddTo'));
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- */
+
public function testRemoveFromGroupWithNoTargetGroup() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(101);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$this->userSession
->expects($this->once())
@@ -2467,11 +2469,11 @@ class UsersControllerTest extends TestCase {
$this->api->removeFromGroup('TargetUser', '');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- */
+
public function testRemoveFromGroupWithEmptyTargetGroup() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(101);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$this->userSession
->expects($this->once())
@@ -2481,11 +2483,11 @@ class UsersControllerTest extends TestCase {
$this->api->removeFromGroup('TargetUser', '');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 102
- */
+
public function testRemoveFromGroupWithNotExistingTargetGroup() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(102);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$this->userSession
->expects($this->once())
@@ -2500,11 +2502,11 @@ class UsersControllerTest extends TestCase {
$this->api->removeFromGroup('TargetUser', 'TargetGroup');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 103
- */
+
public function testRemoveFromGroupWithNotExistingTargetUser() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(103);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
$this->userSession
@@ -2525,11 +2527,11 @@ class UsersControllerTest extends TestCase {
$this->api->removeFromGroup('TargetUser', 'TargetGroup');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 104
- */
+
public function testRemoveFromGroupWithoutPermission() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(104);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->once())
@@ -2566,12 +2568,12 @@ class UsersControllerTest extends TestCase {
$this->api->removeFromGroup('TargetUser', 'TargetGroup');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 105
- * @expectedExceptionMessage Cannot remove yourself from the admin group
- */
+
public function testRemoveFromGroupAsAdminFromAdmin() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Cannot remove yourself from the admin group');
+ $this->expectExceptionCode(105);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
@@ -2616,12 +2618,12 @@ class UsersControllerTest extends TestCase {
$this->api->removeFromGroup('Admin', 'admin');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 105
- * @expectedExceptionMessage Cannot remove yourself from this group as you are a SubAdmin
- */
+
public function testRemoveFromGroupAsSubAdminFromSubAdmin() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Cannot remove yourself from this group as you are a SubAdmin');
+ $this->expectExceptionCode(105);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
@@ -2671,12 +2673,12 @@ class UsersControllerTest extends TestCase {
$this->api->removeFromGroup('SubAdmin', 'subadmin');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 105
- * @expectedExceptionMessage Not viable to remove user from the last group you are SubAdmin of
- */
+
public function testRemoveFromGroupAsSubAdminFromLastSubAdminGroup() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Not viable to remove user from the last group you are SubAdmin of');
+ $this->expectExceptionCode(105);
+
$loggedInUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$loggedInUser
->expects($this->any())
@@ -2774,12 +2776,12 @@ class UsersControllerTest extends TestCase {
$this->assertEquals([], $this->api->removeFromGroup('AnotherUser', 'admin')->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- * @expectedExceptionMessage User does not exist
- */
+
public function testAddSubAdminWithNotExistingTargetUser() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('User does not exist');
+ $this->expectExceptionCode(101);
+
$this->userManager
->expects($this->once())
->method('get')
@@ -2789,12 +2791,12 @@ class UsersControllerTest extends TestCase {
$this->api->addSubAdmin('NotExistingUser', '');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 102
- * @expectedExceptionMessage Group does not exist
- */
+
public function testAddSubAdminWithNotExistingTargetGroup() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Group does not exist');
+ $this->expectExceptionCode(102);
+
$targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$this->userManager
@@ -2811,12 +2813,12 @@ class UsersControllerTest extends TestCase {
$this->api->addSubAdmin('ExistingUser', 'NotExistingGroup');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 103
- * @expectedExceptionMessage Cannot create subadmins for admin group
- */
+
public function testAddSubAdminToAdminGroup() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Cannot create subadmins for admin group');
+ $this->expectExceptionCode(103);
+
$targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
$targetGroup
@@ -2898,12 +2900,12 @@ class UsersControllerTest extends TestCase {
$this->assertEquals([], $this->api->addSubAdmin('ExistingUser', 'TargetGroup')->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- * @expectedExceptionMessage User does not exist
- */
+
public function testRemoveSubAdminNotExistingTargetUser() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('User does not exist');
+ $this->expectExceptionCode(101);
+
$this->userManager
->expects($this->once())
->method('get')
@@ -2913,12 +2915,12 @@ class UsersControllerTest extends TestCase {
$this->api->removeSubAdmin('NotExistingUser', 'GroupToDeleteFrom');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- * @expectedExceptionMessage Group does not exist
- */
+
public function testRemoveSubAdminNotExistingTargetGroup() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Group does not exist');
+ $this->expectExceptionCode(101);
+
$targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$this->userManager
->expects($this->once())
@@ -2935,12 +2937,12 @@ class UsersControllerTest extends TestCase {
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 102
- * @expectedExceptionMessage User is not a subadmin of this group
- */
+
public function testRemoveSubAdminFromNotASubadmin() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('User is not a subadmin of this group');
+ $this->expectExceptionCode(102);
+
$targetUser = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
$targetGroup = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
$this->userManager
@@ -3001,12 +3003,12 @@ class UsersControllerTest extends TestCase {
$this->assertEquals([], $this->api->removeSubAdmin('ExistingUser', 'GroupToDeleteFrom')->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 404
- * @expectedExceptionMessage User does not exist
- */
+
public function testGetUserSubAdminGroupsNotExistingTargetUser() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('User does not exist');
+ $this->expectExceptionCode(404);
+
$this->userManager
->expects($this->once())
->method('get')
@@ -3155,10 +3157,10 @@ class UsersControllerTest extends TestCase {
$this->assertSame($expected, $api->getCurrentUser()->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- */
+
public function testGetCurrentUserNotLoggedIn() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+
$this->userSession->expects($this->once())->method('getUser')
->willReturn(null);
@@ -3208,11 +3210,11 @@ class UsersControllerTest extends TestCase {
$this->assertSame($expected, $api->getUser('uid')->getData());
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 998
- */
+
public function testResendWelcomeMessageWithNotExistingTargetUser() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(998);
+
$this->userManager
->expects($this->once())
->method('get')
@@ -3222,11 +3224,11 @@ class UsersControllerTest extends TestCase {
$this->api->resendWelcomeMessage('NotExistingUser');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 997
- */
+
public function testResendWelcomeMessageAsSubAdminAndUserIsNotAccessible() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionCode(997);
+
$loggedInUser = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
@@ -3267,12 +3269,12 @@ class UsersControllerTest extends TestCase {
$this->api->resendWelcomeMessage('UserToGet');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- * @expectedExceptionMessage Email address not available
- */
+
public function testResendWelcomeMessageNoEmail() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Email address not available');
+ $this->expectExceptionCode(101);
+
$loggedInUser = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
@@ -3308,12 +3310,12 @@ class UsersControllerTest extends TestCase {
$this->api->resendWelcomeMessage('UserToGet');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 101
- * @expectedExceptionMessage Email address not available
- */
+
public function testResendWelcomeMessageNullEmail() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Email address not available');
+ $this->expectExceptionCode(101);
+
$loggedInUser = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
@@ -3448,12 +3450,12 @@ class UsersControllerTest extends TestCase {
$this->api->resendWelcomeMessage('UserToGet');
}
- /**
- * @expectedException \OCP\AppFramework\OCS\OCSException
- * @expectedExceptionCode 102
- * @expectedExceptionMessage Sending email failed
- */
+
public function testResendWelcomeMessageFailed() {
+ $this->expectException(\OCP\AppFramework\OCS\OCSException::class);
+ $this->expectExceptionMessage('Sending email failed');
+ $this->expectExceptionCode(102);
+
$loggedInUser = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
diff --git a/apps/provisioning_api/tests/Middleware/ProvisioningApiMiddlewareTest.php b/apps/provisioning_api/tests/Middleware/ProvisioningApiMiddlewareTest.php
index 70dad250585..ef3b20fa76c 100644
--- a/apps/provisioning_api/tests/Middleware/ProvisioningApiMiddlewareTest.php
+++ b/apps/provisioning_api/tests/Middleware/ProvisioningApiMiddlewareTest.php
@@ -35,7 +35,7 @@ class ProvisioningApiMiddlewareTest extends TestCase {
/** @var IControllerMethodReflector|\PHPUnit_Framework_MockObject_MockObject */
private $reflector;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->reflector = $this->createMock(IControllerMethodReflector::class);
diff --git a/apps/settings/tests/Controller/AdminSettingsControllerTest.php b/apps/settings/tests/Controller/AdminSettingsControllerTest.php
index d3591c6d67a..21dc877975d 100644
--- a/apps/settings/tests/Controller/AdminSettingsControllerTest.php
+++ b/apps/settings/tests/Controller/AdminSettingsControllerTest.php
@@ -62,7 +62,7 @@ class AdminSettingsControllerTest extends TestCase {
/** @var string */
private $adminUid = 'lololo';
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
@@ -87,7 +87,7 @@ class AdminSettingsControllerTest extends TestCase {
\OC::$server->getGroupManager()->createGroup('admin')->addUser($user);
}
- public function tearDown(): void {
+ protected function tearDown(): void {
\OC::$server->getUserManager()->get($this->adminUid)->delete();
parent::tearDown();
diff --git a/apps/settings/tests/Controller/AppSettingsControllerTest.php b/apps/settings/tests/Controller/AppSettingsControllerTest.php
index 508a39642a5..536c3eea52a 100644
--- a/apps/settings/tests/Controller/AppSettingsControllerTest.php
+++ b/apps/settings/tests/Controller/AppSettingsControllerTest.php
@@ -76,7 +76,7 @@ class AppSettingsControllerTest extends TestCase {
/** @var ILogger|MockObject */
private $logger;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
diff --git a/apps/settings/tests/Controller/CertificateControllerTest.php b/apps/settings/tests/Controller/CertificateControllerTest.php
index 270e986e307..e5487f6892c 100644
--- a/apps/settings/tests/Controller/CertificateControllerTest.php
+++ b/apps/settings/tests/Controller/CertificateControllerTest.php
@@ -48,7 +48,7 @@ class CertificateControllerTest extends \Test\TestCase {
/** @var ICertificateManager */
private $systemCertificateManager;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->getMockBuilder(IRequest::class)->getMock();
diff --git a/apps/settings/tests/Controller/CheckSetupControllerTest.php b/apps/settings/tests/Controller/CheckSetupControllerTest.php
index b038cf2af34..ca0e9362de1 100644
--- a/apps/settings/tests/Controller/CheckSetupControllerTest.php
+++ b/apps/settings/tests/Controller/CheckSetupControllerTest.php
@@ -87,7 +87,7 @@ class CheckSetupControllerTest extends TestCase {
*/
private $dirsToRemove = [];
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->getMockBuilder(IRequest::class)
diff --git a/apps/settings/tests/Controller/UsersControllerTest.php b/apps/settings/tests/Controller/UsersControllerTest.php
index eb5790a0401..d5d067f3eeb 100644
--- a/apps/settings/tests/Controller/UsersControllerTest.php
+++ b/apps/settings/tests/Controller/UsersControllerTest.php
@@ -353,7 +353,6 @@ class UsersControllerTest extends \Test\TestCase {
* @param bool $setDisplayNameResult
* @param bool $canChangeEmail
*
- * @expectedException \OC\ForbiddenException
*/
public function testSaveUserSettingsException($data,
$oldEmailAddress,
@@ -361,6 +360,8 @@ class UsersControllerTest extends \Test\TestCase {
$setDisplayNameResult,
$canChangeEmail
) {
+ $this->expectException(\OC\ForbiddenException::class);
+
$controller = $this->getController();
$user = $this->createMock(IUser::class);
diff --git a/apps/settings/tests/Mailer/NewUserMailHelperTest.php b/apps/settings/tests/Mailer/NewUserMailHelperTest.php
index 77d606a9535..e84c4322562 100644
--- a/apps/settings/tests/Mailer/NewUserMailHelperTest.php
+++ b/apps/settings/tests/Mailer/NewUserMailHelperTest.php
@@ -57,7 +57,7 @@ class NewUserMailHelperTest extends TestCase {
/** @var \OCA\Settings\Mailer\NewUserMailHelper */
private $newUserMailHelper;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->defaults = $this->createMock(Defaults::class);
diff --git a/apps/settings/tests/Middleware/SubadminMiddlewareTest.php b/apps/settings/tests/Middleware/SubadminMiddlewareTest.php
index e2434c01b02..51914604a98 100644
--- a/apps/settings/tests/Middleware/SubadminMiddlewareTest.php
+++ b/apps/settings/tests/Middleware/SubadminMiddlewareTest.php
@@ -47,10 +47,10 @@ class SubadminMiddlewareTest extends \Test\TestCase {
$this->subadminMiddleware = new SubadminMiddleware($this->reflector, false, $this->l10n);
}
- /**
- * @expectedException \OC\AppFramework\Middleware\Security\Exceptions\NotAdminException
- */
+
public function testBeforeControllerAsUserWithExemption() {
+ $this->expectException(\OC\AppFramework\Middleware\Security\Exceptions\NotAdminException::class);
+
$this->reflector
->expects($this->once())
->method('hasAnnotation')
@@ -93,10 +93,10 @@ class SubadminMiddlewareTest extends \Test\TestCase {
$this->assertEquals($expectedResponse, $this->subadminMiddleware->afterException($this->controller, 'foo', new NotAdminException('')));
}
- /**
- * @expectedException \Exception
- */
+
public function testAfterRegularException() {
+ $this->expectException(\Exception::class);
+
$expectedResponse = new TemplateResponse('core', '403', array(), 'guest');
$expectedResponse->setStatus(403);
$this->subadminMiddleware->afterException($this->controller, 'foo', new \Exception());
diff --git a/apps/settings/tests/Personal/Security/AuthtokensTest.php b/apps/settings/tests/Personal/Security/AuthtokensTest.php
index d0af05df913..e2e5d3e6234 100644
--- a/apps/settings/tests/Personal/Security/AuthtokensTest.php
+++ b/apps/settings/tests/Personal/Security/AuthtokensTest.php
@@ -52,7 +52,7 @@ class AuthtokensTest extends TestCase {
/** @var Security\Authtokens */
private $section;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->authTokenProvider = $this->createMock(IAuthTokenProvider::class);
diff --git a/apps/settings/tests/Settings/Admin/MailTest.php b/apps/settings/tests/Settings/Admin/MailTest.php
index 1b47dc874c1..011329e7b89 100644
--- a/apps/settings/tests/Settings/Admin/MailTest.php
+++ b/apps/settings/tests/Settings/Admin/MailTest.php
@@ -34,7 +34,7 @@ class MailTest extends TestCase {
/** @var IConfig */
private $config;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->getMockBuilder(IConfig::class)->getMock();
diff --git a/apps/settings/tests/Settings/Admin/SecurityTest.php b/apps/settings/tests/Settings/Admin/SecurityTest.php
index 778690de1c8..6ddc0d39822 100644
--- a/apps/settings/tests/Settings/Admin/SecurityTest.php
+++ b/apps/settings/tests/Settings/Admin/SecurityTest.php
@@ -44,7 +44,7 @@ class SecurityTest extends TestCase {
/** @var IInitialStateService|MockObject */
private $initialState;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->manager = $this->getMockBuilder(Manager::class)->disableOriginalConstructor()->getMock();
$this->userManager = $this->getMockBuilder(IUserManager::class)->getMock();
diff --git a/apps/settings/tests/Settings/Admin/ServerTest.php b/apps/settings/tests/Settings/Admin/ServerTest.php
index 57c984fdb12..727284fdca4 100644
--- a/apps/settings/tests/Settings/Admin/ServerTest.php
+++ b/apps/settings/tests/Settings/Admin/ServerTest.php
@@ -34,7 +34,7 @@ class ServerTest extends TestCase {
/** @var IConfig */
private $config;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
diff --git a/apps/settings/tests/Settings/Admin/SharingTest.php b/apps/settings/tests/Settings/Admin/SharingTest.php
index 37046d9d319..38f687b87ae 100644
--- a/apps/settings/tests/Settings/Admin/SharingTest.php
+++ b/apps/settings/tests/Settings/Admin/SharingTest.php
@@ -42,7 +42,7 @@ class SharingTest extends TestCase {
/** @var IManager|\PHPUnit_Framework_MockObject_MockObject */
private $shareManager;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->getMockBuilder(IConfig::class)->getMock();
$this->l10n = $this->getMockBuilder(IL10N::class)->getMock();
diff --git a/apps/settings/tests/Settings/Personal/SecurityTest.php b/apps/settings/tests/Settings/Personal/SecurityTest.php
index 671fcd6f9b4..ba51a9d7e32 100644
--- a/apps/settings/tests/Settings/Personal/SecurityTest.php
+++ b/apps/settings/tests/Settings/Personal/SecurityTest.php
@@ -58,7 +58,7 @@ class SecurityTest extends TestCase {
/** @var Security */
private $section;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->initialStateService = $this->createMock(IInitialStateService::class);
diff --git a/apps/sharebymail/tests/CapabilitiesTest.php b/apps/sharebymail/tests/CapabilitiesTest.php
index 96fce010c1d..1e19ffd2eaf 100644
--- a/apps/sharebymail/tests/CapabilitiesTest.php
+++ b/apps/sharebymail/tests/CapabilitiesTest.php
@@ -26,7 +26,7 @@ class CapabilitiesTest extends TestCase {
/** @var Capabilities */
private $capabilities;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->capabilities = new Capabilities();
diff --git a/apps/sharebymail/tests/SettingsTest.php b/apps/sharebymail/tests/SettingsTest.php
index 12d8fc4d919..a05d4f5926b 100644
--- a/apps/sharebymail/tests/SettingsTest.php
+++ b/apps/sharebymail/tests/SettingsTest.php
@@ -34,7 +34,7 @@ class SettingsTest extends TestCase {
/** @var SettingsManager | \PHPUnit_Framework_MockObject_MockObject */
private $settingsManager;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->settingsManager = $this->getMockBuilder(SettingsManager::class)
diff --git a/apps/sharebymail/tests/ShareByMailProviderTest.php b/apps/sharebymail/tests/ShareByMailProviderTest.php
index 678e6cc0da0..4efd528b2d1 100644
--- a/apps/sharebymail/tests/ShareByMailProviderTest.php
+++ b/apps/sharebymail/tests/ShareByMailProviderTest.php
@@ -97,7 +97,7 @@ class ShareByMailProviderTest extends TestCase {
/** @var CapabilitiesManager | \PHPUnit_Framework_MockObject_MockObject */
private $capabilitiesManager;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->shareManager = \OC::$server->getShareManager();
@@ -174,7 +174,7 @@ class ShareByMailProviderTest extends TestCase {
}
- public function tearDown(): void {
+ protected function tearDown(): void {
$this->connection->getQueryBuilder()->delete('share')->execute();
parent::tearDown();
@@ -305,10 +305,10 @@ class ShareByMailProviderTest extends TestCase {
);
}
- /**
- * @expectedException \Exception
- */
+
public function testCreateFailed() {
+ $this->expectException(\Exception::class);
+
$this->share->expects($this->once())->method('getSharedWith')->willReturn('user1');
$node = $this->getMockBuilder('OCP\Files\Node')->getMock();
$node->expects($this->any())->method('getName')->willReturn('fileName');
@@ -348,10 +348,10 @@ class ShareByMailProviderTest extends TestCase {
}
- /**
- * @expectedException \OC\HintException
- */
+
public function testCreateMailShareFailed() {
+ $this->expectException(\OC\HintException::class);
+
$this->share->expects($this->any())->method('getToken')->willReturn('token');
$this->share->expects($this->once())->method('setToken')->with('token');
$node = $this->getMockBuilder('OCP\Files\Node')->getMock();
@@ -572,10 +572,10 @@ class ShareByMailProviderTest extends TestCase {
$this->assertInstanceOf('OCP\Share\IShare', $result);
}
- /**
- * @expectedException \OCP\Share\Exceptions\ShareNotFound
- */
+
public function testGetShareByIdFailed() {
+ $this->expectException(\OCP\Share\Exceptions\ShareNotFound::class);
+
$instance = $this->getInstance(['createShareObject']);
$itemSource = 11;
@@ -657,10 +657,10 @@ class ShareByMailProviderTest extends TestCase {
$this->assertInstanceOf('OCP\Share\IShare', $result);
}
- /**
- * @expectedException \OCP\Share\Exceptions\ShareNotFound
- */
+
public function testGetShareByTokenFailed() {
+ $this->expectException(\OCP\Share\Exceptions\ShareNotFound::class);
+
$itemSource = 11;
$itemType = 'file';
@@ -774,10 +774,10 @@ class ShareByMailProviderTest extends TestCase {
$this->assertSame($token, $result['token']);
}
- /**
- * @expectedException \OCP\Share\Exceptions\ShareNotFound
- */
+
public function testGetRawShareFailed() {
+ $this->expectException(\OCP\Share\Exceptions\ShareNotFound::class);
+
$itemSource = 11;
$itemType = 'file';
$shareWith = 'user@server.com';
diff --git a/apps/systemtags/tests/Activity/SettingTest.php b/apps/systemtags/tests/Activity/SettingTest.php
index 0cb6f505371..489f5fd8ca0 100644
--- a/apps/systemtags/tests/Activity/SettingTest.php
+++ b/apps/systemtags/tests/Activity/SettingTest.php
@@ -29,7 +29,7 @@ class SettingTest extends TestCase {
/** @var Setting */
private $setting;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->l = $this->createMock(IL10N::class);
diff --git a/apps/systemtags/tests/Settings/AdminTest.php b/apps/systemtags/tests/Settings/AdminTest.php
index b9b7fb60f85..3e878ac3c6c 100644
--- a/apps/systemtags/tests/Settings/AdminTest.php
+++ b/apps/systemtags/tests/Settings/AdminTest.php
@@ -32,7 +32,7 @@ class AdminTest extends TestCase {
/** @var Admin */
private $admin;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->admin = new Admin();
diff --git a/apps/theming/tests/Controller/IconControllerTest.php b/apps/theming/tests/Controller/IconControllerTest.php
index df0fdd52b3f..9d5970fd384 100644
--- a/apps/theming/tests/Controller/IconControllerTest.php
+++ b/apps/theming/tests/Controller/IconControllerTest.php
@@ -61,7 +61,7 @@ class IconControllerTest extends TestCase {
/** @var ImageManager */
private $imageManager;
- public function setUp(): void {
+ protected function setUp(): void {
$this->request = $this->createMock(IRequest::class);
$this->themingDefaults = $this->createMock(ThemingDefaults::class);
$this->iconBuilder = $this->createMock(IconBuilder::class);
diff --git a/apps/theming/tests/Controller/ThemingControllerTest.php b/apps/theming/tests/Controller/ThemingControllerTest.php
index a626fdebe6d..8d4650e68b3 100644
--- a/apps/theming/tests/Controller/ThemingControllerTest.php
+++ b/apps/theming/tests/Controller/ThemingControllerTest.php
@@ -83,7 +83,7 @@ class ThemingControllerTest extends TestCase {
/** @var IURLGenerator */
private $urlGenerator;
- public function setUp(): void {
+ protected function setUp(): void {
$this->request = $this->createMock(IRequest::class);
$this->config = $this->createMock(IConfig::class);
$this->themingDefaults = $this->createMock(ThemingDefaults::class);
diff --git a/apps/theming/tests/ImageManagerTest.php b/apps/theming/tests/ImageManagerTest.php
index 56fa63bea7b..7d61b80efdf 100644
--- a/apps/theming/tests/ImageManagerTest.php
+++ b/apps/theming/tests/ImageManagerTest.php
@@ -184,10 +184,10 @@ class ImageManagerTest extends TestCase {
$this->assertEquals($file, $this->imageManager->getImage('logo', false));
}
- /**
- * @expectedException OCP\Files\NotFoundException
- */
+
public function testGetImageUnset() {
+ $this->expectException(\OCP\Files\NotFoundException::class);
+
$this->config->expects($this->once())
->method('getAppValue')->with('theming', 'logoMime', false)
->willReturn(false);
@@ -239,10 +239,10 @@ class ImageManagerTest extends TestCase {
$this->assertEquals($expected, $this->imageManager->getCachedImage('filename'));
}
- /**
- * @expectedException \OCP\Files\NotFoundException
- */
+
public function testGetCachedImageNotFound() {
+ $this->expectException(\OCP\Files\NotFoundException::class);
+
$folder = $this->setupCacheFolder();
$folder->expects($this->once())
->method('getFile')
diff --git a/apps/theming/tests/Settings/AdminTest.php b/apps/theming/tests/Settings/AdminTest.php
index 4e89366c3f2..50d0e454445 100644
--- a/apps/theming/tests/Settings/AdminTest.php
+++ b/apps/theming/tests/Settings/AdminTest.php
@@ -50,7 +50,7 @@ class AdminTest extends TestCase {
/** @var IL10N */
private $l10n;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
$this->l10n = $this->createMock(IL10N::class);
diff --git a/apps/theming/tests/Settings/SectionTest.php b/apps/theming/tests/Settings/SectionTest.php
index 10d6bb172f2..dff2df3502a 100644
--- a/apps/theming/tests/Settings/SectionTest.php
+++ b/apps/theming/tests/Settings/SectionTest.php
@@ -37,7 +37,7 @@ class SectionTest extends TestCase {
/** @var Section */
private $section;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->url = $this->createMock(IURLGenerator::class);
$this->l = $this->createMock(IL10N::class);
diff --git a/apps/theming/tests/ThemingDefaultsTest.php b/apps/theming/tests/ThemingDefaultsTest.php
index b7413eaf47d..20c80211b8d 100644
--- a/apps/theming/tests/ThemingDefaultsTest.php
+++ b/apps/theming/tests/ThemingDefaultsTest.php
@@ -72,7 +72,7 @@ class ThemingDefaultsTest extends TestCase {
/** @var INavigationManager|\PHPUnit_Framework_MockObject_MockObject */
private $navigationManager;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
$this->l10n = $this->createMock(IL10N::class);
diff --git a/apps/twofactor_backupcodes/tests/Unit/BackgroundJob/CheckBackupCodeTest.php b/apps/twofactor_backupcodes/tests/Unit/BackgroundJob/CheckBackupCodeTest.php
index 2e68c0e427b..3e14cbfa3a1 100644
--- a/apps/twofactor_backupcodes/tests/Unit/BackgroundJob/CheckBackupCodeTest.php
+++ b/apps/twofactor_backupcodes/tests/Unit/BackgroundJob/CheckBackupCodeTest.php
@@ -55,7 +55,7 @@ class CheckBackupCodeTest extends TestCase {
/** @var CheckBackupCodes */
private $checkBackupCodes;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->userManager = $this->createMock(IUserManager::class);
diff --git a/apps/twofactor_backupcodes/tests/Unit/BackgroundJob/RememberBackupCodesJobTest.php b/apps/twofactor_backupcodes/tests/Unit/BackgroundJob/RememberBackupCodesJobTest.php
index a6dda9ce6aa..0410facb4f7 100644
--- a/apps/twofactor_backupcodes/tests/Unit/BackgroundJob/RememberBackupCodesJobTest.php
+++ b/apps/twofactor_backupcodes/tests/Unit/BackgroundJob/RememberBackupCodesJobTest.php
@@ -54,7 +54,7 @@ class RememberBackupCodesJobTest extends TestCase {
/** @var RememberBackupCodesJob */
private $job;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->registry = $this->createMock(IRegistry::class);
diff --git a/apps/twofactor_backupcodes/tests/Unit/Notification/NotifierTest.php b/apps/twofactor_backupcodes/tests/Unit/Notification/NotifierTest.php
index 0bbdc8619b4..73754cecb95 100644
--- a/apps/twofactor_backupcodes/tests/Unit/Notification/NotifierTest.php
+++ b/apps/twofactor_backupcodes/tests/Unit/Notification/NotifierTest.php
@@ -64,10 +64,10 @@ class NotifierTest extends TestCase {
);
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testPrepareWrongApp() {
+ $this->expectException(\InvalidArgumentException::class);
+
/** @var INotification|\PHPUnit_Framework_MockObject_MockObject $notification */
$notification = $this->createMock(INotification::class);
$notification->expects($this->once())
@@ -79,10 +79,10 @@ class NotifierTest extends TestCase {
$this->notifier->prepare($notification, 'en');
}
- /**
- * @expectedException \InvalidArgumentException
- */
+
public function testPrepareWrongSubject() {
+ $this->expectException(\InvalidArgumentException::class);
+
/** @var INotification|\PHPUnit_Framework_MockObject_MockObject $notification */
$notification = $this->createMock(INotification::class);
$notification->expects($this->once())
diff --git a/apps/updatenotification/tests/Controller/AdminControllerTest.php b/apps/updatenotification/tests/Controller/AdminControllerTest.php
index 38baeb907b5..ca380184215 100644
--- a/apps/updatenotification/tests/Controller/AdminControllerTest.php
+++ b/apps/updatenotification/tests/Controller/AdminControllerTest.php
@@ -52,7 +52,7 @@ class AdminControllerTest extends TestCase {
/** @var IL10N|\PHPUnit_Framework_MockObject_MockObject */
private $l10n;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);
diff --git a/apps/updatenotification/tests/Notification/BackgroundJobTest.php b/apps/updatenotification/tests/Notification/BackgroundJobTest.php
index 9e35194f066..117c2ad86ae 100644
--- a/apps/updatenotification/tests/Notification/BackgroundJobTest.php
+++ b/apps/updatenotification/tests/Notification/BackgroundJobTest.php
@@ -52,7 +52,7 @@ class BackgroundJobTest extends TestCase {
/** @var Installer|\PHPUnit_Framework_MockObject_MockObject */
protected $installer;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
diff --git a/apps/updatenotification/tests/Notification/NotifierTest.php b/apps/updatenotification/tests/Notification/NotifierTest.php
index d7a3fbbb149..b6620bb9c69 100644
--- a/apps/updatenotification/tests/Notification/NotifierTest.php
+++ b/apps/updatenotification/tests/Notification/NotifierTest.php
@@ -50,7 +50,7 @@ class NotifierTest extends TestCase {
/** @var IGroupManager|\PHPUnit_Framework_MockObject_MockObject */
protected $groupManager;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->urlGenerator = $this->createMock(IURLGenerator::class);
diff --git a/apps/updatenotification/tests/ResetTokenBackgroundJobTest.php b/apps/updatenotification/tests/ResetTokenBackgroundJobTest.php
index c604da85706..eb9e11594ba 100644
--- a/apps/updatenotification/tests/ResetTokenBackgroundJobTest.php
+++ b/apps/updatenotification/tests/ResetTokenBackgroundJobTest.php
@@ -37,7 +37,7 @@ class ResetTokenBackgroundJobTest extends TestCase {
/** @var ResetTokenBackgroundJob */
private $resetTokenBackgroundJob;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
diff --git a/apps/updatenotification/tests/Settings/AdminTest.php b/apps/updatenotification/tests/Settings/AdminTest.php
index a0b7c4b0fe3..049d9bf5b9a 100644
--- a/apps/updatenotification/tests/Settings/AdminTest.php
+++ b/apps/updatenotification/tests/Settings/AdminTest.php
@@ -55,7 +55,7 @@ class AdminTest extends TestCase {
/** @var IRegistry|\PHPUnit_Framework_MockObject_MockObject */
private $subscriptionRegistry;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
diff --git a/apps/updatenotification/tests/UpdateCheckerTest.php b/apps/updatenotification/tests/UpdateCheckerTest.php
index 1ad45074554..00c8aa569db 100644
--- a/apps/updatenotification/tests/UpdateCheckerTest.php
+++ b/apps/updatenotification/tests/UpdateCheckerTest.php
@@ -38,7 +38,7 @@ class UpdateCheckerTest extends TestCase {
/** @var UpdateChecker */
private $updateChecker;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->updater = $this->createMock(VersionCheck::class);
diff --git a/apps/user_ldap/lib/WizardResult.php b/apps/user_ldap/lib/WizardResult.php
index e5294a76506..8e2f519deee 100644
--- a/apps/user_ldap/lib/WizardResult.php
+++ b/apps/user_ldap/lib/WizardResult.php
@@ -40,9 +40,7 @@ class WizardResult {
$this->changes[$key] = $value;
}
- /**
- *
- */
+
public function markChange() {
$this->markedChange = true;
}
diff --git a/apps/user_ldap/tests/AccessTest.php b/apps/user_ldap/tests/AccessTest.php
index 0d327ce2e06..004a2619219 100644
--- a/apps/user_ldap/tests/AccessTest.php
+++ b/apps/user_ldap/tests/AccessTest.php
@@ -78,7 +78,7 @@ class AccessTest extends TestCase {
/** @var Access */
private $access;
- public function setUp(): void {
+ protected function setUp(): void {
$this->connection = $this->createMock(Connection::class);
$this->ldap = $this->createMock(LDAP::class);
$this->userManager = $this->createMock(Manager::class);
@@ -441,11 +441,11 @@ class AccessTest extends TestCase {
$this->assertSame($values[0], strtolower($dnFromServer));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage LDAP password changes are disabled
- */
+
public function testSetPasswordWithDisabledChanges() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('LDAP password changes are disabled');
+
$this->connection
->method('__get')
->willReturn(false);
@@ -473,11 +473,11 @@ class AccessTest extends TestCase {
$this->assertFalse($this->access->setPassword('CN=foo', 'MyPassword'));
}
- /**
- * @expectedException \OC\HintException
- * @expectedExceptionMessage Password change rejected.
- */
+
public function testSetPasswordWithRejectedChange() {
+ $this->expectException(\OC\HintException::class);
+ $this->expectExceptionMessage('Password change rejected.');
+
$this->connection
->method('__get')
->willReturn(true);
diff --git a/apps/user_ldap/tests/ConfigurationTest.php b/apps/user_ldap/tests/ConfigurationTest.php
index 5820fff25ed..4298c8f294b 100644
--- a/apps/user_ldap/tests/ConfigurationTest.php
+++ b/apps/user_ldap/tests/ConfigurationTest.php
@@ -29,7 +29,7 @@ class ConfigurationTest extends \Test\TestCase {
/** @var Configuration */
protected $configuration;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->configuration = new Configuration('t01', false);
}
diff --git a/apps/user_ldap/tests/ConnectionTest.php b/apps/user_ldap/tests/ConnectionTest.php
index f08b5d9bf1d..3090c56c11c 100644
--- a/apps/user_ldap/tests/ConnectionTest.php
+++ b/apps/user_ldap/tests/ConnectionTest.php
@@ -44,7 +44,7 @@ class ConnectionTest extends \Test\TestCase {
/** @var Connection */
protected $connection;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->ldap = $this->createMock(ILDAPWrapper::class);
diff --git a/apps/user_ldap/tests/GroupLDAPPluginTest.php b/apps/user_ldap/tests/GroupLDAPPluginTest.php
index 3b8bfd795c5..773f937a77e 100644
--- a/apps/user_ldap/tests/GroupLDAPPluginTest.php
+++ b/apps/user_ldap/tests/GroupLDAPPluginTest.php
@@ -84,11 +84,11 @@ class GroupLDAPPluginTest extends \Test\TestCase {
$pluginManager->createGroup('group');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage No plugin implements createGroup in this LDAP Backend.
- */
+
public function testCreateGroupNotRegistered() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('No plugin implements createGroup in this LDAP Backend.');
+
$pluginManager = $this->getGroupPluginManager();
$pluginManager->createGroup('foo');
}
@@ -114,11 +114,11 @@ class GroupLDAPPluginTest extends \Test\TestCase {
$pluginManager->deleteGroup('group');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage No plugin implements deleteGroup in this LDAP Backend.
- */
+
public function testDeleteGroupNotRegistered() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('No plugin implements deleteGroup in this LDAP Backend.');
+
$pluginManager = $this->getGroupPluginManager();
$pluginManager->deleteGroup('foo');
}
@@ -145,11 +145,11 @@ class GroupLDAPPluginTest extends \Test\TestCase {
$pluginManager->addToGroup('uid', 'gid');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage No plugin implements addToGroup in this LDAP Backend.
- */
+
public function testAddToGroupNotRegistered() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('No plugin implements addToGroup in this LDAP Backend.');
+
$pluginManager = $this->getGroupPluginManager();
$pluginManager->addToGroup('foo', 'bar');
}
@@ -176,11 +176,11 @@ class GroupLDAPPluginTest extends \Test\TestCase {
$pluginManager->removeFromGroup('uid', 'gid');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage No plugin implements removeFromGroup in this LDAP Backend.
- */
+
public function testRemoveFromGroupNotRegistered() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('No plugin implements removeFromGroup in this LDAP Backend.');
+
$pluginManager = $this->getGroupPluginManager();
$pluginManager->removeFromGroup('foo', 'bar');
}
@@ -207,11 +207,11 @@ class GroupLDAPPluginTest extends \Test\TestCase {
$pluginManager->countUsersInGroup('gid', 'search');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage No plugin implements countUsersInGroup in this LDAP Backend.
- */
+
public function testCountUsersInGroupNotRegistered() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('No plugin implements countUsersInGroup in this LDAP Backend.');
+
$pluginManager = $this->getGroupPluginManager();
$pluginManager->countUsersInGroup('foo', 'bar');
}
@@ -237,11 +237,11 @@ class GroupLDAPPluginTest extends \Test\TestCase {
$pluginManager->getGroupDetails('gid');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage No plugin implements getGroupDetails in this LDAP Backend.
- */
+
public function testgetGroupDetailsNotRegistered() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('No plugin implements getGroupDetails in this LDAP Backend.');
+
$pluginManager = $this->getGroupPluginManager();
$pluginManager->getGroupDetails('foo');
}
diff --git a/apps/user_ldap/tests/Group_LDAPTest.php b/apps/user_ldap/tests/Group_LDAPTest.php
index e0ece5d50a6..2dae666d1dc 100644
--- a/apps/user_ldap/tests/Group_LDAPTest.php
+++ b/apps/user_ldap/tests/Group_LDAPTest.php
@@ -770,10 +770,10 @@ class Group_LDAPTest extends TestCase {
$this->assertEquals($ldap->createGroup('gid'),true);
}
- /**
- * @expectedException \Exception
- */
+
public function testCreateGroupFailing() {
+ $this->expectException(\Exception::class);
+
/** @var GroupPluginManager|\PHPUnit_Framework_MockObject_MockObject $pluginManager */
$pluginManager = $this->getMockBuilder('\OCA\User_LDAP\GroupPluginManager')
->setMethods(['implementsActions', 'createGroup'])
@@ -825,10 +825,10 @@ class Group_LDAPTest extends TestCase {
$this->assertEquals($ldap->deleteGroup('gid'),'result');
}
- /**
- * @expectedException \Exception
- */
+
public function testDeleteGroupFailing() {
+ $this->expectException(\Exception::class);
+
/** @var GroupPluginManager|\PHPUnit_Framework_MockObject_MockObject $pluginManager */
$pluginManager = $this->getMockBuilder('\OCA\User_LDAP\GroupPluginManager')
->setMethods(['implementsActions', 'deleteGroup'])
@@ -871,10 +871,10 @@ class Group_LDAPTest extends TestCase {
$this->assertEquals($ldap->addToGroup('uid', 'gid'),'result');
}
- /**
- * @expectedException \Exception
- */
+
public function testAddToGroupFailing() {
+ $this->expectException(\Exception::class);
+
/** @var GroupPluginManager|\PHPUnit_Framework_MockObject_MockObject $pluginManager */
$pluginManager = $this->getMockBuilder('\OCA\User_LDAP\GroupPluginManager')
->setMethods(['implementsActions', 'addToGroup'])
@@ -917,10 +917,10 @@ class Group_LDAPTest extends TestCase {
$this->assertEquals($ldap->removeFromGroup('uid', 'gid'),'result');
}
- /**
- * @expectedException \Exception
- */
+
public function testRemoveFromGroupFailing() {
+ $this->expectException(\Exception::class);
+
/** @var GroupPluginManager|\PHPUnit_Framework_MockObject_MockObject $pluginManager */
$pluginManager = $this->getMockBuilder('\OCA\User_LDAP\GroupPluginManager')
->setMethods(['implementsActions', 'removeFromGroup'])
@@ -963,10 +963,10 @@ class Group_LDAPTest extends TestCase {
$this->assertEquals($ldap->getGroupDetails('gid'),'result');
}
- /**
- * @expectedException \Exception
- */
+
public function testGetGroupDetailsFailing() {
+ $this->expectException(\Exception::class);
+
/** @var GroupPluginManager|\PHPUnit_Framework_MockObject_MockObject $pluginManager */
$pluginManager = $this->getMockBuilder('\OCA\User_LDAP\GroupPluginManager')
->setMethods(['implementsActions', 'getGroupDetails'])
diff --git a/apps/user_ldap/tests/HelperTest.php b/apps/user_ldap/tests/HelperTest.php
index 3804938199d..eae87a6a924 100644
--- a/apps/user_ldap/tests/HelperTest.php
+++ b/apps/user_ldap/tests/HelperTest.php
@@ -36,7 +36,7 @@ class HelperTest extends \Test\TestCase {
/** @var Helper */
private $helper;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->config = $this->createMock(IConfig::class);
diff --git a/apps/user_ldap/tests/Jobs/SyncTest.php b/apps/user_ldap/tests/Jobs/SyncTest.php
index d16ce6672df..e45f1d3fd10 100644
--- a/apps/user_ldap/tests/Jobs/SyncTest.php
+++ b/apps/user_ldap/tests/Jobs/SyncTest.php
@@ -69,7 +69,7 @@ class SyncTest extends TestCase {
/** @var AccessFactory|\PHPUnit_Framework_MockObject_MockObject */
protected $accessFactory;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->helper = $this->createMock(Helper::class);
diff --git a/apps/user_ldap/tests/LDAPProviderTest.php b/apps/user_ldap/tests/LDAPProviderTest.php
index cbce73be295..03756e85cc5 100644
--- a/apps/user_ldap/tests/LDAPProviderTest.php
+++ b/apps/user_ldap/tests/LDAPProviderTest.php
@@ -103,11 +103,11 @@ class LDAPProviderTest extends \Test\TestCase {
return $factory->getLDAPProvider();
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage User id not found in LDAP
- */
+
public function testGetUserDNUserIDNotFound() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('User id not found in LDAP');
+
$userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP')
->setMethods(['userExists'])
->disableOriginalConstructor()
@@ -142,11 +142,11 @@ class LDAPProviderTest extends \Test\TestCase {
$ldapProvider->getUserDN('existing_user'));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Group id not found in LDAP
- */
+
public function testGetGroupDNGroupIDNotFound() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Group id not found in LDAP');
+
$userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP')
->disableOriginalConstructor()
->getMock();
@@ -240,11 +240,11 @@ class LDAPProviderTest extends \Test\TestCase {
$ldapProvider->sanitizeDN('cn=existing_user,ou=Are Sufficient To,ou=Test,dc=example,dc=org'));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage User id not found in LDAP
- */
+
public function testGetLDAPConnectionUserIDNotFound() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('User id not found in LDAP');
+
$userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP')
->setMethods(['userExists'])
->disableOriginalConstructor()
@@ -275,11 +275,11 @@ class LDAPProviderTest extends \Test\TestCase {
$this->assertTrue($ldapProvider->getLDAPConnection('existing_user'));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Group id not found in LDAP
- */
+
public function testGetGroupLDAPConnectionGroupIDNotFound() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Group id not found in LDAP');
+
$userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP')
->disableOriginalConstructor()
->getMock();
@@ -321,11 +321,11 @@ class LDAPProviderTest extends \Test\TestCase {
$this->assertTrue($ldapProvider->getGroupLDAPConnection('existing_group'));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage User id not found in LDAP
- */
+
public function testGetLDAPBaseUsersUserIDNotFound() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('User id not found in LDAP');
+
$userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP')
->setMethods(['userExists'])
->disableOriginalConstructor()
@@ -384,11 +384,11 @@ class LDAPProviderTest extends \Test\TestCase {
$this->assertEquals($bases[1], $ldapProvider->getLDAPBaseUsers('existing_user'));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage User id not found in LDAP
- */
+
public function testGetLDAPBaseGroupsUserIDNotFound() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('User id not found in LDAP');
+
$userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP')
->setMethods(['userExists'])
->disableOriginalConstructor()
@@ -440,11 +440,11 @@ class LDAPProviderTest extends \Test\TestCase {
$this->assertEquals($bases[0], $ldapProvider->getLDAPBaseGroups('existing_user'));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage User id not found in LDAP
- */
+
public function testClearCacheUserIDNotFound() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('User id not found in LDAP');
+
$userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP')
->setMethods(['userExists'])
->disableOriginalConstructor()
@@ -479,11 +479,11 @@ class LDAPProviderTest extends \Test\TestCase {
$this->addToAssertionCount(1);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Group id not found in LDAP
- */
+
public function testClearGroupCacheGroupIDNotFound() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Group id not found in LDAP');
+
$userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP')
->disableOriginalConstructor()
->getMock();
@@ -565,11 +565,11 @@ class LDAPProviderTest extends \Test\TestCase {
$this->addToAssertionCount(1);
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage User id not found in LDAP
- */
+
public function testGetLDAPDisplayNameFieldUserIDNotFound() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('User id not found in LDAP');
+
$userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP')
->setMethods(['userExists'])
->disableOriginalConstructor()
@@ -603,11 +603,11 @@ class LDAPProviderTest extends \Test\TestCase {
$this->assertEquals('displayName', $ldapProvider->getLDAPDisplayNameField('existing_user'));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage User id not found in LDAP
- */
+
public function testGetLDAPEmailFieldUserIDNotFound() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('User id not found in LDAP');
+
$userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP')
->setMethods(['userExists'])
->disableOriginalConstructor()
@@ -641,11 +641,11 @@ class LDAPProviderTest extends \Test\TestCase {
$this->assertEquals('mail', $ldapProvider->getLDAPEmailField('existing_user'));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage Group id not found in LDAP
- */
+
public function testGetLDAPGroupMemberAssocUserIDNotFound() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('Group id not found in LDAP');
+
$userBackend = $this->getMockBuilder('OCA\User_LDAP\User_LDAP')
->disableOriginalConstructor()
->getMock();
diff --git a/apps/user_ldap/tests/LDAPTest.php b/apps/user_ldap/tests/LDAPTest.php
index a6c097c6f85..441124cdf4d 100644
--- a/apps/user_ldap/tests/LDAPTest.php
+++ b/apps/user_ldap/tests/LDAPTest.php
@@ -30,7 +30,7 @@ class LDAPTest extends TestCase {
/** @var LDAP|\PHPUnit_Framework_MockObject_MockObject */
private $ldap;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->ldap = $this->getMockBuilder(LDAP::class)
->setMethods(['invokeLDAPMethod'])
diff --git a/apps/user_ldap/tests/Migration/AbstractUUIDFixTest.php b/apps/user_ldap/tests/Migration/AbstractUUIDFixTest.php
index 323a3464ce8..60e92ab926c 100644
--- a/apps/user_ldap/tests/Migration/AbstractUUIDFixTest.php
+++ b/apps/user_ldap/tests/Migration/AbstractUUIDFixTest.php
@@ -58,7 +58,7 @@ abstract class AbstractUUIDFixTest extends TestCase {
/** @var bool */
protected $isUser = true;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->ldap = $this->createMock(LDAP::class);
diff --git a/apps/user_ldap/tests/Migration/UUIDFixGroupTest.php b/apps/user_ldap/tests/Migration/UUIDFixGroupTest.php
index c0bbd8098b1..3adcdec35ea 100644
--- a/apps/user_ldap/tests/Migration/UUIDFixGroupTest.php
+++ b/apps/user_ldap/tests/Migration/UUIDFixGroupTest.php
@@ -35,7 +35,7 @@ use OCA\User_LDAP\Tests\Migration\AbstractUUIDFixTest;
* @group DB
*/
class UUIDFixGroupTest extends AbstractUUIDFixTest {
- public function setUp(): void {
+ protected function setUp(): void {
$this->isUser = false;
parent::setUp();
diff --git a/apps/user_ldap/tests/Migration/UUIDFixInsertTest.php b/apps/user_ldap/tests/Migration/UUIDFixInsertTest.php
index 32f601f2b11..a39338186e8 100644
--- a/apps/user_ldap/tests/Migration/UUIDFixInsertTest.php
+++ b/apps/user_ldap/tests/Migration/UUIDFixInsertTest.php
@@ -47,7 +47,7 @@ class UUIDFixInsertTest extends TestCase {
/** @var UUIDFixInsert */
protected $job;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->jobList = $this->createMock(IJobList::class);
diff --git a/apps/user_ldap/tests/Migration/UUIDFixUserTest.php b/apps/user_ldap/tests/Migration/UUIDFixUserTest.php
index 8e91a00156b..6793a8dd8ce 100644
--- a/apps/user_ldap/tests/Migration/UUIDFixUserTest.php
+++ b/apps/user_ldap/tests/Migration/UUIDFixUserTest.php
@@ -34,7 +34,7 @@ use OCA\User_LDAP\User_Proxy;
* @group DB
*/
class UUIDFixUserTest extends AbstractUUIDFixTest {
- public function setUp(): void {
+ protected function setUp(): void {
$this->isUser = true;
parent::setUp();
diff --git a/apps/user_ldap/tests/Settings/AdminTest.php b/apps/user_ldap/tests/Settings/AdminTest.php
index d421c379bf5..156033bcb8c 100644
--- a/apps/user_ldap/tests/Settings/AdminTest.php
+++ b/apps/user_ldap/tests/Settings/AdminTest.php
@@ -43,7 +43,7 @@ class AdminTest extends TestCase {
/** @var IL10N */
private $l10n;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->l10n = $this->getMockBuilder(IL10N::class)->getMock();
diff --git a/apps/user_ldap/tests/Settings/SectionTest.php b/apps/user_ldap/tests/Settings/SectionTest.php
index 0bd7a8010b6..60a36971314 100644
--- a/apps/user_ldap/tests/Settings/SectionTest.php
+++ b/apps/user_ldap/tests/Settings/SectionTest.php
@@ -37,7 +37,7 @@ class SectionTest extends TestCase {
/** @var Section */
private $section;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->url = $this->createMock(IURLGenerator::class);
$this->l = $this->createMock(IL10N::class);
diff --git a/apps/user_ldap/tests/User/DeletedUsersIndexTest.php b/apps/user_ldap/tests/User/DeletedUsersIndexTest.php
index e81a81f742f..c6f2d9bebd2 100644
--- a/apps/user_ldap/tests/User/DeletedUsersIndexTest.php
+++ b/apps/user_ldap/tests/User/DeletedUsersIndexTest.php
@@ -48,7 +48,7 @@ class DeletedUsersIndexTest extends \Test\TestCase {
/** @var UserMapping|\PHPUnit_Framework_MockObject_MockObject */
protected $mapping;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
// no mocks for those as tests go against DB
@@ -63,7 +63,7 @@ class DeletedUsersIndexTest extends \Test\TestCase {
$this->dui = new DeletedUsersIndex($this->config, $this->db, $this->mapping);
}
- public function tearDown(): void {
+ protected function tearDown(): void {
$this->config->deleteAppFromAllUsers('user_ldap');
parent::tearDown();
}
diff --git a/apps/user_ldap/tests/User/ManagerTest.php b/apps/user_ldap/tests/User/ManagerTest.php
index a8abd1e4667..896e981883f 100644
--- a/apps/user_ldap/tests/User/ManagerTest.php
+++ b/apps/user_ldap/tests/User/ManagerTest.php
@@ -86,7 +86,7 @@ class ManagerTest extends \Test\TestCase {
/** @var Manager */
protected $manager;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->access = $this->createMock(Access::class);
diff --git a/apps/user_ldap/tests/User/UserTest.php b/apps/user_ldap/tests/User/UserTest.php
index 992d3ce990c..5a94dd39cc6 100644
--- a/apps/user_ldap/tests/User/UserTest.php
+++ b/apps/user_ldap/tests/User/UserTest.php
@@ -76,7 +76,7 @@ class UserTest extends \Test\TestCase {
/** @var User */
protected $user;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->connection = $this->createMock(Connection::class);
@@ -1114,10 +1114,10 @@ class UserTest extends \Test\TestCase {
$this->assertFalse($this->user->getHomePath());
}
- /**
- * @expectedException \Exception
- */
+
public function testGetHomePathConfiguredNotAvailableNotAllowed() {
+ $this->expectException(\Exception::class);
+
$this->connection->expects($this->any())
->method('__get')
->with($this->equalTo('homeFolderNamingRule'))
diff --git a/apps/user_ldap/tests/UserLDAPPluginTest.php b/apps/user_ldap/tests/UserLDAPPluginTest.php
index 1d7d2ee7c75..fac6156450a 100644
--- a/apps/user_ldap/tests/UserLDAPPluginTest.php
+++ b/apps/user_ldap/tests/UserLDAPPluginTest.php
@@ -85,11 +85,11 @@ class UserLDAPPluginTest extends \Test\TestCase {
$pluginManager->createUser('user', 'password');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage No plugin implements createUser in this LDAP Backend.
- */
+
public function testCreateUserNotRegistered() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('No plugin implements createUser in this LDAP Backend.');
+
$pluginManager = $this->getUserPluginManager();
$pluginManager->createUser('foo','bar');
}
@@ -116,11 +116,11 @@ class UserLDAPPluginTest extends \Test\TestCase {
$pluginManager->setPassword('user', 'password');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage No plugin implements setPassword in this LDAP Backend.
- */
+
public function testSetPasswordNotRegistered() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('No plugin implements setPassword in this LDAP Backend.');
+
$pluginManager = $this->getUserPluginManager();
$pluginManager->setPassword('foo','bar');
}
@@ -146,11 +146,11 @@ class UserLDAPPluginTest extends \Test\TestCase {
$pluginManager->getHome('uid');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage No plugin implements getHome in this LDAP Backend.
- */
+
public function testGetHomeNotRegistered() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('No plugin implements getHome in this LDAP Backend.');
+
$pluginManager = $this->getUserPluginManager();
$pluginManager->getHome('foo');
}
@@ -176,11 +176,11 @@ class UserLDAPPluginTest extends \Test\TestCase {
$pluginManager->getDisplayName('uid');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage No plugin implements getDisplayName in this LDAP Backend.
- */
+
public function testGetDisplayNameNotRegistered() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('No plugin implements getDisplayName in this LDAP Backend.');
+
$pluginManager = $this->getUserPluginManager();
$pluginManager->getDisplayName('foo');
}
@@ -207,11 +207,11 @@ class UserLDAPPluginTest extends \Test\TestCase {
$pluginManager->setDisplayName('user', 'password');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage No plugin implements setDisplayName in this LDAP Backend.
- */
+
public function testSetDisplayNameNotRegistered() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('No plugin implements setDisplayName in this LDAP Backend.');
+
$pluginManager = $this->getUserPluginManager();
$pluginManager->setDisplayName('foo', 'bar');
}
@@ -237,11 +237,11 @@ class UserLDAPPluginTest extends \Test\TestCase {
$pluginManager->canChangeAvatar('uid');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage No plugin implements canChangeAvatar in this LDAP Backend.
- */
+
public function testCanChangeAvatarNotRegistered() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('No plugin implements canChangeAvatar in this LDAP Backend.');
+
$pluginManager = $this->getUserPluginManager();
$pluginManager->canChangeAvatar('foo');
}
@@ -264,11 +264,11 @@ class UserLDAPPluginTest extends \Test\TestCase {
$pluginManager->countUsers();
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage No plugin implements countUsers in this LDAP Backend.
- */
+
public function testCountUsersNotRegistered() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('No plugin implements countUsers in this LDAP Backend.');
+
$pluginManager = $this->getUserPluginManager();
$pluginManager->countUsers();
}
@@ -300,11 +300,11 @@ class UserLDAPPluginTest extends \Test\TestCase {
$pluginManager->deleteUser('uid');
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage No plugin implements deleteUser in this LDAP Backend.
- */
+
public function testDeleteUserNotRegistered() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('No plugin implements deleteUser in this LDAP Backend.');
+
$pluginManager = $this->getUserPluginManager();
$pluginManager->deleteUser('foo');
}
diff --git a/apps/user_ldap/tests/User_LDAPTest.php b/apps/user_ldap/tests/User_LDAPTest.php
index e8076a051a1..b4766300df5 100644
--- a/apps/user_ldap/tests/User_LDAPTest.php
+++ b/apps/user_ldap/tests/User_LDAPTest.php
@@ -787,10 +787,10 @@ class User_LDAPTest extends TestCase {
$this->assertEquals($dataDir.'/susannah/', $result);
}
- /**
- * @expectedException \Exception
- */
+
public function testGetHomeNoPath() {
+ $this->expectException(\Exception::class);
+
$backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
$this->prepareMockForUserExists();
@@ -836,10 +836,10 @@ class User_LDAPTest extends TestCase {
$this->assertFalse($result);
}
- /**
- * @expectedException \OC\User\NoUserException
- */
+
public function testGetHomeDeletedUser() {
+ $this->expectException(\OC\User\NoUserException::class);
+
$uid = 'newyorker';
$backend = new UserLDAP($this->access, $this->config, $this->notificationManager, $this->session, $this->pluginManager);
@@ -1280,11 +1280,11 @@ class User_LDAPTest extends TestCase {
}));
}
- /**
- * @expectedException \OC\HintException
- * @expectedExceptionMessage Password fails quality checking policy
- */
+
public function testSetPasswordInvalid() {
+ $this->expectException(\OC\HintException::class);
+ $this->expectExceptionMessage('Password fails quality checking policy');
+
$this->prepareAccessForSetPassword($this->access);
$this->userManager->expects($this->atLeastOnce())
->method('get')
@@ -1324,11 +1324,11 @@ class User_LDAPTest extends TestCase {
$this->assertFalse(\OC_User::setPassword('roland', 'dt12234$'));
}
- /**
- * @expectedException \Exception
- * @expectedExceptionMessage LDAP setPassword: Could not get user object for uid NotExistingUser. Maybe the LDAP entry has no set display name attribute?
- */
+
public function testSetPasswordWithInvalidUser() {
+ $this->expectException(\Exception::class);
+ $this->expectExceptionMessage('LDAP setPassword: Could not get user object for uid NotExistingUser. Maybe the LDAP entry has no set display name attribute?');
+
$this->userManager
->expects($this->once())
->method('get')
@@ -1425,10 +1425,10 @@ class User_LDAPTest extends TestCase {
$this->assertEquals($newDisplayName, $this->backend->setDisplayName('uid', $newDisplayName));
}
- /**
- * @expectedException \OC\HintException
- */
+
public function testSetDisplayNameErrorWithPlugin() {
+ $this->expectException(\OC\HintException::class);
+
$newDisplayName = 'J. Baker';
$this->pluginManager->expects($this->once())
->method('implementsActions')
diff --git a/apps/user_ldap/tests/User_ProxyTest.php b/apps/user_ldap/tests/User_ProxyTest.php
index 02a1815804c..dc9758013fe 100644
--- a/apps/user_ldap/tests/User_ProxyTest.php
+++ b/apps/user_ldap/tests/User_ProxyTest.php
@@ -49,7 +49,7 @@ class User_ProxyTest extends TestCase {
/** @var UserPluginManager|\PHPUnit_Framework_MockObject_MockObject */
private $userPluginManager;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->ldapWrapper = $this->createMock(ILDAPWrapper::class);
diff --git a/apps/workflowengine/tests/Check/RequestUserAgentTest.php b/apps/workflowengine/tests/Check/RequestUserAgentTest.php
index 79e3de44874..7003441053d 100644
--- a/apps/workflowengine/tests/Check/RequestUserAgentTest.php
+++ b/apps/workflowengine/tests/Check/RequestUserAgentTest.php
@@ -34,7 +34,7 @@ class RequestUserAgentTest extends TestCase {
/** @var RequestUserAgent */
protected $check;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->request = $this->createMock(IRequest::class);