Skip to content
Prev Previous commit
Next Next commit
Fix unit tests
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Feb 23, 2018
commit 69c88ad075c5d4ab32fd54a30d995014790cb7d6
22 changes: 21 additions & 1 deletion apps/updatenotification/tests/Settings/AdminTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
use OCP\AppFramework\Http\TemplateResponse;
use OCP\IConfig;
use OCP\IDateTimeFormatter;
use OCP\IGroup;
use OCP\IGroupManager;
use OCP\Util;
use Test\TestCase;

Expand All @@ -40,6 +42,8 @@ class AdminTest extends TestCase {
private $config;
/** @var UpdateChecker|\PHPUnit_Framework_MockObject_MockObject */
private $updateChecker;
/** @var IGroupManager|\PHPUnit_Framework_MockObject_MockObject */
private $groupManager;
/** @var IDateTimeFormatter|\PHPUnit_Framework_MockObject_MockObject */
private $dateTimeFormatter;

Expand All @@ -48,11 +52,13 @@ public function setUp() {

$this->config = $this->createMock(IConfig::class);
$this->updateChecker = $this->createMock(UpdateChecker::class);
$this->groupManager = $this->createMock(IGroupManager::class);
$this->dateTimeFormatter = $this->createMock(IDateTimeFormatter::class);

$this->admin = new Admin(
$this->config,
$this->updateChecker,
$this->groupManager,
$this->dateTimeFormatter
);
}
Expand Down Expand Up @@ -96,6 +102,18 @@ public function testGetFormWithUpdate() {
'updaterEnabled' => true,
]);

$group = $this->createMock(IGroup::class);
$group->expects($this->any())
->method('getDisplayName')
->willReturn('Administrators');
$group->expects($this->any())
->method('getGID')
->willReturn('admin');
$this->groupManager->expects($this->once())
->method('get')
->with('admin')
->willReturn($group);

$params = [
'json' => json_encode([
'isNewVersionAvailable' => true,
Expand All @@ -108,7 +126,9 @@ public function testGetFormWithUpdate() {
'updaterEnabled' => true,
'isDefaultUpdateServerURL' => true,
'updateServerURL' => 'https://updates.nextcloud.com/updater_server/',
'notify_groups' => 'admin',
'notifyGroups' => [
['value' => 'admin', 'label' => 'Administrators'],
],
]),
];

Expand Down