diff options
Diffstat (limited to 'tests/lib/Settings/ManagerTest.php')
-rw-r--r-- | tests/lib/Settings/ManagerTest.php | 106 |
1 files changed, 5 insertions, 101 deletions
diff --git a/tests/lib/Settings/ManagerTest.php b/tests/lib/Settings/ManagerTest.php index be5aad2e414..577abc7915c 100644 --- a/tests/lib/Settings/ManagerTest.php +++ b/tests/lib/Settings/ManagerTest.php @@ -62,8 +62,6 @@ class ManagerTest extends TestCase { private $lockingProvider; /** @var IRequest|\PHPUnit_Framework_MockObject_MockObject */ private $request; - /** @var Mapper|\PHPUnit_Framework_MockObject_MockObject */ - private $mapper; /** @var IURLGenerator|\PHPUnit_Framework_MockObject_MockObject */ private $url; /** @var AccountManager|\PHPUnit_Framework_MockObject_MockObject */ @@ -72,8 +70,6 @@ class ManagerTest extends TestCase { private $groupManager; /** @var IFactory|\PHPUnit_Framework_MockObject_MockObject */ private $l10nFactory; - /** @var \OC_Defaults|\PHPUnit_Framework_MockObject_MockObject */ - private $defaults; /** @var IAppManager */ private $appManager; @@ -88,12 +84,10 @@ class ManagerTest extends TestCase { $this->userManager = $this->createMock(IUserManager::class); $this->lockingProvider = $this->createMock(ILockingProvider::class); $this->request = $this->createMock(IRequest::class); - $this->mapper = $this->createMock(Mapper::class); $this->url = $this->createMock(IURLGenerator::class); $this->accountManager = $this->createMock(AccountManager::class); $this->groupManager = $this->createMock(IGroupManager::class); $this->l10nFactory = $this->createMock(IFactory::class); - $this->defaults = $this->createMock(\OC_Defaults::class); $this->appManager = $this->createMock(IAppManager::class); $this->manager = new Manager( @@ -105,90 +99,21 @@ class ManagerTest extends TestCase { $this->userManager, $this->lockingProvider, $this->request, - $this->mapper, $this->url, $this->accountManager, $this->groupManager, $this->l10nFactory, - $this->defaults, $this->appManager ); } - public function settingsTypeProvider() { - return [ - ['admin', 'admin_settings'], - ['personal', 'personal_settings'], - ]; - } - - /** - * @dataProvider settingsTypeProvider - * @param string $type - * @param string $table - */ - public function testSetupSettingsUpdate($type, $table) { - $className = 'OCA\Files\Settings\Admin'; - - $this->mapper->expects($this->any()) - ->method('has') - ->with($table, $className) - ->will($this->returnValue(true)); - - $this->mapper->expects($this->once()) - ->method('update') - ->with($table, - 'class', - $className, [ - 'section' => 'additional', - 'priority' => 5 - ]); - $this->mapper->expects($this->never()) - ->method('add'); - - $this->manager->setupSettings([ - $type => [$className], - ]); - } - - /** - * @dataProvider settingsTypeProvider - * @param string $type - * @param string $table - */ - public function testSetupSettingsAdd($type, $table) { - $this->mapper->expects($this->any()) - ->method('has') - ->with($table, 'OCA\Files\Settings\Admin') - ->will($this->returnValue(false)); - - $this->mapper->expects($this->once()) - ->method('add') - ->with($table, [ - 'class' => 'OCA\Files\Settings\Admin', - 'section' => 'additional', - 'priority' => 5 - ]); - - $this->mapper->expects($this->never()) - ->method('update'); - - $this->manager->setupSettings([ - $type => ['OCA\Files\Settings\Admin'], - ]); - } - public function testGetAdminSections() { $this->l10n ->expects($this->any()) ->method('t') ->will($this->returnArgument(0)); - $this->mapper->expects($this->once()) - ->method('getAdminSectionsFromDB') - ->will($this->returnValue([ - ['class' => \OCA\WorkflowEngine\Settings\Section::class, 'priority' => 90] - ])); + $this->manager->registerSection('admin', \OCA\WorkflowEngine\Settings\Section::class); $this->url->expects($this->exactly(6)) ->method('imagePath') @@ -205,7 +130,7 @@ class ManagerTest extends TestCase { 5 => [new Section('sharing', 'Sharing', 0, '2')], 10 => [new Section('security', 'Security', 0, '3')], 45 => [new Section('encryption', 'Encryption', 0, '3')], - 90 => [\OC::$server->query(\OCA\WorkflowEngine\Settings\Section::class)], + 55 => [\OC::$server->query(\OCA\WorkflowEngine\Settings\Section::class)], 98 => [new Section('additional', 'Additional settings', 0, '4')], 99 => [new Section('tips-tricks', 'Tips & tricks', 0, '5')], ], $this->manager->getAdminSections()); @@ -217,11 +142,7 @@ class ManagerTest extends TestCase { ->method('t') ->will($this->returnArgument(0)); - $this->mapper->expects($this->once()) - ->method('getPersonalSectionsFromDB') - ->will($this->returnValue([ - ['class' => \OCA\WorkflowEngine\Settings\Section::class, 'priority' => 90] - ])); + $this->manager->registerSection('personal', \OCA\WorkflowEngine\Settings\Section::class); $this->url->expects($this->exactly(3)) ->method('imagePath') @@ -231,11 +152,11 @@ class ManagerTest extends TestCase { ['settings', 'change.svg', '3'], ]); - $this->assertArraySubset([ + $this->assertEquals([ 0 => [new Section('personal-info', 'Personal info', 0, '1')], 5 => [new Section('security', 'Security', 0, '2')], 15 => [new Section('sync-clients', 'Sync clients', 0, '3')], - 90 => [\OC::$server->query(\OCA\WorkflowEngine\Settings\Section::class)], + 55 => [\OC::$server->query(\OCA\WorkflowEngine\Settings\Section::class)], ], $this->manager->getPersonalSections()); } @@ -245,11 +166,6 @@ class ManagerTest extends TestCase { ->method('t') ->will($this->returnArgument(0)); - $this->mapper->expects($this->once()) - ->method('getAdminSectionsFromDB') - ->will($this->returnValue([ - ])); - $this->url->expects($this->exactly(6)) ->method('imagePath') ->willReturnMap([ @@ -276,10 +192,6 @@ class ManagerTest extends TestCase { ->method('t') ->will($this->returnArgument(0)); - $this->mapper->expects($this->once()) - ->method('getPersonalSectionsFromDB') - ->will($this->returnValue([])); - $this->url->expects($this->exactly(3)) ->method('imagePath') ->willReturnMap([ @@ -296,20 +208,12 @@ class ManagerTest extends TestCase { } public function testGetAdminSettings() { - $this->mapper->expects($this->any()) - ->method('getAdminSettingsFromDB') - ->will($this->returnValue([])); - $this->assertEquals([ 0 => [new Sharing($this->config)], ], $this->manager->getAdminSettings('sharing')); } public function testGetPersonalSettings() { - $this->mapper->expects($this->any()) - ->method('getPersonalSettingsFromDB') - ->will($this->returnValue([])); - $this->assertEquals([ 10 => [new Security()], ], $this->manager->getPersonalSettings('security')); |