/** * @return TemplateResponse */ public function displayPanel() { $lastUpdateCheck = $this->dateTimeFormatter->formatDateTime($this->config->getAppValue('core', 'lastupdatedat')); $channels = ['daily', 'beta', 'stable', 'production']; $currentChannel = \OCP\Util::getChannel(); // Remove the currently used channel from the channels list if (($key = array_search($currentChannel, $channels)) !== false) { unset($channels[$key]); } $updateState = $this->updateChecker->getUpdateState(); $params = ['isNewVersionAvailable' => $updateState === [] ? false : true, 'lastChecked' => $lastUpdateCheck, 'currentChannel' => $currentChannel, 'channels' => $channels, 'newVersionString' => $updateState === [] ? '' : $updateState['updateVersion']]; return new TemplateResponse($this->appName, 'admin', $params, ''); }
public function testDisplayPanelWithoutUpdate() { $channels = ['daily', 'beta', 'stable', 'production']; $currentChannel = \OCP\Util::getChannel(); // Remove the currently used channel from the channels list if (($key = array_search($currentChannel, $channels)) !== false) { unset($channels[$key]); } $this->config->expects($this->exactly(2))->method('getAppValue')->willReturnMap([['core', 'lastupdatedat', '', '12345'], ['updatenotification', 'notify_groups', '["admin"]', '["admin"]']]); $this->dateTimeFormatter->expects($this->once())->method('formatDateTime')->with('12345')->willReturn('LastCheckedReturnValue'); $this->updateChecker->expects($this->once())->method('getUpdateState')->willReturn([]); $params = ['isNewVersionAvailable' => false, 'lastChecked' => 'LastCheckedReturnValue', 'currentChannel' => \OCP\Util::getChannel(), 'channels' => $channels, 'newVersionString' => '', 'notify_groups' => 'admin']; $expected = new TemplateResponse('updatenotification', 'admin', $params, ''); $this->assertEquals($expected, $this->adminController->displayPanel()); }
/** * @dataProvider channelProvider * * @param string $channel */ public function testOverrideChannel($channel) { \OCP\Util::setChannel($channel); $actual = \OCP\Util::getChannel($channel); $this->assertEquals($channel, $actual); }
/** * Get current value * @return string */ public function getCurrentChannel() { return \OCP\Util::getChannel(); }