summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2017-01-19 11:02:56 +0100
committerJoas Schilling <coding@schilljs.com>2017-01-19 11:02:56 +0100
commit80b800128d93e26ba7b06279ed6ef6f3a2f00651 (patch)
tree0cb7def80303b0f46b320db2a265acd394aca26b /tests
parent17a7eaabcd734c1f989ffc191152d0957195f5d0 (diff)
downloadnextcloud-server-80b800128d93e26ba7b06279ed6ef6f3a2f00651.tar.gz
nextcloud-server-80b800128d93e26ba7b06279ed6ef6f3a2f00651.zip
Fix the manager tests
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/Settings/ManagerTest.php74
1 files changed, 44 insertions, 30 deletions
diff --git a/tests/lib/Settings/ManagerTest.php b/tests/lib/Settings/ManagerTest.php
index b91331a1d30..70401abb652 100644
--- a/tests/lib/Settings/ManagerTest.php
+++ b/tests/lib/Settings/ManagerTest.php
@@ -32,6 +32,7 @@ use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\ILogger;
+use OCP\IURLGenerator;
use OCP\IUserManager;
use OCP\Lock\ILockingProvider;
use Test\TestCase;
@@ -55,18 +56,21 @@ class ManagerTest extends TestCase {
private $lockingProvider;
/** @var Mapper|\PHPUnit_Framework_MockObject_MockObject */
private $mapper;
+ /** @var IURLGenerator|\PHPUnit_Framework_MockObject_MockObject */
+ private $url;
public function setUp() {
parent::setUp();
- $this->logger = $this->getMockBuilder('\OCP\ILogger')->getMock();
- $this->dbConnection = $this->getMockBuilder('\OCP\IDBConnection')->getMock();
- $this->l10n = $this->getMockBuilder('\OCP\IL10N')->getMock();
- $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock();
- $this->encryptionManager = $this->getMockBuilder('\OCP\Encryption\IManager')->getMock();
- $this->userManager = $this->getMockBuilder('\OCP\IUserManager')->getMock();
- $this->lockingProvider = $this->getMockBuilder('\OCP\Lock\ILockingProvider')->getMock();
- $this->mapper = $this->getMockBuilder(Mapper::class)->disableOriginalConstructor()->getMock();
+ $this->logger = $this->createMock(ILogger::class);
+ $this->dbConnection = $this->createMock(IDBConnection::class);
+ $this->l10n = $this->createMock(IL10N::class);
+ $this->config = $this->createMock(IConfig::class);
+ $this->encryptionManager = $this->createMock(IManager::class);
+ $this->userManager = $this->createMock(IUserManager::class);
+ $this->lockingProvider = $this->createMock(ILockingProvider::class);
+ $this->mapper = $this->createMock(Mapper::class);
+ $this->url = $this->createMock(IURLGenerator::class);
$this->manager = new Manager(
$this->logger,
@@ -76,7 +80,8 @@ class ManagerTest extends TestCase {
$this->encryptionManager,
$this->userManager,
$this->lockingProvider,
- $this->mapper
+ $this->mapper,
+ $this->url
);
}
@@ -133,22 +138,26 @@ class ManagerTest extends TestCase {
$this->mapper->expects($this->once())
->method('getAdminSectionsFromDB')
->will($this->returnValue([
- ['class' => '\OCA\LogReader\Settings\Section', 'priority' => 90]
+ ['class' => \OCA\WorkflowEngine\Settings\Section::class, 'priority' => 90]
]));
- $this->mapper->expects($this->once())
- ->method('getAdminSettingsCountFromDB')
- ->will($this->returnValue([
- 'logging' => 1
- ]));
+ $this->url->expects($this->exactly(5))
+ ->method('imagePath')
+ ->willReturnMap([
+ ['settings', 'admin.svg', '1'],
+ ['core', 'actions/share.svg', '2'],
+ ['core', 'actions/password.svg', '3'],
+ ['core', 'actions/settings-dark.svg', '4'],
+ ['settings', 'help.svg', '5'],
+ ]);
$this->assertEquals([
- 0 => [new Section('server', 'Server settings', 0)],
- 5 => [new Section('sharing', 'Sharing', 0)],
- 45 => [new Section('encryption', 'Encryption', 0)],
- 90 => [new \OCA\LogReader\Settings\Section(\OC::$server->getL10N('logreader'))],
- 98 => [new Section('additional', 'Additional settings', 0)],
- 99 => [new Section('tips-tricks', 'Tips & tricks', 0)],
+ 0 => [new Section('server', 'Server settings', 0, '1')],
+ 5 => [new Section('sharing', 'Sharing', 0, '2')],
+ 45 => [new Section('encryption', 'Encryption', 0, '3')],
+ 90 => [\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());
}
@@ -161,19 +170,24 @@ class ManagerTest extends TestCase {
$this->mapper->expects($this->once())
->method('getAdminSectionsFromDB')
->will($this->returnValue([
- ['class' => '\OCA\LogReader\Settings\Section', 'priority' => 90]
]));
- $this->mapper->expects($this->once())
- ->method('getAdminSettingsCountFromDB')
- ->will($this->returnValue([]));
+ $this->url->expects($this->exactly(5))
+ ->method('imagePath')
+ ->willReturnMap([
+ ['settings', 'admin.svg', '1'],
+ ['core', 'actions/share.svg', '2'],
+ ['core', 'actions/password.svg', '3'],
+ ['core', 'actions/settings-dark.svg', '4'],
+ ['settings', 'help.svg', '5'],
+ ]);
$this->assertEquals([
- 0 => [new Section('server', 'Server settings', 0)],
- 5 => [new Section('sharing', 'Sharing', 0)],
- 45 => [new Section('encryption', 'Encryption', 0)],
- 98 => [new Section('additional', 'Additional settings', 0)],
- 99 => [new Section('tips-tricks', 'Tips & tricks', 0)],
+ 0 => [new Section('server', 'Server settings', 0, '1')],
+ 5 => [new Section('sharing', 'Sharing', 0, '2')],
+ 45 => [new Section('encryption', 'Encryption', 0, '3')],
+ 98 => [new Section('additional', 'Additional settings', 0, '4')],
+ 99 => [new Section('tips-tricks', 'Tips & tricks', 0, '5')],
], $this->manager->getAdminSections());
}