summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2022-06-10 15:32:21 +0200
committerGitHub <noreply@github.com>2022-06-10 15:32:21 +0200
commitce7b7226da49abc08951955c56eab5426ca5b3a1 (patch)
treeb0bc59605e6d6637c91c90fb705649554126323e /tests
parentb2cd92cc148ca9dcb4706faab9c31da1cf54d828 (diff)
parentc49b255b018b15e8445cd85456ef096640b5c4ea (diff)
downloadnextcloud-server-ce7b7226da49abc08951955c56eab5426ca5b3a1.tar.gz
nextcloud-server-ce7b7226da49abc08951955c56eab5426ca5b3a1.zip
Merge pull request #32658 from nextcloud/backport/32655/stable23
[stable23] Handle non existing settings again
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Settings/ManagerTest.php42
1 files changed, 30 insertions, 12 deletions
diff --git a/tests/lib/Settings/ManagerTest.php b/tests/lib/Settings/ManagerTest.php
index 96711e75cab..29ae33c3c93 100644
--- a/tests/lib/Settings/ManagerTest.php
+++ b/tests/lib/Settings/ManagerTest.php
@@ -21,7 +21,7 @@
*
*/
-namespace OCA\Settings\Tests\AppInfo;
+namespace OC\Settings\Tests\AppInfo;
use OC\Settings\AuthorizedGroupMapper;
use OC\Settings\Manager;
@@ -82,16 +82,26 @@ class ManagerTest extends TestCase {
public function testGetAdminSections() {
$this->manager->registerSection('admin', \OCA\WorkflowEngine\Settings\Section::class);
+ $section = \OC::$server->query(\OCA\WorkflowEngine\Settings\Section::class);
+ $this->container->method('get')
+ ->with(\OCA\WorkflowEngine\Settings\Section::class)
+ ->willReturn($section);
+
$this->assertEquals([
- 55 => [\OC::$server->query(\OCA\WorkflowEngine\Settings\Section::class)],
+ 55 => [$section],
], $this->manager->getAdminSections());
}
public function testGetPersonalSections() {
$this->manager->registerSection('personal', \OCA\WorkflowEngine\Settings\Section::class);
+ $section = \OC::$server->query(\OCA\WorkflowEngine\Settings\Section::class);
+ $this->container->method('get')
+ ->with(\OCA\WorkflowEngine\Settings\Section::class)
+ ->willReturn($section);
+
$this->assertEquals([
- 55 => [\OC::$server->query(\OCA\WorkflowEngine\Settings\Section::class)],
+ 55 => [$section],
], $this->manager->getPersonalSections());
}
@@ -181,14 +191,16 @@ class ManagerTest extends TestCase {
$this->manager->registerSetting('personal', 'section1');
$this->manager->registerSetting('personal', 'section2');
- $this->container->expects($this->at(0))
+ $this->container->expects($this->exactly(2))
->method('get')
- ->with('section1')
- ->willReturn($section);
- $this->container->expects($this->at(1))
- ->method('get')
- ->with('section2')
- ->willReturn($section2);
+ ->withConsecutive(
+ ['section1'],
+ ['section2']
+ )
+ ->willReturnMap([
+ ['section1', $section],
+ ['section2', $section2],
+ ]);
$settings = $this->manager->getPersonalSettings('security');
@@ -212,12 +224,18 @@ class ManagerTest extends TestCase {
$this->manager->registerSection('personal', \OCA\WorkflowEngine\Settings\Section::class);
$this->manager->registerSection('admin', \OCA\WorkflowEngine\Settings\Section::class);
+
+ $section = \OC::$server->query(\OCA\WorkflowEngine\Settings\Section::class);
+ $this->container->method('get')
+ ->with(\OCA\WorkflowEngine\Settings\Section::class)
+ ->willReturn($section);
+
$this->assertEquals([
- 55 => [\OC::$server->query(\OCA\WorkflowEngine\Settings\Section::class)],
+ 55 => [$section],
], $this->manager->getPersonalSections());
$this->assertEquals([
- 55 => [\OC::$server->query(\OCA\WorkflowEngine\Settings\Section::class)],
+ 55 => [$section],
], $this->manager->getAdminSections());
}
}