Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix unit tests
Signed-off-by: Joas Schilling <[email protected]>
  • Loading branch information
nickvergessen committed May 31, 2022
commit 26050a48f0e84dd31287bd78a88ef4c90c915aed
42 changes: 30 additions & 12 deletions tests/lib/Settings/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
*/

namespace OCA\Settings\Tests\AppInfo;
namespace OC\Settings\Tests\AppInfo;

use OC\Settings\AuthorizedGroupMapper;
use OC\Settings\Manager;
Expand Down Expand Up @@ -82,16 +82,26 @@ protected function setUp(): void {
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());
}

Expand Down Expand Up @@ -181,14 +191,16 @@ public function testGetPersonalSettings() {
$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');

Expand All @@ -212,12 +224,18 @@ public function testSameSectionAsPersonalAndAdmin() {
$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());
}
}