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/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Core/Controller/LoginControllerTest.php2
-rw-r--r--tests/acceptance/features/access-levels.feature2
-rw-r--r--tests/acceptance/features/app-files-sharing-link.feature6
-rw-r--r--tests/acceptance/features/app-files-sharing.feature8
-rw-r--r--tests/acceptance/features/app-files-tags.feature6
-rw-r--r--tests/acceptance/features/app-theming.feature12
-rw-r--r--tests/acceptance/features/bootstrap/AppNavigationContext.php2
-rw-r--r--tests/acceptance/features/bootstrap/FilesAppContext.php8
-rw-r--r--tests/acceptance/features/bootstrap/FilesAppSharingContext.php6
-rw-r--r--tests/acceptance/features/bootstrap/LoginPageContext.php4
-rw-r--r--tests/acceptance/features/bootstrap/SettingsMenuContext.php8
-rw-r--r--tests/acceptance/features/bootstrap/ThemingAppContext.php12
-rw-r--r--tests/acceptance/features/bootstrap/UsersSettingsContext.php10
-rw-r--r--tests/acceptance/features/core/ActorContext.php4
-rw-r--r--tests/acceptance/features/header.feature7
-rw-r--r--tests/lib/App/DependencyAnalyzerTest.php2
-rw-r--r--tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php20
-rw-r--r--tests/lib/BackgroundJob/DummyJobList.php2
-rw-r--r--tests/lib/Calendar/ManagerTest.php377
-rw-r--r--tests/lib/Collaboration/Collaborators/MailPluginTest.php10
-rw-r--r--tests/lib/Collaboration/Collaborators/RemotePluginTest.php10
-rw-r--r--tests/lib/DB/MigratorTest.php2
-rw-r--r--tests/lib/Federation/CloudIdManagerTest.php17
-rw-r--r--tests/lib/Files/Node/FolderTest.php40
-rw-r--r--tests/lib/L10N/FactoryTest.php118
-rw-r--r--tests/lib/LargeFileHelperGetFileSizeTest.php2
-rw-r--r--tests/lib/Mail/MailerTest.php4
-rw-r--r--tests/lib/Migration/BackgroundRepairTest.php51
-rw-r--r--tests/lib/NavigationManagerTest.php28
-rw-r--r--tests/lib/Notification/ManagerTest.php8
-rw-r--r--tests/lib/OCS/ProviderTest.php86
-rw-r--r--tests/lib/Repair/ClearFrontendCachesTest.php2
-rw-r--r--tests/lib/Repair/NC11/FixMountStoragesTest.php11
-rw-r--r--tests/lib/RepairTest.php (renamed from tests/lib/RepairStepTest.php)45
-rw-r--r--tests/lib/Security/CertificateManagerTest.php2
-rw-r--r--tests/lib/Security/IdentityProof/ManagerTest.php48
-rw-r--r--tests/lib/Share20/ManagerTest.php253
-rw-r--r--tests/lib/Template/JSCombinerTest.php116
-rw-r--r--tests/lib/Updater/VersionCheckTest.php218
-rw-r--r--tests/lib/User/ManagerTest.php24
40 files changed, 1015 insertions, 578 deletions
diff --git a/tests/Core/Controller/LoginControllerTest.php b/tests/Core/Controller/LoginControllerTest.php
index cee3da65994..b80fde008d5 100644
--- a/tests/Core/Controller/LoginControllerTest.php
+++ b/tests/Core/Controller/LoginControllerTest.php
@@ -260,7 +260,7 @@ class LoginControllerTest extends TestCase {
[
'MessageArray1',
'MessageArray2',
- 'This community release of Nextcloud is unsupported and instant notifications are unavailable.',
+ 'This community release of Nextcloud is unsupported and push notifications are limited.',
]
);
$this->initialStateService->expects($this->at(1))
diff --git a/tests/acceptance/features/access-levels.feature b/tests/acceptance/features/access-levels.feature
index 9d5695897c0..de34a17baea 100644
--- a/tests/acceptance/features/access-levels.feature
+++ b/tests/acceptance/features/access-levels.feature
@@ -18,6 +18,6 @@ Feature: access-levels
Scenario: admin users can see admin-level items on the Settings page
Given I am logged in as the admin
- When I visit the settings page
+ When I visit the admin settings page
Then I see that the "Personal" settings panel is shown
And I see that the "Administration" settings panel is shown
diff --git a/tests/acceptance/features/app-files-sharing-link.feature b/tests/acceptance/features/app-files-sharing-link.feature
index d89c7b4289d..4fab8391531 100644
--- a/tests/acceptance/features/app-files-sharing-link.feature
+++ b/tests/acceptance/features/app-files-sharing-link.feature
@@ -177,7 +177,7 @@ Feature: app-files-sharing-link
And I see that the file list contains a file named "farewell.txt"
And I share "farewell.txt" with "user0"
And I see that the file is shared with "user0"
- And I visit the settings page
+ And I visit the admin settings page
And I open the "Sharing" section of the "Administration" group
And I disable resharing
And I see that resharing is disabled
@@ -208,7 +208,7 @@ Feature: app-files-sharing-link
And I share the link for "farewell.txt"
And I write down the shared link
And I act as John
- And I visit the settings page
+ And I visit the admin settings page
And I open the "Sharing" section of the "Administration" group
And I disable resharing
And I see that resharing is disabled
@@ -238,7 +238,7 @@ Feature: app-files-sharing-link
And I share the link for "farewell.txt"
And I write down the shared link
And I act as John
- And I visit the settings page
+ And I visit the admin settings page
And I open the "Sharing" section of the "Administration" group
And I disable resharing
And I see that resharing is disabled
diff --git a/tests/acceptance/features/app-files-sharing.feature b/tests/acceptance/features/app-files-sharing.feature
index 4f58d1d17ff..cbb8aae33e7 100644
--- a/tests/acceptance/features/app-files-sharing.feature
+++ b/tests/acceptance/features/app-files-sharing.feature
@@ -252,7 +252,7 @@ Feature: app-files-sharing
And I see that the file list contains a file named "Shared folder"
And I share "Shared folder" with "user0"
And I see that the file is shared with "user0"
- When I visit the settings page
+ When I visit the admin settings page
And I open the "Sharing" section of the "Administration" group
And I disable resharing
And I see that resharing is disabled
@@ -273,7 +273,7 @@ Feature: app-files-sharing
And I see that the file list contains a file named "Shared folder"
And I share "Shared folder" with "user0"
And I see that the file is shared with "user0"
- And I visit the settings page
+ And I visit the admin settings page
And I open the "Sharing" section of the "Administration" group
And I disable resharing
And I see that resharing is disabled
@@ -303,7 +303,7 @@ Feature: app-files-sharing
And I open the Files app
And I share "Shared folder" with "user1"
And I act as John
- And I visit the settings page
+ And I visit the admin settings page
And I open the "Sharing" section of the "Administration" group
And I disable resharing
And I see that resharing is disabled
@@ -336,7 +336,7 @@ Feature: app-files-sharing
And I open the Files app
And I share "Shared folder" with "user1"
And I act as John
- And I visit the settings page
+ And I visit the admin settings page
And I open the "Sharing" section of the "Administration" group
And I disable resharing
And I see that resharing is disabled
diff --git a/tests/acceptance/features/app-files-tags.feature b/tests/acceptance/features/app-files-tags.feature
index 8514a59d7d0..efb1277007f 100644
--- a/tests/acceptance/features/app-files-tags.feature
+++ b/tests/acceptance/features/app-files-tags.feature
@@ -21,7 +21,7 @@ Feature: app-files-tags
Scenario: create tags using the Administration settings
Given I am logged in as the admin
- And I visit the settings page
+ And I visit the admin settings page
And I open the "Basic settings" section of the "Administration" group
# The "create" button does nothing before JavaScript was initialized, and
# the only way to detect that is waiting for the button to select tags to be
@@ -32,7 +32,7 @@ Feature: app-files-tags
# Scenario: add tags using the dropdown in the details view
# Given I am logged in as the admin
-# And I visit the settings page
+# And I visit the admin settings page
# And I open the "Basic settings" section of the "Administration" group
# # The "create" button does nothing before JavaScript was initialized, and
# # the only way to detect that is waiting for the button to select tags to be
@@ -60,7 +60,7 @@ Feature: app-files-tags
#
# Scenario: remove tags using the dropdown in the details view
# Given I am logged in as the admin
-# And I visit the settings page
+# And I visit the admin settings page
# And I open the "Basic settings" section of the "Administration" group
# # The "create" button does nothing before JavaScript was initialized, and
# # the only way to detect that is waiting for the button to select tags to be
diff --git a/tests/acceptance/features/app-theming.feature b/tests/acceptance/features/app-theming.feature
index 01c7d8df8dd..676b90ab06e 100644
--- a/tests/acceptance/features/app-theming.feature
+++ b/tests/acceptance/features/app-theming.feature
@@ -3,25 +3,25 @@ Feature: app-theming
Scenario: changing the color updates the header color
Given I am logged in as the admin
- And I visit the settings page
+ And I visit the admin settings page
And I open the "Theming" section
And I see that the color selector in the Theming app has loaded
# The "eventually" part is not really needed here, as the colour is not
# being animated at this point, but there is no need to create a specific
# step just for this.
- And I see that the header color is eventually "#0082C9"
+ And I see that the background color is eventually "#0082C9"
When I set the "Color" parameter in the Theming app to "#C9C9C9"
Then I see that the parameters in the Theming app are eventually saved
- And I see that the header color is eventually "#C9C9C9"
+ And I see that the background color is eventually "#C9C9C9"
Scenario: resetting the color updates the header color
Given I am logged in as the admin
- And I visit the settings page
+ And I visit the admin settings page
And I open the "Theming" section
And I see that the color selector in the Theming app has loaded
And I set the "Color" parameter in the Theming app to "#C9C9C9"
And I see that the parameters in the Theming app are eventually saved
- And I see that the header color is eventually "#C9C9C9"
+ And I see that the background color is eventually "#C9C9C9"
When I reset the "Color" parameter in the Theming app to its default value
Then I see that the parameters in the Theming app are eventually saved
- And I see that the header color is eventually "#0082C9"
+ And I see that the background color is eventually "#0082C9"
diff --git a/tests/acceptance/features/bootstrap/AppNavigationContext.php b/tests/acceptance/features/bootstrap/AppNavigationContext.php
index ef8cb8cae8b..cba56856bfa 100644
--- a/tests/acceptance/features/bootstrap/AppNavigationContext.php
+++ b/tests/acceptance/features/bootstrap/AppNavigationContext.php
@@ -40,7 +40,7 @@ class AppNavigationContext implements Context, ActorAwareInterface {
* @return Locator
*/
public static function appNavigationSectionItemFor($sectionText) {
- return Locator::forThe()->xpath("//li/a[normalize-space() = '$sectionText']/..")->
+ return Locator::forThe()->xpath("//li/*[contains(normalize-space(), '$sectionText')]/..")->
descendantOf(self::appNavigation())->
describedAs($sectionText . " section item in App Navigation");
}
diff --git a/tests/acceptance/features/bootstrap/FilesAppContext.php b/tests/acceptance/features/bootstrap/FilesAppContext.php
index 31fe864bc36..124000f878d 100644
--- a/tests/acceptance/features/bootstrap/FilesAppContext.php
+++ b/tests/acceptance/features/bootstrap/FilesAppContext.php
@@ -46,7 +46,7 @@ class FilesAppContext implements Context, ActorAwareInterface {
* @return Locator
*/
private static function appMenu() {
- return Locator::forThe()->id("appmenu")->
+ return Locator::forThe()->css("header nav.app-menu")->
describedAs("App menu in header");
}
@@ -54,7 +54,7 @@ class FilesAppContext implements Context, ActorAwareInterface {
* @return Locator
*/
public static function filesItemInAppMenu() {
- return Locator::forThe()->xpath("/li[@data-id = 'files']")->
+ return Locator::forThe()->xpath("//li[@data-app-id = 'files']")->
descendantOf(self::appMenu())->
describedAs("Files item in app menu in header");
}
@@ -116,7 +116,7 @@ class FilesAppContext implements Context, ActorAwareInterface {
* @return Locator
*/
public static function notFavoritedStateIconInFileDetailsInDetailsView() {
- return Locator::forThe()->css(".star--star")->
+ return Locator::forThe()->css(".star-outline-icon")->
descendantOf(self::favoriteActionInFileDetailsInDetailsView())->
describedAs("Not favorited state icon in file details in details view in Files app");
}
@@ -125,7 +125,7 @@ class FilesAppContext implements Context, ActorAwareInterface {
* @return Locator
*/
public static function favoritedStateIconInFileDetailsInDetailsView() {
- return Locator::forThe()->css(".star--starred")->
+ return Locator::forThe()->css(".star-icon")->
descendantOf(self::favoriteActionInFileDetailsInDetailsView())->
describedAs("Favorited state icon in file details in details view in Files app");
}
diff --git a/tests/acceptance/features/bootstrap/FilesAppSharingContext.php b/tests/acceptance/features/bootstrap/FilesAppSharingContext.php
index ce3158f9bd9..fd85315f49f 100644
--- a/tests/acceptance/features/bootstrap/FilesAppSharingContext.php
+++ b/tests/acceptance/features/bootstrap/FilesAppSharingContext.php
@@ -88,7 +88,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface {
* @return Locator
*/
public static function shareWithMenuTrigger($sharedWithName) {
- return Locator::forThe()->css(".sharing-entry__actions .trigger")->
+ return Locator::forThe()->css(".sharing-entry__actions button")->
descendantOf(self::sharedWithRow($sharedWithName))->
describedAs("Share with $sharedWithName menu trigger in the details view in Files app");
}
@@ -197,7 +197,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface {
public static function shareLinkAddNewButton() {
// When there is no link share the "Add new share" item is shown instead
// of the menu button as a direct child of ".share-menu".
- return Locator::forThe()->css(".action-item.icon-add")->
+ return Locator::forThe()->css(".action-item.new-share-link")->
descendantOf(self::shareLinkRow())->
describedAs("Add new share link button in the details view in Files app");
}
@@ -215,7 +215,7 @@ class FilesAppSharingContext implements Context, ActorAwareInterface {
* @return Locator
*/
public static function shareLinkMenuTrigger() {
- return Locator::forThe()->css(".sharing-entry__actions .trigger")->
+ return Locator::forThe()->css(".sharing-entry__actions .action-item__menutoggle")->
descendantOf(self::shareLinkRow())->
describedAs("Share link menu trigger in the details view in Files app");
}
diff --git a/tests/acceptance/features/bootstrap/LoginPageContext.php b/tests/acceptance/features/bootstrap/LoginPageContext.php
index 3fb06abb235..01ad34ba149 100644
--- a/tests/acceptance/features/bootstrap/LoginPageContext.php
+++ b/tests/acceptance/features/bootstrap/LoginPageContext.php
@@ -54,7 +54,7 @@ class LoginPageContext implements Context, ActorAwareInterface {
}
public static function wrongPasswordMessage(): Locator {
- return Locator::forThe()->xpath("//*[@class = 'warning wrongPasswordMsg' and normalize-space() = 'Wrong username or password.']")->
+ return Locator::forThe()->xpath("//*[@class = 'input-field__helper-text-message input-field__helper-text-message--error' and normalize-space() = 'Wrong username or password.']")->
describedAs("Wrong password message in Login page");
}
@@ -62,7 +62,7 @@ class LoginPageContext implements Context, ActorAwareInterface {
* @return Locator
*/
public static function userDisabledMessage() {
- return Locator::forThe()->xpath("//*[@class = 'warning userDisabledMsg' and normalize-space() = 'User disabled']")->
+ return Locator::forThe()->xpath("//*[@class = 'input-field__helper-text-message input-field__helper-text-message--error' and normalize-space() = 'User disabled']")->
describedAs('User disabled message on login page');
}
diff --git a/tests/acceptance/features/bootstrap/SettingsMenuContext.php b/tests/acceptance/features/bootstrap/SettingsMenuContext.php
index 1572dea3faa..f89d8782198 100644
--- a/tests/acceptance/features/bootstrap/SettingsMenuContext.php
+++ b/tests/acceptance/features/bootstrap/SettingsMenuContext.php
@@ -144,6 +144,14 @@ class SettingsMenuContext implements Context, ActorAwareInterface {
}
/**
+ * @When I visit the admin settings page
+ */
+ public function iVisitTheAdminSettingsPage() {
+ $this->iOpenTheSettingsMenu();
+ $this->actor->find(self::menuItemFor('Administration settings'), 2)->click();
+ }
+
+ /**
* @When I log out
*/
public function iLogOut() {
diff --git a/tests/acceptance/features/bootstrap/ThemingAppContext.php b/tests/acceptance/features/bootstrap/ThemingAppContext.php
index d17d9c18109..248d58a1794 100644
--- a/tests/acceptance/features/bootstrap/ThemingAppContext.php
+++ b/tests/acceptance/features/bootstrap/ThemingAppContext.php
@@ -125,19 +125,19 @@ class ThemingAppContext implements Context, ActorAwareInterface {
}
/**
- * @Then I see that the header color is eventually :color
+ * @Then I see that the background color is eventually :color
*/
- public function iSeeThatTheHeaderColorIsEventually($color) {
- $headerColorMatchesCallback = function () use ($color) {
- $headerColor = $this->actor->getSession()->evaluateScript("return $('#header').css('background-color');");
+ public function iSeeThatTheBackgroundColorIsEventually($color) {
+ $backgroundColorMatchesCallback = function () use ($color) {
+ $headerColor = $this->actor->getSession()->evaluateScript("return $('body').css('background-color');");
$headerColor = $this->getRGBArray($headerColor);
$color = $this->getRGBArray($color);
return $headerColor == $color;
};
- if (!Utils::waitFor($headerColorMatchesCallback, $timeout = 10 * $this->actor->getFindTimeoutMultiplier(), $timeoutStep = 1)) {
- Assert::fail("The header color is not $color yet after $timeout seconds");
+ if (!Utils::waitFor($backgroundColorMatchesCallback, $timeout = 10 * $this->actor->getFindTimeoutMultiplier(), $timeoutStep = 1)) {
+ Assert::fail("The background color is not $color yet after $timeout seconds");
}
}
diff --git a/tests/acceptance/features/bootstrap/UsersSettingsContext.php b/tests/acceptance/features/bootstrap/UsersSettingsContext.php
index ce035647104..4d17b3b5118 100644
--- a/tests/acceptance/features/bootstrap/UsersSettingsContext.php
+++ b/tests/acceptance/features/bootstrap/UsersSettingsContext.php
@@ -161,7 +161,7 @@ class UsersSettingsContext implements Context, ActorAwareInterface {
* @return Locator
*/
public static function editModeToggle($user) {
- return Locator::forThe()->css(".toggleUserActions button.icon-rename")->
+ return Locator::forThe()->css(".toggleUserActions button")->
descendantOf(self::rowForUser($user))->
describedAs("The edit toggle button for the user $user in Users Settings");
}
@@ -293,8 +293,12 @@ class UsersSettingsContext implements Context, ActorAwareInterface {
* @Then I see that the new user form is shown
*/
public function iSeeThatTheNewUserFormIsShown() {
- Assert::assertTrue(
- $this->actor->find(self::newUserForm(), 10)->isVisible());
+ if (!WaitFor::elementToBeEventuallyShown(
+ $this->actor,
+ self::newUserForm(),
+ $timeout = 10 * $this->actor->getFindTimeoutMultiplier())) {
+ Assert::fail("The new user form is not shown yet after $timeout seconds");
+ }
}
/**
diff --git a/tests/acceptance/features/core/ActorContext.php b/tests/acceptance/features/core/ActorContext.php
index b3c8b6f0459..aa538f06069 100644
--- a/tests/acceptance/features/core/ActorContext.php
+++ b/tests/acceptance/features/core/ActorContext.php
@@ -137,6 +137,8 @@ class ActorContext extends RawMinkContext {
$this->getSession()->start();
+ $this->getSession()->maximizeWindow();
+
$this->actors["default"] = new Actor("default", $this->getSession(), $this->getMinkParameter("base_url"), $this->sharedNotebook);
$this->actors["default"]->setFindTimeoutMultiplier($this->actorTimeoutMultiplier);
@@ -163,6 +165,8 @@ class ActorContext extends RawMinkContext {
if (!array_key_exists($actorName, $this->actors)) {
$this->getSession($actorName)->start();
+ $this->getSession($actorName)->maximizeWindow();
+
$this->actors[$actorName] = new Actor($actorName, $this->getSession($actorName), $this->getMinkParameter("base_url"), $this->sharedNotebook);
$this->actors[$actorName]->setFindTimeoutMultiplier($this->actorTimeoutMultiplier);
}
diff --git a/tests/acceptance/features/header.feature b/tests/acceptance/features/header.feature
index 9931bc67436..21f9147c9ac 100644
--- a/tests/acceptance/features/header.feature
+++ b/tests/acceptance/features/header.feature
@@ -5,9 +5,10 @@ Feature: header
Given I am logged in as the admin
When I open the Settings menu
Then I see that the Settings menu is shown
- And I see that the Settings menu has only 7 items
+ And I see that the Settings menu has only 8 items
And I see that the "Set status" item in the Settings menu is shown
- And I see that the "Settings" item in the Settings menu is shown
+ And I see that the "Personal settings" item in the Settings menu is shown
+ And I see that the "Administration settings" item in the Settings menu is shown
And I see that the "Apps" item in the Settings menu is shown
And I see that the "Users" item in the Settings menu is shown
And I see that the "Help" item in the Settings menu is shown
@@ -32,7 +33,7 @@ Feature: header
Scenario: users from other groups are not seen in the contacts menu when autocompletion is restricted within the same group
Given I am logged in as the admin
- And I visit the settings page
+ And I visit the admin settings page
And I open the "Sharing" section of the "Administration" group
And I enable restricting username autocompletion to groups
And I see that username autocompletion is restricted to groups
diff --git a/tests/lib/App/DependencyAnalyzerTest.php b/tests/lib/App/DependencyAnalyzerTest.php
index 1e37948d783..75cc991cf99 100644
--- a/tests/lib/App/DependencyAnalyzerTest.php
+++ b/tests/lib/App/DependencyAnalyzerTest.php
@@ -35,7 +35,7 @@ class DependencyAnalyzerTest extends TestCase {
->willReturn('5.4.3');
$this->platformMock->expects($this->any())
->method('getIntSize')
- ->willReturn('4');
+ ->willReturn(4);
$this->platformMock->expects($this->any())
->method('getDatabase')
->willReturn('mysql');
diff --git a/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php b/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php
index f9739044465..be684e36013 100644
--- a/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php
+++ b/tests/lib/AppFramework/Middleware/SessionMiddlewareTest.php
@@ -35,7 +35,7 @@ class SessionMiddlewareTest extends \Test\TestCase {
* @UseSession
*/
public function testSessionNotClosedOnBeforeController() {
- $session = $this->getSessionMock(0);
+ $session = $this->getSessionMock(0, 1);
$this->reflector->reflect($this, __FUNCTION__);
$middleware = new SessionMiddleware($this->reflector, $session);
@@ -53,8 +53,20 @@ class SessionMiddlewareTest extends \Test\TestCase {
$middleware->afterController($this->controller, __FUNCTION__, new Response());
}
+ /**
+ * @UseSession
+ */
+ public function testSessionReopenedAndClosedOnBeforeController() {
+ $session = $this->getSessionMock(1, 1);
+
+ $this->reflector->reflect($this, __FUNCTION__);
+ $middleware = new SessionMiddleware($this->reflector, $session);
+ $middleware->beforeController($this->controller, __FUNCTION__);
+ $middleware->afterController($this->controller, __FUNCTION__, new Response());
+ }
+
public function testSessionClosedOnBeforeController() {
- $session = $this->getSessionMock(1);
+ $session = $this->getSessionMock(0);
$this->reflector->reflect($this, __FUNCTION__);
$middleware = new SessionMiddleware($this->reflector, $session);
@@ -72,13 +84,15 @@ class SessionMiddlewareTest extends \Test\TestCase {
/**
* @return mixed
*/
- private function getSessionMock($expectedCloseCount) {
+ private function getSessionMock(int $expectedCloseCount, int $expectedReopenCount = 0) {
$session = $this->getMockBuilder('\OC\Session\Memory')
->disableOriginalConstructor()
->getMock();
$session->expects($this->exactly($expectedCloseCount))
->method('close');
+ $session->expects($this->exactly($expectedReopenCount))
+ ->method('reopen');
return $session;
}
}
diff --git a/tests/lib/BackgroundJob/DummyJobList.php b/tests/lib/BackgroundJob/DummyJobList.php
index be9c06257b7..4d14ed9e7db 100644
--- a/tests/lib/BackgroundJob/DummyJobList.php
+++ b/tests/lib/BackgroundJob/DummyJobList.php
@@ -33,7 +33,7 @@ class DummyJobList extends \OC\BackgroundJob\JobList {
public function add($job, $argument = null): void {
if (is_string($job)) {
/** @var IJob $job */
- $job = new $job;
+ $job = \OCP\Server::get($job);
}
$job->setArgument($argument);
if (!$this->has($job, null)) {
diff --git a/tests/lib/Calendar/ManagerTest.php b/tests/lib/Calendar/ManagerTest.php
index a4d9d45fdb2..8b99c21ae41 100644
--- a/tests/lib/Calendar/ManagerTest.php
+++ b/tests/lib/Calendar/ManagerTest.php
@@ -25,10 +25,14 @@ namespace Test\Calendar;
use OC\AppFramework\Bootstrap\Coordinator;
use OC\Calendar\Manager;
+use OCP\AppFramework\Utility\ITimeFactory;
use OCP\Calendar\ICalendar;
+use OCP\Calendar\ICreateFromString;
use PHPUnit\Framework\MockObject\MockObject;
use Psr\Container\ContainerInterface;
use Psr\Log\LoggerInterface;
+use Sabre\VObject\Document;
+use Sabre\VObject\Reader;
use Test\TestCase;
class ManagerTest extends TestCase {
@@ -45,17 +49,22 @@ class ManagerTest extends TestCase {
/** @var Manager */
private $manager;
+ /** @var ITimeFactory|ITimeFactory&MockObject|MockObject */
+ private $time;
+
protected function setUp(): void {
parent::setUp();
$this->coordinator = $this->createMock(Coordinator::class);
$this->container = $this->createMock(ContainerInterface::class);
$this->logger = $this->createMock(LoggerInterface::class);
+ $this->time = $this->createMock(ITimeFactory::class);
$this->manager = new Manager(
$this->coordinator,
$this->container,
- $this->logger
+ $this->logger,
+ $this->time,
);
}
@@ -231,4 +240,370 @@ class ManagerTest extends TestCase {
$isEnabled = $this->manager->isEnabled();
$this->assertTrue($isEnabled);
}
+
+ public function testHandleImipReplyWrongMethod(): void {
+ $principalUri = 'principals/user/linus';
+ $sender = 'pierre@general-store.com';
+ $recipient = 'linus@stardew-tent-living.com';
+ $calendarData = $this->getVCalendarReply();
+ $calendarData->METHOD = 'REQUEST';
+
+ $this->logger->expects(self::once())
+ ->method('warning');
+ $this->time->expects(self::never())
+ ->method('getTimestamp');
+
+ $result = $this->manager->handleIMipReply($principalUri, $sender, $recipient, $calendarData->serialize());
+ $this->assertFalse($result);
+ }
+
+ public function testHandleImipReplyOrganizerNotRecipient(): void {
+ $principalUri = 'principals/user/linus';
+ $recipient = 'pierre@general-store.com';
+ $sender = 'linus@stardew-tent-living.com';
+ $calendarData = $this->getVCalendarReply();
+
+ $this->logger->expects(self::once())
+ ->method('warning');
+ $this->time->expects(self::never())
+ ->method('getTimestamp');
+
+ $result = $this->manager->handleIMipReply($principalUri, $sender, $recipient, $calendarData->serialize());
+ $this->assertFalse($result);
+ }
+
+ public function testHandleImipReplyDateInThePast(): void {
+ $principalUri = 'principals/user/linus';
+ $sender = 'pierre@general-store.com';
+ $recipient = 'linus@stardew-tent-living.com';
+ $calendarData = $this->getVCalendarReply();
+ $calendarData->VEVENT->DTSTART = new \DateTime('2013-04-07'); // set to in the past
+
+ $this->time->expects(self::once())
+ ->method('getTimestamp')
+ ->willReturn(time());
+
+ $this->logger->expects(self::once())
+ ->method('warning');
+
+ $result = $this->manager->handleIMipReply($principalUri, $sender, $recipient, $calendarData->serialize());
+ $this->assertFalse($result);
+ }
+
+ public function testHandleImipReplyNoCalendars(): void {
+ /** @var Manager | \PHPUnit\Framework\MockObject\MockObject $manager */
+ $manager = $this->getMockBuilder(Manager::class)
+ ->setConstructorArgs([
+ $this->coordinator,
+ $this->container,
+ $this->logger,
+ $this->time
+ ])
+ ->setMethods([
+ 'getCalendarsForPrincipal'
+ ]);
+ $principalUri = 'principals/user/linus';
+ $sender = 'pierre@general-store.com';
+ $recipient = 'linus@stardew-tent-living.com';
+ $calendarData = $this->getVCalendarReply();
+
+ $this->time->expects(self::once())
+ ->method('getTimestamp')
+ ->willReturn(202208219);
+ $manager->expects(self::once())
+ ->method('getCalendarsForPrincipal')
+ ->willReturn([]);
+ $this->logger->expects(self::once())
+ ->method('warning');
+
+ $result = $manager->handleIMipReply($principalUri, $sender, $recipient, $calendarData->serialize());
+ $this->assertFalse($result);
+ }
+
+ public function testHandleImipReplyEventNotFound(): void {
+ /** @var Manager | \PHPUnit\Framework\MockObject\MockObject $manager */
+ $manager = $this->getMockBuilder(Manager::class)
+ ->setConstructorArgs([
+ $this->coordinator,
+ $this->container,
+ $this->logger,
+ $this->time
+ ])
+ ->setMethods([
+ 'getCalendarsForPrincipal'
+ ]);
+ $calendar = $this->createMock(ICreateFromString::class);
+ $principalUri = 'principals/user/linus';
+ $sender = 'pierre@general-store.com';
+ $recipient = 'linus@stardew-tent-living.com';
+ $calendarData = $this->getVCalendarReply();
+
+ $this->time->expects(self::once())
+ ->method('getTimestamp')
+ ->willReturn(202208219);
+ $manager->expects(self::once())
+ ->method('getCalendarsForPrincipal')
+ ->willReturn([$calendar]);
+ $calendar->expects(self::once())
+ ->method('search')
+ ->willReturn([]);
+ $this->logger->expects(self::once())
+ ->method('info');
+ $calendar->expects(self::never())
+ ->method('handleIMipMessage');
+
+ $result = $manager->handleIMipReply($principalUri, $sender, $recipient, $calendarData->serialize());
+ $this->assertFalse($result);
+ }
+
+ public function testHandleImipReply(): void {
+ /** @var Manager | \PHPUnit\Framework\MockObject\MockObject $manager */
+ $manager = $this->getMockBuilder(Manager::class)
+ ->setConstructorArgs([
+ $this->coordinator,
+ $this->container,
+ $this->logger,
+ $this->time
+ ])
+ ->setMethods([
+ 'getCalendarsForPrincipal'
+ ]);
+ $calendar = $this->createMock(ICreateFromString::class);
+ $principalUri = 'principals/user/linus';
+ $sender = 'pierre@general-store.com';
+ $recipient = 'linus@stardew-tent-living.com';
+ $calendarData = $this->getVCalendarReply();
+
+ $this->time->expects(self::once())
+ ->method('getTimestamp')
+ ->willReturn(202208219);
+ $manager->expects(self::once())
+ ->method('getCalendarsForPrincipal')
+ ->willReturn([$calendar]);
+ $calendar->expects(self::once())
+ ->method('search')
+ ->willReturn([['uri' => 'testname.ics']]);
+ $calendar->expects(self::once())
+ ->method('handleIMipMessage')
+ ->with('testname.ics', $calendarData->serialize());
+
+ $result = $manager->handleIMipReply($principalUri, $sender, $recipient, $calendarData->serialize());
+ $this->assertTrue($result);
+ }
+
+ public function testHandleImipCancelWrongMethod(): void {
+ $principalUri = 'principals/user/pierre';
+ $sender = 'linus@stardew-tent-living.com';
+ $recipient = 'pierre@general-store.com';
+ $replyTo = null;
+ $calendarData = $this->getVCalendarCancel();
+ $calendarData->VEVENT->METHOD = 'REQUEST';
+
+ $this->logger->expects(self::once())
+ ->method('warning');
+ $this->time->expects(self::never())
+ ->method('getTimestamp');
+
+ $result = $this->manager->handleIMipCancel($principalUri, $sender, $replyTo, $recipient, $calendarData->serialize());
+ $this->assertFalse($result);
+ }
+
+ public function testHandleImipCancelAttendeeNotRecipient(): void {
+ $principalUri = '/user/admin';
+ $sender = 'linus@stardew-tent-living.com';
+ $recipient = 'leah@general-store.com';
+ $replyTo = null;
+ $calendarData = $this->getVCalendarCancel();
+ $calendarData->VEVENT->METHOD = 'CANCEL';
+
+ $this->logger->expects(self::once())
+ ->method('warning');
+ $this->time->expects(self::never())
+ ->method('getTimestamp');
+
+ $result = $this->manager->handleIMipCancel($principalUri, $sender, $replyTo, $recipient, $calendarData->serialize());
+ $this->assertFalse($result);
+ }
+
+ public function testHandleImipCancelDateInThePast(): void {
+ $principalUri = 'principals/user/pierre';
+ $sender = 'linus@stardew-tent-living.com';
+ $recipient = 'pierre@general-store.com';
+ $replyTo = null;
+ $calendarData = $this->getVCalendarCancel();
+ $calendarData->VEVENT->DTSTART = new \DateTime('2013-04-07'); // set to in the past
+
+ $this->time->expects(self::once())
+ ->method('getTimestamp')
+ ->willReturn(time());
+ $this->logger->expects(self::once())
+ ->method('warning');
+
+ $result = $this->manager->handleIMipCancel($principalUri, $sender, $replyTo, $recipient, $calendarData->serialize());
+ $this->assertFalse($result);
+ }
+
+ public function testHandleImipCancelNoCalendars(): void {
+ /** @var Manager | \PHPUnit\Framework\MockObject\MockObject $manager */
+ $manager = $this->getMockBuilder(Manager::class)
+ ->setConstructorArgs([
+ $this->coordinator,
+ $this->container,
+ $this->logger,
+ $this->time
+ ])
+ ->setMethods([
+ 'getCalendarsForPrincipal'
+ ]);
+ $principalUri = 'principals/user/pierre';
+ $sender = 'linus@stardew-tent-living.com';
+ $recipient = 'pierre@general-store.com';
+ $replyTo = null;
+ $calendarData = $this->getVCalendarCancel();
+
+ $this->time->expects(self::once())
+ ->method('getTimestamp')
+ ->willReturn(202208219);
+ $manager->expects(self::once())
+ ->method('getCalendarsForPrincipal')
+ ->with($principalUri)
+ ->willReturn([]);
+ $this->logger->expects(self::once())
+ ->method('warning');
+
+ $result = $this->manager->handleIMipCancel($principalUri, $sender, $replyTo, $recipient, $calendarData->serialize());
+ $this->assertTrue($result);
+ }
+
+ public function testHandleImipCancelOrganiserInReplyTo(): void {
+ /** @var Manager | \PHPUnit\Framework\MockObject\MockObject $manager */
+ $manager = $this->getMockBuilder(Manager::class)
+ ->setConstructorArgs([
+ $this->coordinator,
+ $this->container,
+ $this->logger,
+ $this->time
+ ])
+ ->setMethods([
+ 'getCalendarsForPrincipal'
+ ]);
+ $principalUri = 'principals/user/pierre';
+ $sender = 'clint@stardew-blacksmiths.com';
+ $recipient = 'pierre@general-store.com';
+ $replyTo = 'linus@stardew-tent-living.com';
+ $calendar = $this->createMock(ICreateFromString::class);
+ $calendarData = $this->getVCalendarCancel();
+ $calendarData->VEVENT->METHOD = 'CANCEL';
+
+ $this->time->expects(self::once())
+ ->method('getTimestamp')
+ ->willReturn(202208219);
+ $manager->expects(self::once())
+ ->method('getCalendarsForPrincipal')
+ ->with($principalUri)
+ ->willReturn([$calendar]);
+ $calendar->expects(self::once())
+ ->method('search')
+ ->willReturn([['uri' => 'testname.ics']]);
+ $calendar->expects(self::once())
+ ->method('handleIMipMessage')
+ ->with('testname.ics', $calendarData->serialize());
+ $result = $this->manager->handleIMipCancel($principalUri, $sender, $replyTo, $recipient, $calendarData->serialize());
+ $this->assertFalse($result);
+ }
+
+ public function testHandleImipCancel(): void {
+ /** @var Manager | \PHPUnit\Framework\MockObject\MockObject $manager */
+ $manager = $this->getMockBuilder(Manager::class)
+ ->setConstructorArgs([
+ $this->coordinator,
+ $this->container,
+ $this->logger,
+ $this->time
+ ])
+ ->setMethods([
+ 'getCalendarsForPrincipal'
+ ]);
+ $principalUri = 'principals/user/pierre';
+ $sender = 'linus@stardew-tent-living.com';
+ $recipient = 'pierre@general-store.com';
+ $replyTo = null;
+ $calendar = $this->createMock(ICreateFromString::class);
+ $calendarData = $this->getVCalendarCancel();
+ $calendarData->VEVENT->METHOD = 'CANCEL';
+
+ $this->time->expects(self::once())
+ ->method('getTimestamp')
+ ->willReturn(202208219);
+ $manager->expects(self::once())
+ ->method('getCalendarsForPrincipal')
+ ->with($principalUri)
+ ->willReturn([$calendar]);
+ $calendar->expects(self::once())
+ ->method('search')
+ ->willReturn([['uri' => 'testname.ics']]);
+ $calendar->expects(self::once())
+ ->method('handleIMipMessage')
+ ->with('testname.ics', $calendarData->serialize());
+ $result = $this->manager->handleIMipCancel($principalUri, $sender, $replyTo, $recipient, $calendarData->serialize());
+ $this->assertFalse($result);
+ }
+
+ private function getVCalendarReply(): Document {
+ $data = <<<EOF
+BEGIN:VCALENDAR
+PRODID:-//Nextcloud/Nextcloud CalDAV Server//EN
+VERSION:2.0
+CALSCALE:GREGORIAN
+METHOD:REPLY
+BEGIN:VEVENT
+DTSTART;VALUE=DATE:20210820
+DTEND;VALUE=DATE:20220821
+DTSTAMP:20210812T100040Z
+ORGANIZER;CN=admin:mailto:linus@stardew-tent-living.com
+UID:dcc733bf-b2b2-41f2-a8cf-550ae4b67aff
+ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;CN=pierr
+ e@general-store.com;X-NUM-GUESTS=0:mailto:pierre@general-store.com
+CREATED:20220812T100021Z
+DESCRIPTION:
+LAST-MODIFIED:20220812T100040Z
+LOCATION:
+SEQUENCE:3
+STATUS:CONFIRMED
+SUMMARY:berry basket
+TRANSP:OPAQUE
+END:VEVENT
+END:VCALENDAR
+EOF;
+ return Reader::read($data);
+ }
+
+ private function getVCalendarCancel(): Document {
+ $data = <<<EOF
+BEGIN:VCALENDAR
+PRODID:-//Nextcloud/Nextcloud CalDAV Server//EN
+VERSION:2.0
+CALSCALE:GREGORIAN
+METHOD:CANCEL
+BEGIN:VEVENT
+DTSTART;VALUE=DATE:20210820
+DTEND;VALUE=DATE:20220821
+DTSTAMP:20210812T100040Z
+ORGANIZER;CN=admin:mailto:linus@stardew-tent-living.com
+UID:dcc733bf-b2b2-41f2-a8cf-550ae4b67aff
+ATTENDEE;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;PARTSTAT=ACCEPTED;CN=pierr
+ e@general-store.com;X-NUM-GUESTS=0:mailto:pierre@general-store.com
+CREATED:20220812T100021Z
+DESCRIPTION:
+LAST-MODIFIED:20220812T100040Z
+LOCATION:
+SEQUENCE:3
+STATUS:CANCELLED
+SUMMARY:berry basket
+TRANSP:OPAQUE
+END:VEVENT
+END:VCALENDAR
+EOF;
+ return Reader::read($data);
+ }
}
diff --git a/tests/lib/Collaboration/Collaborators/MailPluginTest.php b/tests/lib/Collaboration/Collaborators/MailPluginTest.php
index 702c1d6be6e..3cf76c562a1 100644
--- a/tests/lib/Collaboration/Collaborators/MailPluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/MailPluginTest.php
@@ -29,7 +29,9 @@ use OC\Federation\CloudIdManager;
use OC\KnownUser\KnownUserService;
use OCP\Collaboration\Collaborators\SearchResultType;
use OCP\Contacts\IManager;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\ICloudIdManager;
+use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IGroupManager;
use OCP\IURLGenerator;
@@ -77,7 +79,13 @@ class MailPluginTest extends TestCase {
$this->knownUserService = $this->createMock(KnownUserService::class);
$this->userSession = $this->createMock(IUserSession::class);
$this->mailer = $this->createMock(IMailer::class);
- $this->cloudIdManager = new CloudIdManager($this->contactsManager, $this->createMock(IURLGenerator::class), $this->createMock(IUserManager::class));
+ $this->cloudIdManager = new CloudIdManager(
+ $this->contactsManager,
+ $this->createMock(IURLGenerator::class),
+ $this->createMock(IUserManager::class),
+ $this->createMock(ICacheFactory::class),
+ $this->createMock(IEventDispatcher::class)
+ );
$this->searchResult = new SearchResult();
}
diff --git a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php
index 4072f3ecde1..22bd6f84be9 100644
--- a/tests/lib/Collaboration/Collaborators/RemotePluginTest.php
+++ b/tests/lib/Collaboration/Collaborators/RemotePluginTest.php
@@ -28,7 +28,9 @@ use OC\Collaboration\Collaborators\SearchResult;
use OC\Federation\CloudIdManager;
use OCP\Collaboration\Collaborators\SearchResultType;
use OCP\Contacts\IManager;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\ICloudIdManager;
+use OCP\ICacheFactory;
use OCP\IConfig;
use OCP\IURLGenerator;
use OCP\IUser;
@@ -63,7 +65,13 @@ class RemotePluginTest extends TestCase {
$this->userManager = $this->createMock(IUserManager::class);
$this->config = $this->createMock(IConfig::class);
$this->contactsManager = $this->createMock(IManager::class);
- $this->cloudIdManager = new CloudIdManager($this->contactsManager, $this->createMock(IURLGenerator::class), $this->createMock(IUserManager::class));
+ $this->cloudIdManager = new CloudIdManager(
+ $this->contactsManager,
+ $this->createMock(IURLGenerator::class),
+ $this->createMock(IUserManager::class),
+ $this->createMock(ICacheFactory::class),
+ $this->createMock(IEventDispatcher::class)
+ );
$this->searchResult = new SearchResult();
}
diff --git a/tests/lib/DB/MigratorTest.php b/tests/lib/DB/MigratorTest.php
index af44159efa3..af56730f9f6 100644
--- a/tests/lib/DB/MigratorTest.php
+++ b/tests/lib/DB/MigratorTest.php
@@ -62,7 +62,7 @@ class MigratorTest extends \Test\TestCase {
private function getMigrator(): Migrator {
$platform = $this->connection->getDatabasePlatform();
$random = \OC::$server->getSecureRandom();
- $dispatcher = \OC::$server->getEventDispatcher();
+ $dispatcher = \OC::$server->get(\OCP\EventDispatcher\IEventDispatcher::class);
if ($platform instanceof SqlitePlatform) {
return new SQLiteMigrator($this->connection, $this->config, $dispatcher);
} elseif ($platform instanceof OraclePlatform) {
diff --git a/tests/lib/Federation/CloudIdManagerTest.php b/tests/lib/Federation/CloudIdManagerTest.php
index 92f8a5fa8dd..0db36b0524a 100644
--- a/tests/lib/Federation/CloudIdManagerTest.php
+++ b/tests/lib/Federation/CloudIdManagerTest.php
@@ -22,7 +22,10 @@
namespace Test\Federation;
use OC\Federation\CloudIdManager;
+use OC\Memcache\ArrayCache;
use OCP\Contacts\IManager;
+use OCP\EventDispatcher\IEventDispatcher;
+use OCP\ICacheFactory;
use OCP\IURLGenerator;
use OCP\IUserManager;
use Test\TestCase;
@@ -36,6 +39,8 @@ class CloudIdManagerTest extends TestCase {
private $userManager;
/** @var CloudIdManager */
private $cloudIdManager;
+ /** @var ICacheFactory|\PHPUnit\Framework\MockObject\MockObject */
+ private $cacheFactory;
protected function setUp(): void {
@@ -45,7 +50,17 @@ class CloudIdManagerTest extends TestCase {
$this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->userManager = $this->createMock(IUserManager::class);
- $this->cloudIdManager = new CloudIdManager($this->contactsManager, $this->urlGenerator, $this->userManager);
+ $this->cacheFactory = $this->createMock(ICacheFactory::class);
+ $this->cacheFactory->method('createLocal')
+ ->willReturn(new ArrayCache(''));
+
+ $this->cloudIdManager = new CloudIdManager(
+ $this->contactsManager,
+ $this->urlGenerator,
+ $this->userManager,
+ $this->cacheFactory,
+ $this->createMock(IEventDispatcher::class)
+ );
}
public function cloudIdProvider() {
diff --git a/tests/lib/Files/Node/FolderTest.php b/tests/lib/Files/Node/FolderTest.php
index 4cda92b6e83..ddf6c412dcd 100644
--- a/tests/lib/Files/Node/FolderTest.php
+++ b/tests/lib/Files/Node/FolderTest.php
@@ -14,6 +14,7 @@ use OC\Files\Config\CachedMountInfo;
use OC\Files\FileInfo;
use OC\Files\Mount\Manager;
use OC\Files\Mount\MountPoint;
+use OC\Files\Node\File;
use OC\Files\Node\Folder;
use OC\Files\Node\Node;
use OC\Files\Node\Root;
@@ -105,11 +106,13 @@ class FolderTest extends NodeTest {
->method('getUser')
->willReturn($this->user);
+ $node = new File($root, $view, '/bar/foo/asd');
$root->method('get')
- ->with('/bar/foo/asd');
+ ->with('/bar/foo/asd')
+ ->willReturn($node);
- $node = new Folder($root, $view, '/bar/foo');
- $node->get('asd');
+ $parentNode = new Folder($root, $view, '/bar/foo');
+ self::assertEquals($node, $parentNode->get('asd'));
}
public function testNodeExists() {
@@ -178,11 +181,38 @@ class FolderTest extends NodeTest {
->willReturn(true);
$node = new Folder($root, $view, '/bar/foo');
- $child = new Folder($root, $view, '/bar/foo/asd');
+ $child = new Folder($root, $view, '/bar/foo/asd', null, $node);
$result = $node->newFolder('asd');
$this->assertEquals($child, $result);
}
+ public function testNewFolderDeepParent() {
+ $manager = $this->createMock(Manager::class);
+ /**
+ * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
+ */
+ $view = $this->createMock(View::class);
+ $root = $this->getMockBuilder(Root::class)
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->getMock();
+ $root->expects($this->any())
+ ->method('getUser')
+ ->willReturn($this->user);
+
+ $view->method('getFileInfo')
+ ->with('/foobar')
+ ->willReturn($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_ALL]));
+
+ $view->method('mkdir')
+ ->with('/foobar/asd/sdf')
+ ->willReturn(true);
+
+ $node = new Folder($root, $view, '/foobar');
+ $child = new Folder($root, $view, '/foobar/asd/sdf', null, null);
+ $result = $node->newFolder('asd/sdf');
+ $this->assertEquals($child, $result);
+ }
+
public function testNewFolderNotPermitted() {
$this->expectException(\OCP\Files\NotPermittedException::class);
@@ -228,7 +258,7 @@ class FolderTest extends NodeTest {
->willReturn(true);
$node = new Folder($root, $view, '/bar/foo');
- $child = new \OC\Files\Node\File($root, $view, '/bar/foo/asd');
+ $child = new \OC\Files\Node\File($root, $view, '/bar/foo/asd', null, $node);
$result = $node->newFile('asd');
$this->assertEquals($child, $result);
}
diff --git a/tests/lib/L10N/FactoryTest.php b/tests/lib/L10N/FactoryTest.php
index faf9dff48cc..4e01602a4f7 100644
--- a/tests/lib/L10N/FactoryTest.php
+++ b/tests/lib/L10N/FactoryTest.php
@@ -146,20 +146,21 @@ class FactoryTest extends TestCase {
public function testFindLanguageWithNotExistingRequestLanguageAndNotExistingStoredUserLanguage(): void {
$factory = $this->getFactory(['languageExists'], true);
$this->invokePrivate($factory, 'requestLanguage', ['de']);
- $factory->expects(self::at(0))
- ->method('languageExists')
- ->with('MyApp', 'de')
- ->willReturn(false);
+ $factory->expects($this->exactly(3))
+ ->method('languageExists')
+ ->willReturnMap([
+ ['MyApp', 'de', false],
+ ['MyApp', 'jp', false],
+ ['MyApp', 'es', true],
+ ]);
$this->config
- ->expects(self::at(0))
+ ->expects($this->exactly(3))
->method('getSystemValue')
- ->with('force_language', false)
- ->willReturn(false);
- $this->config
- ->expects(self::at(1))
- ->method('getSystemValue')
- ->with('installed', false)
- ->willReturn(true);
+ ->willReturnMap([
+ ['force_language', false, false],
+ ['installed', false, true],
+ ['default_language', false, 'es']
+ ]);
$user = $this->getMockBuilder(IUser::class)
->getMock();
$user->expects(self::once())
@@ -174,19 +175,6 @@ class FactoryTest extends TestCase {
->method('getUserValue')
->with('MyUserUid', 'core', 'lang', null)
->willReturn('jp');
- $factory->expects(self::at(1))
- ->method('languageExists')
- ->with('MyApp', 'jp')
- ->willReturn(false);
- $this->config
- ->expects(self::at(3))
- ->method('getSystemValue')
- ->with('default_language', false)
- ->willReturn('es');
- $factory->expects(self::at(2))
- ->method('languageExists')
- ->with('MyApp', 'es')
- ->willReturn(true);
self::assertSame('es', $factory->findLanguage('MyApp'));
}
@@ -194,20 +182,21 @@ class FactoryTest extends TestCase {
public function testFindLanguageWithNotExistingRequestLanguageAndNotExistingStoredUserLanguageAndNotExistingDefault(): void {
$factory = $this->getFactory(['languageExists'], true);
$this->invokePrivate($factory, 'requestLanguage', ['de']);
- $factory->expects(self::at(0))
- ->method('languageExists')
- ->with('MyApp', 'de')
- ->willReturn(false);
+ $factory->expects($this->exactly(3))
+ ->method('languageExists')
+ ->willReturnMap([
+ ['MyApp', 'de', false],
+ ['MyApp', 'jp', false],
+ ['MyApp', 'es', false],
+ ]);
$this->config
- ->expects(self::at(0))
+ ->expects($this->exactly(3))
->method('getSystemValue')
- ->with('force_language', false)
- ->willReturn(false);
- $this->config
- ->expects(self::at(1))
- ->method('getSystemValue')
- ->with('installed', false)
- ->willReturn(true);
+ ->willReturnMap([
+ ['force_language', false, false],
+ ['installed', false, true],
+ ['default_language', false, 'es']
+ ]);
$user = $this->getMockBuilder(IUser::class)
->getMock();
$user->expects(self::once())
@@ -222,19 +211,6 @@ class FactoryTest extends TestCase {
->method('getUserValue')
->with('MyUserUid', 'core', 'lang', null)
->willReturn('jp');
- $factory->expects(self::at(1))
- ->method('languageExists')
- ->with('MyApp', 'jp')
- ->willReturn(false);
- $this->config
- ->expects(self::at(3))
- ->method('getSystemValue')
- ->with('default_language', false)
- ->willReturn('es');
- $factory->expects(self::at(2))
- ->method('languageExists')
- ->with('MyApp', 'es')
- ->willReturn(false);
$this->config
->expects(self::never())
->method('setUserValue');
@@ -245,20 +221,21 @@ class FactoryTest extends TestCase {
public function testFindLanguageWithNotExistingRequestLanguageAndNotExistingStoredUserLanguageAndNotExistingDefaultAndNoAppInScope(): void {
$factory = $this->getFactory(['languageExists'], true);
$this->invokePrivate($factory, 'requestLanguage', ['de']);
- $factory->expects(self::at(0))
- ->method('languageExists')
- ->with('MyApp', 'de')
- ->willReturn(false);
+ $factory->expects($this->exactly(3))
+ ->method('languageExists')
+ ->willReturnMap([
+ ['MyApp', 'de', false],
+ ['MyApp', 'jp', false],
+ ['MyApp', 'es', false],
+ ]);
$this->config
- ->expects(self::at(0))
+ ->expects($this->exactly(3))
->method('getSystemValue')
- ->with('force_language', false)
- ->willReturn(false);
- $this->config
- ->expects(self::at(1))
- ->method('getSystemValue')
- ->with('installed', false)
- ->willReturn(true);
+ ->willReturnMap([
+ ['force_language', false, false],
+ ['installed', false, true],
+ ['default_language', false, 'es']
+ ]);
$user = $this->getMockBuilder(IUser::class)
->getMock();
$user->expects(self::once())
@@ -273,19 +250,6 @@ class FactoryTest extends TestCase {
->method('getUserValue')
->with('MyUserUid', 'core', 'lang', null)
->willReturn('jp');
- $factory->expects(self::at(1))
- ->method('languageExists')
- ->with('MyApp', 'jp')
- ->willReturn(false);
- $this->config
- ->expects(self::at(3))
- ->method('getSystemValue')
- ->with('default_language', false)
- ->willReturn('es');
- $factory->expects(self::at(2))
- ->method('languageExists')
- ->with('MyApp', 'es')
- ->willReturn(false);
$this->config
->expects(self::never())
->method('setUserValue')
@@ -298,12 +262,12 @@ class FactoryTest extends TestCase {
public function testFindLanguageWithForcedLanguage(): void {
$factory = $this->getFactory(['languageExists']);
$this->config
- ->expects(self::at(0))
+ ->expects($this->once())
->method('getSystemValue')
->with('force_language', false)
->willReturn('de');
- $factory->expects(self::once())
+ $factory->expects($this->once())
->method('languageExists')
->with('MyApp', 'de')
->willReturn(true);
diff --git a/tests/lib/LargeFileHelperGetFileSizeTest.php b/tests/lib/LargeFileHelperGetFileSizeTest.php
index 3066d48792b..6fa2555b6d0 100644
--- a/tests/lib/LargeFileHelperGetFileSizeTest.php
+++ b/tests/lib/LargeFileHelperGetFileSizeTest.php
@@ -63,7 +63,7 @@ class LargeFileHelperGetFileSizeTest extends TestCase {
if (escapeshellarg('strängé') !== '\'strängé\'') {
$this->markTestSkipped('Your escapeshell args removes accents');
}
- if (!\OC_Helper::is_function_enabled('exec')) {
+ if (!\OCP\Util::isFunctionEnabled('exec')) {
$this->markTestSkipped(
'The exec() function needs to be enabled for this test.'
);
diff --git a/tests/lib/Mail/MailerTest.php b/tests/lib/Mail/MailerTest.php
index e96cda26398..74c4f2a62ab 100644
--- a/tests/lib/Mail/MailerTest.php
+++ b/tests/lib/Mail/MailerTest.php
@@ -87,7 +87,7 @@ class MailerTest extends TestCase {
]);
$path = \OC_Helper::findBinaryPath('sendmail');
- if ($path === null) {
+ if ($path === false) {
$path = '/usr/sbin/sendmail';
}
@@ -135,7 +135,7 @@ class MailerTest extends TestCase {
$message = $this->createMock(Message::class);
$event = new BeforeMessageSent($message);
- $this->dispatcher->expects($this->at(0))
+ $this->dispatcher->expects($this->once())
->method('dispatchTyped')
->with($this->equalTo($event));
diff --git a/tests/lib/Migration/BackgroundRepairTest.php b/tests/lib/Migration/BackgroundRepairTest.php
index 4e95915e624..e14b3179b27 100644
--- a/tests/lib/Migration/BackgroundRepairTest.php
+++ b/tests/lib/Migration/BackgroundRepairTest.php
@@ -21,13 +21,16 @@
namespace Test\Migration;
-use OC\Migration\BackgroundRepair;
-use OC\NeedsUpdateException;
-use OCP\ILogger;
+use OCP\AppFramework\Utility\ITimeFactory;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\Migration\IOutput;
use OCP\Migration\IRepairStep;
-use Symfony\Component\EventDispatcher\EventDispatcherInterface;
-use Symfony\Component\EventDispatcher\GenericEvent;
+use OC\BackgroundJob\JobList;
+use OC\Migration\BackgroundRepair;
+use OC\NeedsUpdateException;
+use OC\Repair\Events\RepairStepEvent;
+use PHPUnit\Framework\MockObject\MockObject;
+use Psr\Log\LoggerInterface;
use Test\TestCase;
class TestRepairStep implements IRepairStep {
@@ -56,37 +59,43 @@ class TestRepairStep implements IRepairStep {
class BackgroundRepairTest extends TestCase {
- /** @var \OC\BackgroundJob\JobList|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var JobList|MockObject */
private $jobList;
- /** @var BackgroundRepair|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var BackgroundRepair|MockObject */
private $job;
- /** @var ILogger|\PHPUnit\Framework\MockObject\MockObject */
+ /** @var LoggerInterface|MockObject */
private $logger;
- /** @var EventDispatcherInterface|\PHPUnit\Framework\MockObject\MockObject $dispatcher */
+ /** @var IEventDispatcher|MockObject $dispatcher */
private $dispatcher;
+ /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject $dispatcher */
+ private $time;
+
protected function setUp(): void {
parent::setUp();
- $this->jobList = $this->getMockBuilder('OC\BackgroundJob\JobList')
+ $this->jobList = $this->getMockBuilder(JobList::class)
->disableOriginalConstructor()
->getMock();
- $this->logger = $this->getMockBuilder(ILogger::class)
+ $this->logger = $this->getMockBuilder(LoggerInterface::class)
->disableOriginalConstructor()
->getMock();
- $this->dispatcher = $this->createMock(EventDispatcherInterface::class);
+ $this->dispatcher = $this->createMock(IEventDispatcher::class);
+ $this->time = $this->createMock(ITimeFactory::class);
+ $this->time->method('getTime')
+ ->willReturn(999999);
$this->job = $this->getMockBuilder(BackgroundRepair::class)
- ->setConstructorArgs([$this->dispatcher])
+ ->setConstructorArgs([$this->dispatcher, $this->time, $this->logger, $this->jobList])
->setMethods(['loadApp'])
->getMock();
}
public function testNoArguments() {
$this->jobList->expects($this->once())->method('remove');
- $this->job->execute($this->jobList);
+ $this->job->start($this->jobList);
}
public function testAppUpgrading() {
@@ -96,25 +105,25 @@ class BackgroundRepairTest extends TestCase {
'app' => 'test',
'step' => 'j'
]);
- $this->job->execute($this->jobList);
+ $this->job->start($this->jobList);
}
public function testUnknownStep() {
- $this->dispatcher->expects($this->never())->method('dispatch');
+ $this->dispatcher->expects($this->never())->method('dispatchTyped');
$this->jobList->expects($this->once())->method('remove');
- $this->logger->expects($this->once())->method('logException');
+ $this->logger->expects($this->once())->method('error');
$this->job->setArgument([
'app' => 'test',
'step' => 'j'
]);
- $this->job->execute($this->jobList, $this->logger);
+ $this->job->start($this->jobList);
}
public function testWorkingStep() {
- $this->dispatcher->expects($this->once())->method('dispatch')
- ->with('\OC\Repair::step', new GenericEvent('\OC\Repair::step', ['A test repair step']));
+ $this->dispatcher->expects($this->once())->method('dispatchTyped')
+ ->with($this->equalTo(new RepairStepEvent('A test repair step')));
$this->jobList->expects($this->once())->method('remove');
@@ -122,6 +131,6 @@ class BackgroundRepairTest extends TestCase {
'app' => 'test',
'step' => '\Test\Migration\TestRepairStep'
]);
- $this->job->execute($this->jobList, $this->logger);
+ $this->job->start($this->jobList);
}
}
diff --git a/tests/lib/NavigationManagerTest.php b/tests/lib/NavigationManagerTest.php
index 39f326ef0da..8d70b1b25ae 100644
--- a/tests/lib/NavigationManagerTest.php
+++ b/tests/lib/NavigationManagerTest.php
@@ -282,6 +282,30 @@ class NavigationManagerTest extends TestCase {
'unread' => 0
]
];
+ $adminSettings = [
+ 'settings' => [
+ 'id' => 'settings',
+ 'order' => 2,
+ 'href' => '/apps/test/',
+ 'icon' => '/apps/settings/img/personal.svg',
+ 'name' => 'Personal settings',
+ 'active' => false,
+ 'type' => 'settings',
+ 'classes' => '',
+ 'unread' => 0
+ ],
+ 'admin_settings' => [
+ 'id' => 'admin_settings',
+ 'order' => 3,
+ 'href' => '/apps/test/',
+ 'icon' => '/apps/settings/img/admin.svg',
+ 'name' => 'Administration settings',
+ 'active' => false,
+ 'type' => 'settings',
+ 'classes' => '',
+ 'unread' => 0
+ ]
+ ];
return [
'minimalistic' => [
@@ -330,7 +354,7 @@ class NavigationManagerTest extends TestCase {
],
'admin' => [
array_merge(
- ['settings' => $defaults['settings']],
+ $adminSettings,
$apps,
['test' => [
'id' => 'test',
@@ -354,7 +378,7 @@ class NavigationManagerTest extends TestCase {
],
'no name' => [
array_merge(
- ['settings' => $defaults['settings']],
+ $adminSettings,
$apps,
['logout' => $defaults['logout']]
),
diff --git a/tests/lib/Notification/ManagerTest.php b/tests/lib/Notification/ManagerTest.php
index 6cdd254f001..e482ba3876b 100644
--- a/tests/lib/Notification/ManagerTest.php
+++ b/tests/lib/Notification/ManagerTest.php
@@ -248,10 +248,10 @@ class ManagerTest extends TestCase {
public function dataIsFairUseOfFreePushService(): array {
return [
- [true, 4999, true],
- [true, 5000, true],
- [false, 4999, true],
- [false, 5000, false],
+ [true, 499, true],
+ [true, 500, true],
+ [false, 499, true],
+ [false, 500, false],
];
}
diff --git a/tests/lib/OCS/ProviderTest.php b/tests/lib/OCS/ProviderTest.php
index 3a78793f91d..f66bd2eab01 100644
--- a/tests/lib/OCS/ProviderTest.php
+++ b/tests/lib/OCS/ProviderTest.php
@@ -41,24 +41,14 @@ class ProviderTest extends \Test\TestCase {
public function testBuildProviderListWithoutAnythingEnabled() {
$this->appManager
- ->expects($this->at(0))
+ ->expects($this->exactly(4))
->method('isEnabledForUser')
- ->with('files_sharing')
- ->willReturn(false);
- $this->appManager
- ->expects($this->at(1))
- ->method('isEnabledForUser')
- ->with('federation')
- ->willReturn(false);
- $this->appManager
- ->expects($this->at(2))
- ->method('isEnabledForUser')
- ->with('activity')
- ->willReturn(false);
- $this->appManager
- ->expects($this->at(3))
- ->method('isEnabledForUser')
- ->with('provisioning_api')
+ ->withConsecutive(
+ ['files_sharing'],
+ ['federation'],
+ ['activity'],
+ ['provisioning_api']
+ )
->willReturn(false);
$expected = new \OCP\AppFramework\Http\JSONResponse(
@@ -82,25 +72,20 @@ class ProviderTest extends \Test\TestCase {
public function testBuildProviderListWithSharingEnabled() {
$this->appManager
- ->expects($this->at(0))
- ->method('isEnabledForUser')
- ->with('files_sharing')
- ->willReturn(true);
- $this->appManager
- ->expects($this->at(1))
- ->method('isEnabledForUser')
- ->with('federation')
- ->willReturn(false);
- $this->appManager
- ->expects($this->at(2))
+ ->expects($this->exactly(4))
->method('isEnabledForUser')
- ->with('activity')
- ->willReturn(false);
- $this->appManager
- ->expects($this->at(3))
- ->method('isEnabledForUser')
- ->with('provisioning_api')
- ->willReturn(false);
+ ->withConsecutive(
+ ['files_sharing'],
+ ['federation'],
+ ['activity'],
+ ['provisioning_api']
+ )
+ ->willReturnOnConsecutiveCalls(
+ true,
+ false,
+ false,
+ false
+ );
$expected = new \OCP\AppFramework\Http\JSONResponse(
[
@@ -136,25 +121,20 @@ class ProviderTest extends \Test\TestCase {
public function testBuildProviderListWithFederationEnabled() {
$this->appManager
- ->expects($this->at(0))
- ->method('isEnabledForUser')
- ->with('files_sharing')
- ->willReturn(false);
- $this->appManager
- ->expects($this->at(1))
+ ->expects($this->exactly(4))
->method('isEnabledForUser')
- ->with('federation')
- ->willReturn(true);
- $this->appManager
- ->expects($this->at(2))
- ->method('isEnabledForUser')
- ->with('activity')
- ->willReturn(false);
- $this->appManager
- ->expects($this->at(3))
- ->method('isEnabledForUser')
- ->with('provisioning_api')
- ->willReturn(false);
+ ->withConsecutive(
+ ['files_sharing'],
+ ['federation'],
+ ['activity'],
+ ['provisioning_api']
+ )
+ ->willReturnOnConsecutiveCalls(
+ false,
+ true,
+ false,
+ false
+ );
$expected = new \OCP\AppFramework\Http\JSONResponse(
[
diff --git a/tests/lib/Repair/ClearFrontendCachesTest.php b/tests/lib/Repair/ClearFrontendCachesTest.php
index d89a19e70cc..09b96be7de3 100644
--- a/tests/lib/Repair/ClearFrontendCachesTest.php
+++ b/tests/lib/Repair/ClearFrontendCachesTest.php
@@ -61,7 +61,7 @@ class ClearFrontendCachesTest extends \Test\TestCase {
->with('');
$this->jsCombiner->expects($this->once())
->method('resetCache');
- $this->cacheFactory->expects($this->at(0))
+ $this->cacheFactory->expects($this->once())
->method('createDistributed')
->with('imagePath')
->willReturn($imagePathCache);
diff --git a/tests/lib/Repair/NC11/FixMountStoragesTest.php b/tests/lib/Repair/NC11/FixMountStoragesTest.php
index 9bc61865235..33c3fc1da11 100644
--- a/tests/lib/Repair/NC11/FixMountStoragesTest.php
+++ b/tests/lib/Repair/NC11/FixMountStoragesTest.php
@@ -70,18 +70,17 @@ class FixMountStoragesTest extends TestCase {
/** @var IOutput|\PHPUnit\Framework\MockObject\MockObject $output */
$output = $this->createMock(IOutput::class);
- $output->expects($this->at(0))
+ $output->expects($this->exactly(2))
->method('info')
- ->with('1 mounts updated');
+ ->withConsecutive(
+ ['1 mounts updated'],
+ ['No mounts updated']
+ );
$this->repair->run($output);
$this->assertStorage($mount1, 42);
$this->assertStorage($mount2, 23);
- $output->expects($this->at(0))
- ->method('info')
- ->with('No mounts updated');
-
$this->repair->run($output);
$this->assertStorage($mount1, 42);
$this->assertStorage($mount2, 23);
diff --git a/tests/lib/RepairStepTest.php b/tests/lib/RepairTest.php
index b1d16fdd3fd..1a2fd620e49 100644
--- a/tests/lib/RepairStepTest.php
+++ b/tests/lib/RepairTest.php
@@ -8,14 +8,19 @@
namespace Test;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\Migration\IRepairStep;
+use OC\Repair;
+use OC\Repair\Events\RepairInfoEvent;
+use OC\Repair\Events\RepairStepEvent;
+use OC\Repair\Events\RepairWarningEvent;
+use OC\Repair\Events\RepairErrorEvent;
use Psr\Log\LoggerInterface;
-use Symfony\Component\EventDispatcher\EventDispatcher;
-class RepairStepTest implements IRepairStep {
- private $warning;
+class TestRepairStep implements IRepairStep {
+ private bool $warning;
- public function __construct($warning = false) {
+ public function __construct(bool $warning = false) {
$this->warning = $warning;
}
@@ -33,28 +38,27 @@ class RepairStepTest implements IRepairStep {
}
class RepairTest extends TestCase {
- /** @var \OC\Repair */
- private $repair;
+ private Repair $repair;
/** @var string[] */
- private $outputArray;
+ private array $outputArray = [];
protected function setUp(): void {
parent::setUp();
- $dispatcher = new EventDispatcher();
+ $dispatcher = \OC::$server->get(IEventDispatcher::class);
$this->repair = new \OC\Repair([], $dispatcher, $this->createMock(LoggerInterface::class));
- $dispatcher->addListener('\OC\Repair::warning', function ($event) {
- /** @var \Symfony\Component\EventDispatcher\GenericEvent $event */
- $this->outputArray[] = 'warning: ' . $event->getArgument(0);
+ $dispatcher->addListener(RepairWarningEvent::class, function (RepairWarningEvent $event) {
+ $this->outputArray[] = 'warning: ' . $event->getMessage();
});
- $dispatcher->addListener('\OC\Repair::info', function ($event) {
- /** @var \Symfony\Component\EventDispatcher\GenericEvent $event */
- $this->outputArray[] = 'info: ' . $event->getArgument(0);
+ $dispatcher->addListener(RepairInfoEvent::class, function (RepairInfoEvent $event) {
+ $this->outputArray[] = 'info: ' . $event->getMessage();
});
- $dispatcher->addListener('\OC\Repair::step', function ($event) {
- /** @var \Symfony\Component\EventDispatcher\GenericEvent $event */
- $this->outputArray[] = 'step: ' . $event->getArgument(0);
+ $dispatcher->addListener(RepairStepEvent::class, function (RepairStepEvent $event) {
+ $this->outputArray[] = 'step: ' . $event->getStepName();
+ });
+ $dispatcher->addListener(RepairErrorEvent::class, function (RepairErrorEvent $event) {
+ $this->outputArray[] = 'error: ' . $event->getMessage();
});
}
@@ -88,7 +92,7 @@ class RepairTest extends TestCase {
$mock = $this->createMock(TestRepairStep::class);
$mock->expects($this->any())
->method('run')
- ->will($this->throwException(new \Exception()));
+ ->will($this->throwException(new \Exception('Exception text')));
$mock->expects($this->any())
->method('getName')
->willReturn('Exception Test');
@@ -103,11 +107,14 @@ class RepairTest extends TestCase {
$thrown = true;
}
- $this->assertTrue($thrown);
+ $this->assertFalse($thrown);
// jump out after exception
$this->assertEquals(
[
'step: Exception Test',
+ 'error: Exception text',
+ 'step: Test Name',
+ 'info: Simulated info',
],
$this->outputArray
);
diff --git a/tests/lib/Security/CertificateManagerTest.php b/tests/lib/Security/CertificateManagerTest.php
index b1659d1096d..fdc6b40533e 100644
--- a/tests/lib/Security/CertificateManagerTest.php
+++ b/tests/lib/Security/CertificateManagerTest.php
@@ -163,7 +163,7 @@ class CertificateManagerTest extends \Test\TestCase {
$certificateManager->expects($this->any())->method('getFilemtimeOfCaBundle')
->willReturn($CaBundleMtime);
- $certificateManager->expects($this->at(0))->method('getCertificateBundle')
+ $certificateManager->expects($this->once())->method('getCertificateBundle')
->willReturn('targetBundlePath');
$view->expects($this->any())->method('file_exists')
diff --git a/tests/lib/Security/IdentityProof/ManagerTest.php b/tests/lib/Security/IdentityProof/ManagerTest.php
index 968cfa633ca..8733d5de8be 100644
--- a/tests/lib/Security/IdentityProof/ManagerTest.php
+++ b/tests/lib/Security/IdentityProof/ManagerTest.php
@@ -117,15 +117,16 @@ class ManagerTest extends TestCase {
->with('EncryptedPrivateKey')
->willReturn('MyPrivateKey');
$folder
- ->expects($this->at(0))
+ ->expects($this->exactly(2))
->method('getFile')
- ->with('private')
- ->willReturn($privateFile);
- $folder
- ->expects($this->at(1))
- ->method('getFile')
- ->with('public')
- ->willReturn($publicFile);
+ ->withConsecutive(
+ ['private'],
+ ['public']
+ )
+ ->willReturnOnConsecutiveCalls(
+ $privateFile,
+ $publicFile
+ );
$this->appData
->expects($this->once())
->method('getFolder')
@@ -142,17 +143,12 @@ class ManagerTest extends TestCase {
->expects($this->once())
->method('getUID')
->willReturn('MyUid');
- $this->appData
- ->expects($this->at(0))
- ->method('getFolder')
- ->with('user-MyUid')
- ->willThrowException(new \Exception());
$this->manager
->expects($this->once())
->method('generateKeyPair')
->willReturn(['MyNewPublicKey', 'MyNewPrivateKey']);
$this->appData
- ->expects($this->at(1))
+ ->expects($this->once())
->method('newFolder')
->with('user-MyUid');
$folder = $this->createMock(ISimpleFolder::class);
@@ -172,20 +168,24 @@ class ManagerTest extends TestCase {
->method('putContent')
->with('MyNewPublicKey');
$folder
- ->expects($this->at(0))
- ->method('newFile')
- ->with('private')
- ->willReturn($privateFile);
- $folder
- ->expects($this->at(1))
+ ->expects($this->exactly(2))
->method('newFile')
- ->with('public')
- ->willReturn($publicFile);
+ ->withConsecutive(
+ ['private'],
+ ['public']
+ )
+ ->willReturnOnConsecutiveCalls(
+ $privateFile,
+ $publicFile
+ );
$this->appData
- ->expects($this->at(2))
+ ->expects($this->exactly(2))
->method('getFolder')
->with('user-MyUid')
- ->willReturn($folder);
+ ->willReturnOnConsecutiveCalls(
+ $this->throwException(new \Exception()),
+ $folder
+ );
$expected = new Key('MyNewPublicKey', 'MyNewPrivateKey');
diff --git a/tests/lib/Share20/ManagerTest.php b/tests/lib/Share20/ManagerTest.php
index 4e613d1cf5c..a7bb6cbcefc 100644
--- a/tests/lib/Share20/ManagerTest.php
+++ b/tests/lib/Share20/ManagerTest.php
@@ -248,22 +248,18 @@ class ManagerTest extends \Test\TestCase {
->method('delete')
->with($share);
- $this->eventDispatcher->expects($this->at(0))
+ $this->eventDispatcher->expects($this->exactly(2))
->method('dispatch')
- ->with(
- 'OCP\Share::preUnshare',
- $this->callBack(function (GenericEvent $e) use ($share) {
- return $e->getSubject() === $share;
- })
- );
- $this->eventDispatcher->expects($this->at(1))
- ->method('dispatch')
- ->with(
- 'OCP\Share::postUnshare',
- $this->callBack(function (GenericEvent $e) use ($share) {
- return $e->getSubject() === $share &&
- $e->getArgument('deletedShares') === [$share];
- })
+ ->withConsecutive(
+ ['OCP\Share::preUnshare',
+ $this->callBack(function (GenericEvent $e) use ($share) {
+ return $e->getSubject() === $share;
+ })],
+ ['OCP\Share::postUnshare',
+ $this->callBack(function (GenericEvent $e) use ($share) {
+ return $e->getSubject() === $share &&
+ $e->getArgument('deletedShares') === [$share];
+ })]
);
$manager->deleteShare($share);
@@ -296,22 +292,18 @@ class ManagerTest extends \Test\TestCase {
->method('delete')
->with($share);
- $this->eventDispatcher->expects($this->at(0))
- ->method('dispatch')
- ->with(
- 'OCP\Share::preUnshare',
- $this->callBack(function (GenericEvent $e) use ($share) {
- return $e->getSubject() === $share;
- })
- );
- $this->eventDispatcher->expects($this->at(1))
+ $this->eventDispatcher->expects($this->exactly(2))
->method('dispatch')
- ->with(
- 'OCP\Share::postUnshare',
- $this->callBack(function (GenericEvent $e) use ($share) {
- return $e->getSubject() === $share &&
- $e->getArgument('deletedShares') === [$share];
- })
+ ->withConsecutive(
+ ['OCP\Share::preUnshare',
+ $this->callBack(function (GenericEvent $e) use ($share) {
+ return $e->getSubject() === $share;
+ })],
+ ['OCP\Share::postUnshare',
+ $this->callBack(function (GenericEvent $e) use ($share) {
+ return $e->getSubject() === $share &&
+ $e->getArgument('deletedShares') === [$share];
+ })]
);
$manager->deleteShare($share);
@@ -365,22 +357,18 @@ class ManagerTest extends \Test\TestCase {
->method('delete')
->withConsecutive([$share3], [$share2], [$share1]);
- $this->eventDispatcher->expects($this->at(0))
- ->method('dispatch')
- ->with(
- 'OCP\Share::preUnshare',
- $this->callBack(function (GenericEvent $e) use ($share1) {
- return $e->getSubject() === $share1;
- })
- );
- $this->eventDispatcher->expects($this->at(1))
+ $this->eventDispatcher->expects($this->exactly(2))
->method('dispatch')
- ->with(
- 'OCP\Share::postUnshare',
- $this->callBack(function (GenericEvent $e) use ($share1, $share2, $share3) {
- return $e->getSubject() === $share1 &&
- $e->getArgument('deletedShares') === [$share3, $share2, $share1];
- })
+ ->withConsecutive(
+ ['OCP\Share::preUnshare',
+ $this->callBack(function (GenericEvent $e) use ($share1) {
+ return $e->getSubject() === $share1;
+ })],
+ ['OCP\Share::postUnshare',
+ $this->callBack(function (GenericEvent $e) use ($share1, $share2, $share3) {
+ return $e->getSubject() === $share1 &&
+ $e->getArgument('deletedShares') === [$share3, $share2, $share1];
+ })]
);
$manager->deleteShare($share1);
@@ -408,7 +396,7 @@ class ManagerTest extends \Test\TestCase {
->method('deleteFromSelf')
->with($share, $recipientId);
- $this->eventDispatcher->expects($this->at(0))
+ $this->eventDispatcher->expects($this->once())
->method('dispatch')
->with(
'OCP\Share::postUnshareFromSelf',
@@ -2330,44 +2318,39 @@ class ManagerTest extends \Test\TestCase {
return $share->setId(42);
});
- // Pre share
- $this->eventDispatcher->expects($this->at(0))
+ $this->eventDispatcher->expects($this->exactly(2))
->method('dispatch')
- ->with(
- $this->equalTo('OCP\Share::preShare'),
- $this->callback(function (GenericEvent $e) use ($path, $date) {
- /** @var IShare $share */
- $share = $e->getSubject();
-
- return $share->getShareType() === IShare::TYPE_LINK &&
- $share->getNode() === $path &&
- $share->getSharedBy() === 'sharedBy' &&
- $share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
- $share->getExpirationDate() === $date &&
- $share->getPassword() === 'hashed' &&
- $share->getToken() === 'token';
- })
- );
-
- // Post share
- $this->eventDispatcher->expects($this->at(1))
- ->method('dispatch')
- ->with(
- $this->equalTo('OCP\Share::postShare'),
- $this->callback(function (GenericEvent $e) use ($path, $date) {
- /** @var IShare $share */
- $share = $e->getSubject();
-
- return $share->getShareType() === IShare::TYPE_LINK &&
- $share->getNode() === $path &&
- $share->getSharedBy() === 'sharedBy' &&
- $share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
- $share->getExpirationDate() === $date &&
- $share->getPassword() === 'hashed' &&
- $share->getToken() === 'token' &&
- $share->getId() === '42' &&
- $share->getTarget() === '/target';
- })
+ ->withConsecutive(
+ // Pre share
+ [$this->equalTo('OCP\Share::preShare'),
+ $this->callback(function (GenericEvent $e) use ($path, $date) {
+ /** @var IShare $share */
+ $share = $e->getSubject();
+
+ return $share->getShareType() === IShare::TYPE_LINK &&
+ $share->getNode() === $path &&
+ $share->getSharedBy() === 'sharedBy' &&
+ $share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
+ $share->getExpirationDate() === $date &&
+ $share->getPassword() === 'hashed' &&
+ $share->getToken() === 'token';
+ })],
+ // Post share
+ [$this->equalTo('OCP\Share::postShare'),
+ $this->callback(function (GenericEvent $e) use ($path, $date) {
+ /** @var IShare $share */
+ $share = $e->getSubject();
+
+ return $share->getShareType() === IShare::TYPE_LINK &&
+ $share->getNode() === $path &&
+ $share->getSharedBy() === 'sharedBy' &&
+ $share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
+ $share->getExpirationDate() === $date &&
+ $share->getPassword() === 'hashed' &&
+ $share->getToken() === 'token' &&
+ $share->getId() === '42' &&
+ $share->getTarget() === '/target';
+ })]
);
/** @var IShare $share */
@@ -2442,44 +2425,37 @@ class ManagerTest extends \Test\TestCase {
return $share->setId(42);
});
- // Pre share
- $this->eventDispatcher->expects($this->at(0))
- ->method('dispatch')
- ->with(
- $this->equalTo('OCP\Share::preShare'),
- $this->callback(function (GenericEvent $e) use ($path) {
- /** @var IShare $share */
- $share = $e->getSubject();
-
- return $share->getShareType() === IShare::TYPE_EMAIL &&
- $share->getNode() === $path &&
- $share->getSharedBy() === 'sharedBy' &&
- $share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
- $share->getExpirationDate() === null &&
- $share->getPassword() === null &&
- $share->getToken() === 'token';
- })
- );
-
- // Post share
- $this->eventDispatcher->expects($this->at(1))
+ $this->eventDispatcher->expects($this->exactly(2))
->method('dispatch')
- ->with(
- $this->equalTo('OCP\Share::postShare'),
- $this->callback(function (GenericEvent $e) use ($path) {
- /** @var IShare $share */
- $share = $e->getSubject();
-
- return $share->getShareType() === IShare::TYPE_EMAIL &&
- $share->getNode() === $path &&
- $share->getSharedBy() === 'sharedBy' &&
- $share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
- $share->getExpirationDate() === null &&
- $share->getPassword() === null &&
- $share->getToken() === 'token' &&
- $share->getId() === '42' &&
- $share->getTarget() === '/target';
- })
+ ->withConsecutive(
+ [$this->equalTo('OCP\Share::preShare'),
+ $this->callback(function (GenericEvent $e) use ($path) {
+ /** @var IShare $share */
+ $share = $e->getSubject();
+
+ return $share->getShareType() === IShare::TYPE_EMAIL &&
+ $share->getNode() === $path &&
+ $share->getSharedBy() === 'sharedBy' &&
+ $share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
+ $share->getExpirationDate() === null &&
+ $share->getPassword() === null &&
+ $share->getToken() === 'token';
+ })],
+ [$this->equalTo('OCP\Share::postShare'),
+ $this->callback(function (GenericEvent $e) use ($path) {
+ /** @var IShare $share */
+ $share = $e->getSubject();
+
+ return $share->getShareType() === IShare::TYPE_EMAIL &&
+ $share->getNode() === $path &&
+ $share->getSharedBy() === 'sharedBy' &&
+ $share->getPermissions() === \OCP\Constants::PERMISSION_ALL &&
+ $share->getExpirationDate() === null &&
+ $share->getPassword() === null &&
+ $share->getToken() === 'token' &&
+ $share->getId() === '42' &&
+ $share->getTarget() === '/target';
+ })],
);
/** @var IShare $share */
@@ -2868,23 +2844,21 @@ class ManagerTest extends \Test\TestCase {
$share = $this->createMock(IShare::class);
- $factory->expects($this->at(0))
- ->method('getProviderForType')
- ->with(IShare::TYPE_LINK)
- ->willReturn($this->defaultProvider);
- $factory->expects($this->at(1))
+ $factory->expects($this->exactly(2))
->method('getProviderForType')
- ->with(IShare::TYPE_REMOTE)
+ ->withConsecutive(
+ [IShare::TYPE_LINK],
+ [IShare::TYPE_REMOTE]
+ )
->willReturn($this->defaultProvider);
- $this->defaultProvider->expects($this->at(0))
+ $this->defaultProvider->expects($this->exactly(2))
->method('getShareByToken')
->with('token')
- ->will($this->throwException(new ShareNotFound()));
- $this->defaultProvider->expects($this->at(1))
- ->method('getShareByToken')
- ->with('token')
- ->willReturn($share);
+ ->willReturnOnConsecutiveCalls(
+ $this->throwException(new ShareNotFound()),
+ $share
+ );
$ret = $manager->getShareByToken('token');
$this->assertSame($share, $ret);
@@ -2963,10 +2937,12 @@ class ManagerTest extends \Test\TestCase {
public function testGetShareByTokenPublicUploadDisabled() {
$this->config
- ->expects($this->at(0))
+ ->expects($this->exactly(2))
->method('getAppValue')
- ->with('core', 'shareapi_allow_links', 'yes')
- ->willReturn('yes');
+ ->willReturnMap([
+ ['core', 'shareapi_allow_links', 'yes', 'yes'],
+ ['core', 'shareapi_allow_public_upload', 'yes', 'no'],
+ ]);
$share = $this->manager->newShare();
$share->setShareType(IShare::TYPE_LINK)
@@ -2975,13 +2951,6 @@ class ManagerTest extends \Test\TestCase {
$folder = $this->createMock(\OC\Files\Node\Folder::class);
$share->setNode($folder);
- $this->config
- ->expects($this->at(1))
- ->method('getAppValue')
- ->willReturnMap([
- ['core', 'shareapi_allow_public_upload', 'yes', 'no'],
- ]);
-
$this->defaultProvider->expects($this->once())
->method('getShareByToken')
->willReturn('validToken')
diff --git a/tests/lib/Template/JSCombinerTest.php b/tests/lib/Template/JSCombinerTest.php
index 5c678840c63..2c98d33d543 100644
--- a/tests/lib/Template/JSCombinerTest.php
+++ b/tests/lib/Template/JSCombinerTest.php
@@ -59,7 +59,7 @@ class JSCombinerTest extends \Test\TestCase {
$this->config = $this->createMock(SystemConfig::class);
$this->cacheFactory = $this->createMock(ICacheFactory::class);
$this->depsCache = $this->createMock(ICache::class);
- $this->cacheFactory->expects($this->at(0))
+ $this->cacheFactory->expects($this->atLeastOnce())
->method('createDistributed')
->willReturn($this->depsCache);
$this->logger = $this->createMock(LoggerInterface::class);
@@ -85,15 +85,16 @@ class JSCombinerTest extends \Test\TestCase {
public function testProcessNotInstalled() {
$this->config
- ->expects($this->at(0))
+ ->expects($this->exactly(2))
->method('getValue')
- ->with('debug')
- ->willReturn(false);
- $this->config
- ->expects($this->at(1))
- ->method('getValue')
- ->with('installed')
- ->willReturn(false);
+ ->withConsecutive(
+ ['debug'],
+ ['installed']
+ )
+ ->willReturnOnConsecutiveCalls(
+ false,
+ false
+ );
$actual = $this->jsCombiner->process(__DIR__, '/data/combine.json', 'awesomeapp');
$this->assertFalse($actual);
@@ -101,15 +102,16 @@ class JSCombinerTest extends \Test\TestCase {
public function testProcessUncachedFileNoAppDataFolder() {
$this->config
- ->expects($this->at(0))
- ->method('getValue')
- ->with('debug')
- ->willReturn(false);
- $this->config
- ->expects($this->at(1))
+ ->expects($this->exactly(2))
->method('getValue')
- ->with('installed')
- ->willReturn(true);
+ ->withConsecutive(
+ ['debug'],
+ ['installed']
+ )
+ ->willReturnOnConsecutiveCalls(
+ false,
+ true
+ );
$folder = $this->createMock(ISimpleFolder::class);
$this->appData->expects($this->once())->method('getFolder')->with('awesomeapp')->willThrowException(new NotFoundException());
$this->appData->expects($this->once())->method('newFolder')->with('awesomeapp')->willReturn($folder);
@@ -140,15 +142,16 @@ class JSCombinerTest extends \Test\TestCase {
public function testProcessUncachedFile() {
$this->config
- ->expects($this->at(0))
- ->method('getValue')
- ->with('debug')
- ->willReturn(false);
- $this->config
- ->expects($this->at(1))
+ ->expects($this->exactly(2))
->method('getValue')
- ->with('installed')
- ->willReturn(true);
+ ->withConsecutive(
+ ['debug'],
+ ['installed']
+ )
+ ->willReturnOnConsecutiveCalls(
+ false,
+ true
+ );
$folder = $this->createMock(ISimpleFolder::class);
$this->appData->expects($this->once())->method('getFolder')->with('awesomeapp')->willReturn($folder);
$file = $this->createMock(ISimpleFile::class);
@@ -177,15 +180,16 @@ class JSCombinerTest extends \Test\TestCase {
public function testProcessCachedFile() {
$this->config
- ->expects($this->at(0))
+ ->expects($this->exactly(2))
->method('getValue')
- ->with('debug')
- ->willReturn(false);
- $this->config
- ->expects($this->at(1))
- ->method('getValue')
- ->with('installed')
- ->willReturn(true);
+ ->withConsecutive(
+ ['debug'],
+ ['installed']
+ )
+ ->willReturnOnConsecutiveCalls(
+ false,
+ true
+ );
$folder = $this->createMock(ISimpleFolder::class);
$this->appData->expects($this->once())->method('getFolder')->with('awesomeapp')->willReturn($folder);
$file = $this->createMock(ISimpleFile::class);
@@ -217,15 +221,16 @@ class JSCombinerTest extends \Test\TestCase {
public function testProcessCachedFileMemcache() {
$this->config
- ->expects($this->at(0))
- ->method('getValue')
- ->with('debug')
- ->willReturn(false);
- $this->config
- ->expects($this->at(1))
+ ->expects($this->exactly(2))
->method('getValue')
- ->with('installed')
- ->willReturn(true);
+ ->withConsecutive(
+ ['debug'],
+ ['installed']
+ )
+ ->willReturnOnConsecutiveCalls(
+ false,
+ true
+ );
$folder = $this->createMock(ISimpleFolder::class);
$this->appData->expects($this->once())
->method('getFolder')
@@ -401,13 +406,23 @@ class JSCombinerTest extends \Test\TestCase {
$folder = $this->createMock(ISimpleFolder::class);
$file = $this->createMock(ISimpleFile::class);
$depsFile = $this->createMock(ISimpleFile::class);
+ $gzFile = $this->createMock(ISimpleFile::class);
$path = __DIR__ . '/data/';
- $folder->expects($this->at(0))->method('getFile')->with($fileName)->willReturn($file);
- $folder->expects($this->at(1))->method('getFile')->with($fileName . '.deps')->willReturn($depsFile);
+ $folder->expects($this->exactly(3))
+ ->method('getFile')
+ ->withConsecutive(
+ [$fileName],
+ [$fileName . '.deps'],
+ [$fileName . '.gzip']
+ )->willReturnOnConsecutiveCalls(
+ $file,
+ $depsFile,
+ $gzFile
+ );
- $file->expects($this->at(0))
+ $file->expects($this->once())
->method('putContent')
->with('var a = \'hello\';
@@ -417,7 +432,7 @@ var b = \'world\';
');
$depsFile
- ->expects($this->at(0))
+ ->expects($this->once())
->method('putContent')
->with($this->callback(
function ($content) {
@@ -455,7 +470,7 @@ var b = \'world\';
}
);
- $file->expects($this->at(0))
+ $file->expects($this->once())
->method('putContent')
->with('var a = \'hello\';
@@ -464,13 +479,13 @@ var b = \'world\';
');
- $depsFile->expects($this->at(0))->method('putContent')->with($this->callback(
+ $depsFile->expects($this->once())->method('putContent')->with($this->callback(
function ($content) {
$deps = json_decode($content, true);
return array_key_exists(__DIR__ . '/data//1.js', $deps)
&& array_key_exists(__DIR__ . '/data//2.js', $deps);
}));
- $gzFile->expects($this->at(0))->method('putContent')->with($this->callback(
+ $gzFile->expects($this->once())->method('putContent')->with($this->callback(
function ($content) {
return gzdecode($content) === 'var a = \'hello\';
@@ -550,9 +565,8 @@ var b = \'world\';
$this->cacheFactory->expects($this->once())
->method('createDistributed')
->willReturn($cache);
- $cache->expects($this->once())
- ->method('clear')
- ->with('');
+ $cache->expects($this->never())
+ ->method('clear');
$this->appData->expects($this->once())
->method('getDirectoryListing')
->willReturn([$folder]);
diff --git a/tests/lib/Updater/VersionCheckTest.php b/tests/lib/Updater/VersionCheckTest.php
index f4216ddb0a3..cc2b0a369aa 100644
--- a/tests/lib/Updater/VersionCheckTest.php
+++ b/tests/lib/Updater/VersionCheckTest.php
@@ -66,20 +66,21 @@ class VersionCheckTest extends \Test\TestCase {
];
$this->config
- ->expects($this->at(0))
+ ->expects($this->once())
->method('getSystemValueBool')
->with('has_internet_connection', true)
->willReturn(true);
$this->config
- ->expects($this->at(1))
- ->method('getAppValue')
- ->with('core', 'lastupdatedat')
- ->willReturn(time());
- $this->config
- ->expects($this->at(2))
+ ->expects($this->exactly(2))
->method('getAppValue')
- ->with('core', 'lastupdateResult')
- ->willReturn(json_encode($expectedResult));
+ ->withConsecutive(
+ ['core', 'lastupdatedat'],
+ ['core', 'lastupdateResult']
+ )
+ ->willReturnOnConsecutiveCalls(
+ time(),
+ json_encode($expectedResult)
+ );
$this->assertSame($expectedResult, $this->updater->check());
}
@@ -96,38 +97,37 @@ class VersionCheckTest extends \Test\TestCase {
];
$this->config
- ->expects($this->at(0))
+ ->expects($this->once())
->method('getSystemValueBool')
->with('has_internet_connection', true)
->willReturn(true);
$this->config
- ->expects($this->at(1))
+ ->expects($this->exactly(4))
->method('getAppValue')
- ->with('core', 'lastupdatedat')
- ->willReturn(0);
+ ->withConsecutive(
+ ['core', 'lastupdatedat'],
+ ['core', 'installedat'],
+ ['core', 'installedat'],
+ ['core', 'lastupdatedat'],
+ )
+ ->willReturnOnConsecutiveCalls(
+ 0,
+ 'installedat',
+ 'installedat',
+ 'lastupdatedat'
+ );
$this->config
- ->expects($this->at(2))
+ ->expects($this->once())
->method('getSystemValue')
->with('updater.server.url', 'https://updates.nextcloud.com/updater_server/')
->willReturnArgument(1);
$this->config
- ->expects($this->at(3))
- ->method('setAppValue')
- ->with('core', 'lastupdatedat', $this->isType('integer'));
- $this->config
- ->expects($this->at(5))
- ->method('getAppValue')
- ->with('core', 'installedat')
- ->willReturn('installedat');
- $this->config
- ->expects($this->at(6))
- ->method('getAppValue')
- ->with('core', 'lastupdatedat')
- ->willReturn('lastupdatedat');
- $this->config
- ->expects($this->at(7))
+ ->expects($this->exactly(2))
->method('setAppValue')
- ->with('core', 'lastupdateResult', json_encode($expectedResult));
+ ->withConsecutive(
+ ['core', 'lastupdatedat', $this->isType('integer')],
+ ['core', 'lastupdateResult', json_encode($expectedResult)]
+ );
$updateXml = '<?xml version="1.0"?>
<owncloud>
@@ -149,38 +149,37 @@ class VersionCheckTest extends \Test\TestCase {
public function testCheckWithInvalidXml() {
$this->config
- ->expects($this->at(0))
+ ->expects($this->once())
->method('getSystemValueBool')
->with('has_internet_connection', true)
->willReturn(true);
$this->config
- ->expects($this->at(1))
+ ->expects($this->exactly(4))
->method('getAppValue')
- ->with('core', 'lastupdatedat')
- ->willReturn(0);
+ ->withConsecutive(
+ ['core', 'lastupdatedat'],
+ ['core', 'installedat'],
+ ['core', 'installedat'],
+ ['core', 'lastupdatedat'],
+ )
+ ->willReturnOnConsecutiveCalls(
+ 0,
+ 'installedat',
+ 'installedat',
+ 'lastupdatedat'
+ );
$this->config
- ->expects($this->at(2))
+ ->expects($this->once())
->method('getSystemValue')
->with('updater.server.url', 'https://updates.nextcloud.com/updater_server/')
->willReturnArgument(1);
$this->config
- ->expects($this->at(3))
- ->method('setAppValue')
- ->with('core', 'lastupdatedat', $this->isType('integer'));
- $this->config
- ->expects($this->at(5))
- ->method('getAppValue')
- ->with('core', 'installedat')
- ->willReturn('installedat');
- $this->config
- ->expects($this->at(6))
- ->method('getAppValue')
- ->with('core', 'lastupdatedat')
- ->willReturn('lastupdatedat');
- $this->config
- ->expects($this->at(7))
+ ->expects($this->exactly(2))
->method('setAppValue')
- ->with('core', 'lastupdateResult', '[]');
+ ->withConsecutive(
+ ['core', 'lastupdatedat', $this->isType('integer')],
+ ['core', 'lastupdateResult', '[]']
+ );
$updateXml = 'Invalid XML Response!';
$this->updater
@@ -204,34 +203,37 @@ class VersionCheckTest extends \Test\TestCase {
];
$this->config
- ->expects($this->at(0))
+ ->expects($this->once())
->method('getSystemValueBool')
->with('has_internet_connection', true)
->willReturn(true);
$this->config
- ->expects($this->at(1))
+ ->expects($this->exactly(4))
->method('getAppValue')
- ->with('core', 'lastupdatedat')
- ->willReturn(0);
+ ->withConsecutive(
+ ['core', 'lastupdatedat'],
+ ['core', 'installedat'],
+ ['core', 'installedat'],
+ ['core', 'lastupdatedat'],
+ )
+ ->willReturnOnConsecutiveCalls(
+ 0,
+ 'installedat',
+ 'installedat',
+ 'lastupdatedat'
+ );
$this->config
- ->expects($this->at(2))
+ ->expects($this->once())
->method('getSystemValue')
->with('updater.server.url', 'https://updates.nextcloud.com/updater_server/')
->willReturnArgument(1);
$this->config
- ->expects($this->at(3))
+ ->expects($this->exactly(2))
->method('setAppValue')
- ->with('core', 'lastupdatedat', $this->isType('integer'));
- $this->config
- ->expects($this->at(5))
- ->method('getAppValue')
- ->with('core', 'installedat')
- ->willReturn('installedat');
- $this->config
- ->expects($this->at(6))
- ->method('getAppValue')
- ->with('core', 'lastupdatedat')
- ->willReturn('lastupdatedat');
+ ->withConsecutive(
+ ['core', 'lastupdatedat', $this->isType('integer')],
+ ['core', 'lastupdateResult', $this->isType('string')]
+ );
$updateXml = '<?xml version="1.0"?>
<owncloud>
@@ -254,38 +256,37 @@ class VersionCheckTest extends \Test\TestCase {
$expectedResult = [];
$this->config
- ->expects($this->at(0))
+ ->expects($this->once())
->method('getSystemValueBool')
->with('has_internet_connection', true)
->willReturn(true);
$this->config
- ->expects($this->at(1))
+ ->expects($this->exactly(4))
->method('getAppValue')
- ->with('core', 'lastupdatedat')
- ->willReturn(0);
+ ->withConsecutive(
+ ['core', 'lastupdatedat'],
+ ['core', 'installedat'],
+ ['core', 'installedat'],
+ ['core', 'lastupdatedat'],
+ )
+ ->willReturnOnConsecutiveCalls(
+ 0,
+ 'installedat',
+ 'installedat',
+ 'lastupdatedat'
+ );
$this->config
- ->expects($this->at(2))
+ ->expects($this->once())
->method('getSystemValue')
->with('updater.server.url', 'https://updates.nextcloud.com/updater_server/')
->willReturnArgument(1);
$this->config
- ->expects($this->at(3))
- ->method('setAppValue')
- ->with('core', 'lastupdatedat', $this->isType('integer'));
- $this->config
- ->expects($this->at(5))
- ->method('getAppValue')
- ->with('core', 'installedat')
- ->willReturn('installedat');
- $this->config
- ->expects($this->at(6))
- ->method('getAppValue')
- ->with('core', 'lastupdatedat')
- ->willReturn('lastupdatedat');
- $this->config
- ->expects($this->at(7))
+ ->expects($this->exactly(2))
->method('setAppValue')
- ->with('core', 'lastupdateResult', json_encode($expectedResult));
+ ->withConsecutive(
+ ['core', 'lastupdatedat', $this->isType('integer')],
+ ['core', 'lastupdateResult', json_encode($expectedResult)]
+ );
$updateXml = '';
$this->updater
@@ -309,34 +310,37 @@ class VersionCheckTest extends \Test\TestCase {
];
$this->config
- ->expects($this->at(0))
+ ->expects($this->once())
->method('getSystemValueBool')
->with('has_internet_connection', true)
->willReturn(true);
$this->config
- ->expects($this->at(1))
+ ->expects($this->exactly(4))
->method('getAppValue')
- ->with('core', 'lastupdatedat')
- ->willReturn(0);
+ ->withConsecutive(
+ ['core', 'lastupdatedat'],
+ ['core', 'installedat'],
+ ['core', 'installedat'],
+ ['core', 'lastupdatedat'],
+ )
+ ->willReturnOnConsecutiveCalls(
+ 0,
+ 'installedat',
+ 'installedat',
+ 'lastupdatedat'
+ );
$this->config
- ->expects($this->at(2))
+ ->expects($this->once())
->method('getSystemValue')
->with('updater.server.url', 'https://updates.nextcloud.com/updater_server/')
->willReturnArgument(1);
$this->config
- ->expects($this->at(3))
+ ->expects($this->exactly(2))
->method('setAppValue')
- ->with('core', 'lastupdatedat', $this->isType('integer'));
- $this->config
- ->expects($this->at(5))
- ->method('getAppValue')
- ->with('core', 'installedat')
- ->willReturn('installedat');
- $this->config
- ->expects($this->at(6))
- ->method('getAppValue')
- ->with('core', 'lastupdatedat')
- ->willReturn('lastupdatedat');
+ ->withConsecutive(
+ ['core', 'lastupdatedat', $this->isType('integer')],
+ ['core', 'lastupdateResult', $this->isType('string')]
+ );
// missing autoupdater element should still not fail
$updateXml = '<?xml version="1.0"?>
@@ -357,7 +361,7 @@ class VersionCheckTest extends \Test\TestCase {
public function testNoInternet() {
$this->config
- ->expects($this->at(0))
+ ->expects($this->once())
->method('getSystemValueBool')
->with('has_internet_connection', true)
->willReturn(false);
diff --git a/tests/lib/User/ManagerTest.php b/tests/lib/User/ManagerTest.php
index cef578e9555..ec8d931426c 100644
--- a/tests/lib/User/ManagerTest.php
+++ b/tests/lib/User/ManagerTest.php
@@ -693,24 +693,24 @@ class ManagerTest extends TestCase {
->disableOriginalConstructor()
->getMock();
$config
- ->expects($this->at(0))
+ ->expects($this->once())
->method('getUsersForUserValueCaseInsensitive')
->with('settings', 'email', 'test@example.com')
->willReturn(['uid1', 'uid99', 'uid2']);
$backend = $this->createMock(\Test\Util\User\Dummy::class);
- $backend->expects($this->at(0))
- ->method('userExists')
- ->with($this->equalTo('uid1'))
- ->willReturn(true);
- $backend->expects($this->at(1))
+ $backend->expects($this->exactly(3))
->method('userExists')
- ->with($this->equalTo('uid99'))
- ->willReturn(false);
- $backend->expects($this->at(2))
- ->method('userExists')
- ->with($this->equalTo('uid2'))
- ->willReturn(true);
+ ->withConsecutive(
+ [$this->equalTo('uid1')],
+ [$this->equalTo('uid99')],
+ [$this->equalTo('uid2')]
+ )
+ ->willReturnOnConsecutiveCalls(
+ true,
+ false,
+ true
+ );
$manager = new \OC\User\Manager($config, $this->oldDispatcher, $this->cacheFactory, $this->eventDispatcher);
$manager->registerBackend($backend);