diff options
author | Carl Schwan <carl@carlschwan.eu> | 2022-08-30 18:07:25 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-30 18:07:25 +0200 |
commit | 753e88793e0525cadd8a544e3f4093cc3cf7b331 (patch) | |
tree | f544b21061e5469899f728bd9fa417a801a2d3b8 /tests/Unit/Controller | |
parent | 39ac02c03464c4cdb511d34c0232120d99dde936 (diff) |
Port admin settings to vue (#1880)
* Port admin settings to vue
Co-authored-by: anoy. <anoymouserver@users.noreply.github.com>
Co-authored-by: Benjamin Brahmer <info@b-brahmer.de>
Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'tests/Unit/Controller')
-rw-r--r-- | tests/Unit/Controller/AdminControllerTest.php | 156 |
1 files changed, 0 insertions, 156 deletions
diff --git a/tests/Unit/Controller/AdminControllerTest.php b/tests/Unit/Controller/AdminControllerTest.php deleted file mode 100644 index a9d7bb127..000000000 --- a/tests/Unit/Controller/AdminControllerTest.php +++ /dev/null @@ -1,156 +0,0 @@ -<?php -/** - * Nextcloud - News - * - * This file is licensed under the Affero General Public License version 3 or - * later. See the COPYING file. - * - * @author Alessandro Cosentino <cosenal@gmail.com> - * @author Bernhard Posselt <dev@bernhard-posselt.com> - * @copyright 2012 Alessandro Cosentino - * @copyright 2012-2014 Bernhard Posselt - */ - -namespace OCA\News\Tests\Unit\Controller; - -use OCA\News\Controller\AdminController; -use OCA\News\Service\ItemService; -use OCP\IConfig; -use OCP\IRequest; -use PHPUnit\Framework\TestCase; - -class AdminControllerTest extends TestCase -{ - /** - * @var string - */ - private $appName; - - /** - * @var \PHPUnit\Framework\MockObject\MockObject|IRequest - */ - private $request; - - /** - * @var AdminController - */ - private $controller; - - /** - * @var \PHPUnit\Framework\MockObject\MockObject|IConfig - */ - private $config; - - /** - * @var \PHPUnit\Framework\MockObject\MockObject|ItemService - */ - private $itemService; - - /** - * Gets run before each test - */ - public function setUp(): void - { - $this->appName = 'news'; - $this->request = $this->getMockBuilder(IRequest::class) - ->disableOriginalConstructor() - ->getMock(); - $this->config = $this->getMockBuilder(IConfig::class) - ->disableOriginalConstructor() - ->getMock(); - $this->itemService = $this->getMockBuilder(ItemService::class) - ->disableOriginalConstructor() - ->getMock(); - - $this->controller = new AdminController($this->request, $this->config, $this->itemService); - } - - /** - * Test \OCA\News\Controller\AdminController::index - */ - public function testIndex() - { - $expected = [ - 'autoPurgeMinimumInterval' => 1, - 'autoPurgeCount' => 2, - 'maxRedirects' => 3, - 'feedFetcherTimeout' => 4, - 'useCronUpdates' => false, - 'exploreUrl' => 'test', - 'updateInterval' => 3601 - ]; - $map = [ - ['news','autoPurgeMinimumInterval', 60, 1], - ['news','autoPurgeCount', 200, 2], - ['news','maxRedirects', 10, 3], - ['news','feedFetcherTimeout', 60, 4], - ['news','useCronUpdates', true, false,], - ['news','exploreUrl', '', 'test'], - ['news','updateInterval', 3600, 3601] - ]; - $this->config->expects($this->exactly(count($map))) - ->method('getAppValue') - ->will($this->returnValueMap($map)); - - $response = $this->controller->index(); - $data = $response->getParams(); - $name = $response->getTemplateName(); - $type = $response->getRenderAs(); - - $this->assertEquals($type, 'blank'); - $this->assertEquals($name, 'admin'); - $this->assertEquals($expected, $data); - } - - - public function testUpdate() - { - $expected = [ - 'autoPurgeMinimumInterval' => 1, - 'autoPurgeCount' => 2, - 'maxRedirects' => 3, - 'feedFetcherTimeout' => 4, - 'useCronUpdates' => false, - 'exploreUrl' => 'test', - 'updateInterval' => 3601 - ]; - - $this->config->expects($this->exactly(count($expected))) - ->method('setAppValue') - ->withConsecutive( - ['news','autoPurgeMinimumInterval', 1], - ['news','autoPurgeCount', 2], - ['news','maxRedirects', 3], - ['news','feedFetcherTimeout', 4], - ['news','useCronUpdates', false], - ['news','exploreUrl', 'test'], - ['news','updateInterval', 3601] - ); - - $map = [ - ['news','autoPurgeMinimumInterval', 60, 1], - ['news','autoPurgeCount', 200, 2], - ['news','maxRedirects', 10, 3], - ['news','feedFetcherTimeout', 60, 4], - ['news','useCronUpdates', true, false,], - ['news','exploreUrl', '', 'test'], - ['news','updateInterval', 3600, 3601] - ]; - $this->config->expects($this->exactly(count($map))) - ->method('getAppValue') - ->will($this->returnValueMap($map)); - - $response = $this->controller->update( - $expected['autoPurgeMinimumInterval'], - $expected['autoPurgeCount'], - $expected['maxRedirects'], - $expected['feedFetcherTimeout'], - $expected['useCronUpdates'], - $expected['exploreUrl'], - $expected['updateInterval'] - ); - - $this->assertEquals($expected, $response); - } - -} |