summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDaniel Opitz <git@copynpaste.de>2018-10-16 22:37:48 +0200
committerSean Molenaar <SMillerDev@users.noreply.github.com>2018-12-04 17:10:46 +0100
commite158cc1d3b1fb33de5aaa1aaac0c7828016fb7b9 (patch)
tree4d3b4da643a428f259ca9fe1c63d97f8cecfb5fc /tests
parent5c7fdb08534018ba86ec4a38f45b63cbbf67a72f (diff)
use magic class constant instead of classname strings
Diffstat (limited to 'tests')
-rw-r--r--tests/Unit/Config/ConfigTest.php23
-rw-r--r--tests/Unit/Controller/AdminControllerTest.php15
-rw-r--r--tests/Unit/Controller/ExportControllerTest.php19
-rw-r--r--tests/Unit/Controller/FeedApiControllerTest.php32
-rw-r--r--tests/Unit/Controller/FeedControllerTest.php19
-rw-r--r--tests/Unit/Controller/FolderApiControllerTest.php28
-rw-r--r--tests/Unit/Controller/FolderControllerTest.php20
-rw-r--r--tests/Unit/Controller/ItemApiControllerTest.php20
-rw-r--r--tests/Unit/Controller/ItemControllerTest.php16
-rw-r--r--tests/Unit/Controller/PageControllerTest.php39
-rw-r--r--tests/Unit/Controller/UserApiControllerTest.php25
-rw-r--r--tests/Unit/Controller/UtilityApiControllerTest.php30
-rw-r--r--tests/Unit/Db/FolderMapperTest.php10
-rw-r--r--tests/Unit/Db/MapperTestUtility.php8
-rw-r--r--tests/Unit/Fetcher/FeedFetcherTest.php45
-rw-r--r--tests/Unit/Fetcher/FetcherTest.php15
-rw-r--r--tests/Unit/Fetcher/YoutubeFetcherTest.php5
-rw-r--r--tests/Unit/Service/FeedServiceTest.php47
-rw-r--r--tests/Unit/Service/FolderServiceTest.php30
-rw-r--r--tests/Unit/Service/ItemServiceTest.php29
-rw-r--r--tests/Unit/Service/ServiceTest.php12
-rw-r--r--tests/Unit/Service/StatusServiceTest.php13
-rw-r--r--tests/Unit/Utility/ProxyConfigParserTest.php5
-rw-r--r--tests/Unit/Utility/UpdaterTest.php16
24 files changed, 219 insertions, 302 deletions
diff --git a/tests/Unit/Config/ConfigTest.php b/tests/Unit/Config/ConfigTest.php
index 36e800ba4..992453cca 100644
--- a/tests/Unit/Config/ConfigTest.php
+++ b/tests/Unit/Config/ConfigTest.php
@@ -14,6 +14,9 @@
namespace OCA\News\Tests\Unit\Config;
use OCA\News\Config\Config;
+use OCP\Files\File;
+use OCP\Files\Folder;
+use OCP\ILogger;
use PHPUnit\Framework\TestCase;
class ConfigTest extends TestCase
@@ -26,12 +29,10 @@ class ConfigTest extends TestCase
public function setUp()
{
- $this->logger = $this->getMockBuilder(
- 'OCP\ILogger'
- )
+ $this->logger = $this->getMockBuilder(ILogger::class)
->disableOriginalConstructor()
->getMock();
- $this->fileSystem = $this->getMockBuilder('OCP\Files\Folder')->getMock();
+ $this->fileSystem = $this->getMockBuilder(Folder::class)->getMock();
$this->loggerParams = ['hi'];
$this->config = new Config(
$this->fileSystem, $this->logger, $this->loggerParams
@@ -54,7 +55,7 @@ class ConfigTest extends TestCase
public function testRead()
{
- $file = $this->getMockBuilder('OCP\Files\File')->getMock();
+ $file = $this->getMockBuilder(File::class)->getMock();
$this->fileSystem->expects($this->once())
->method('get')
->with($this->equalTo($this->configPath))
@@ -77,7 +78,7 @@ class ConfigTest extends TestCase
public function testReadIgnoresVeryLowPurgeInterval()
{
- $file = $this->getMockBuilder('OCP\Files\File')->getMock();
+ $file = $this->getMockBuilder(File::class)->getMock();
$this->fileSystem->expects($this->once())
->method('get')
->with($this->equalTo($this->configPath))
@@ -95,7 +96,7 @@ class ConfigTest extends TestCase
public function testReadBool()
{
- $file = $this->getMockBuilder('OCP\Files\File')->getMock();
+ $file = $this->getMockBuilder(File::class)->getMock();
$this->fileSystem->expects($this->once())
->method('get')
->with($this->equalTo($this->configPath))
@@ -117,7 +118,7 @@ class ConfigTest extends TestCase
public function testReadLogsInvalidValue()
{
- $file = $this->getMockBuilder('OCP\Files\File')->getMock();
+ $file = $this->getMockBuilder(File::class)->getMock();
$this->fileSystem->expects($this->once())
->method('get')
->with($this->equalTo($this->configPath))
@@ -141,7 +142,7 @@ class ConfigTest extends TestCase
public function testReadLogsInvalidINI()
{
- $file = $this->getMockBuilder('OCP\Files\File')->getMock();
+ $file = $this->getMockBuilder(File::class)->getMock();
$this->fileSystem->expects($this->once())
->method('get')
->with($this->equalTo($this->configPath))
@@ -173,7 +174,7 @@ class ConfigTest extends TestCase
$this->config->setMaxSize(399);
$this->config->setExploreUrl('http://google.de');
- $file = $this->getMockBuilder('OCP\Files\File')->getMock();
+ $file = $this->getMockBuilder(File::class)->getMock();
$this->fileSystem->expects($this->once())
->method('get')
->with($this->equalTo($this->configPath))
@@ -207,7 +208,7 @@ class ConfigTest extends TestCase
$this->fileSystem->expects($this->once())
->method('newFile')
->with($this->equalTo($this->configPath));
- $file = $this->getMockBuilder('OCP\Files\File')->getMock();
+ $file = $this->getMockBuilder(File::class)->getMock();
$this->fileSystem->expects($this->once())
->method('get')
->with($this->equalTo($this->configPath))
diff --git a/tests/Unit/Controller/AdminControllerTest.php b/tests/Unit/Controller/AdminControllerTest.php
index 486330193..2b148e67d 100644
--- a/tests/Unit/Controller/AdminControllerTest.php
+++ b/tests/Unit/Controller/AdminControllerTest.php
@@ -13,7 +13,10 @@
namespace OCA\News\Tests\Unit\Controller;
+use OCA\News\Config\Config;
use OCA\News\Controller\AdminController;
+use OCA\News\Service\ItemService;
+use OCP\IRequest;
use PHPUnit\Framework\TestCase;
class AdminControllerTest extends TestCase
@@ -32,19 +35,13 @@ class AdminControllerTest extends TestCase
public function setUp()
{
$this->appName = 'news';
- $this->request = $this->getMockBuilder(
- '\OCP\IRequest'
- )
+ $this->request = $this->getMockBuilder(IRequest::class)
->disableOriginalConstructor()
->getMock();
- $this->config = $this->getMockBuilder(
- '\OCA\News\Config\Config'
- )
+ $this->config = $this->getMockBuilder(Config::class)
->disableOriginalConstructor()
->getMock();
- $this->itemService = $this->getMockBuilder(
- '\OCA\News\Service\ItemService'
- )
+ $this->itemService = $this->getMockBuilder(ItemService::class)
->disableOriginalConstructor()
->getMock();
diff --git a/tests/Unit/Controller/ExportControllerTest.php b/tests/Unit/Controller/ExportControllerTest.php
index b2b56e8dd..9af641c42 100644
--- a/tests/Unit/Controller/ExportControllerTest.php
+++ b/tests/Unit/Controller/ExportControllerTest.php
@@ -14,12 +14,15 @@
namespace OCA\News\Tests\Unit\Controller;
use OCA\News\Controller\ExportController;
-use \OCP\AppFramework\Http;
+use OCA\News\Service\FeedService;
+use OCA\News\Service\FolderService;
+use OCA\News\Service\ItemService;
use \OCA\News\Http\TextDownloadResponse;
use \OCA\News\Utility\OPMLExporter;
use \OCA\News\Db\Item;
use \OCA\News\Db\Feed;
+use OCP\IRequest;
use PHPUnit\Framework\TestCase;
@@ -42,22 +45,16 @@ class ExportControllerTest extends TestCase
{
$this->appName = 'news';
$this->user = 'john';
- $this->itemService = $this->getMockBuilder(
- '\OCA\News\Service\ItemService'
- )
+ $this->itemService = $this->getMockBuilder(ItemService::class)
->disableOriginalConstructor()
->getMock();
- $this->feedService = $this->getMockBuilder(
- '\OCA\News\Service\FeedService'
- )
+ $this->feedService = $this->getMockBuilder(FeedService::class)
->disableOriginalConstructor()
->getMock();
- $this->folderService = $this->getMockBuilder(
- '\OCA\News\Service\FolderService'
- )
+ $this->folderService = $this->getMockBuilder(FolderService::class)
->disableOriginalConstructor()
->getMock();
- $this->request = $this->getMockBuilder('\OCP\IRequest')
+ $this->request = $this->getMockBuilder(IRequest::class)
->disableOriginalConstructor()
->getMock();
$this->opmlExporter = new OPMLExporter();
diff --git a/tests/Unit/Controller/FeedApiControllerTest.php b/tests/Unit/Controller/FeedApiControllerTest.php
index ef61d1969..cc387161d 100644
--- a/tests/Unit/Controller/FeedApiControllerTest.php
+++ b/tests/Unit/Controller/FeedApiControllerTest.php
@@ -16,13 +16,17 @@
namespace OCA\News\Tests\Unit\Controller;
use OCA\News\Controller\FeedApiController;
+use OCA\News\Service\FeedService;
+use OCA\News\Service\ItemService;
use \OCP\AppFramework\Http;
use \OCA\News\Service\ServiceNotFoundException;
use \OCA\News\Service\ServiceConflictException;
-use \OCA\News\Db\Folder;
use \OCA\News\Db\Feed;
-use \OCA\News\Db\Item;
+use OCP\ILogger;
+use OCP\IRequest;
+use OCP\IUser;
+use OCP\IUserSession;
use PHPUnit\Framework\TestCase;
@@ -43,25 +47,17 @@ class FeedApiControllerTest extends TestCase
protected function setUp()
{
$this->loggerParams = ['hi'];
- $this->logger = $this->getMockBuilder(
- '\OCP\ILogger'
- )
+ $this->logger = $this->getMockBuilder(ILogger::class)
->disableOriginalConstructor()
->getMock();
$this->appName = 'news';
- $this->request = $this->getMockBuilder(
- '\OCP\IRequest'
- )
+ $this->request = $this->getMockBuilder(IRequest::class)
->disableOriginalConstructor()
->getMock();
- $this->userSession = $this->getMockBuilder(
- '\OCP\IUserSession'
- )
+ $this->userSession = $this->getMockBuilder(IUserSession::class)
->disableOriginalConstructor()
->getMock();
- $this->user = $this->getMockBuilder(
- '\OCP\IUser'
- )
+ $this->user = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
$this->userSession->expects($this->any())
@@ -70,14 +66,10 @@ class FeedApiControllerTest extends TestCase
$this->user->expects($this->any())
->method('getUID')
->will($this->returnValue('123'));
- $this->feedService = $this->getMockBuilder(
- '\OCA\News\Service\FeedService'
- )
+ $this->feedService = $this->getMockBuilder(FeedService::class)
->disableOriginalConstructor()
->getMock();
- $this->itemService = $this->getMockBuilder(
- '\OCA\News\Service\ItemService'
- )
+ $this->itemService = $this->getMockBuilder(ItemService::class)
->disableOriginalConstructor()
->getMock();
$this->feedAPI = new FeedApiController(
diff --git a/tests/Unit/Controller/FeedControllerTest.php b/tests/Unit/Controller/FeedControllerTest.php
index 7580920d3..4703d307a 100644
--- a/tests/Unit/Controller/FeedControllerTest.php
+++ b/tests/Unit/Controller/FeedControllerTest.php
@@ -14,12 +14,17 @@
namespace OCA\News\Tests\Unit\Controller;
use OCA\News\Controller\FeedController;
+use OCA\News\Service\FeedService;
+use OCA\News\Service\FolderService;
+use OCA\News\Service\ItemService;
use OCP\AppFramework\Http;
use OCA\News\Db\Feed;
use OCA\News\Db\FeedType;
use OCA\News\Service\ServiceNotFoundException;
use OCA\News\Service\ServiceConflictException;
+use OCP\IConfig;
+use OCP\IRequest;
use PHPUnit\Framework\TestCase;
@@ -44,26 +49,22 @@ class FeedControllerTest extends TestCase
{
$this->appName = 'news';
$this->user = 'jack';
- $this->settings = $this->getMockBuilder(
- '\OCP\IConfig'
- )
+ $this->settings = $this->getMockBuilder(IConfig::class)
->disableOriginalConstructor()
->getMock();
$this->itemService = $this
- ->getMockBuilder('\OCA\News\Service\ItemService')
+ ->getMockBuilder(ItemService::class)
->disableOriginalConstructor()
->getMock();
$this->feedService = $this
- ->getMockBuilder('\OCA\News\Service\FeedService')
+ ->getMockBuilder(FeedService::class)
->disableOriginalConstructor()
->getMock();
$this->folderService = $this
- ->getMockBuilder('\OCA\News\Service\FolderService')
+ ->getMockBuilder(FolderService::class)
->disableOriginalConstructor()
->getMock();
- $this->request = $this->getMockBuilder(
- '\OCP\IRequest'
- )
+ $this->request = $this->getMockBuilder(IRequest::class)
->disableOriginalConstructor()
->getMock();
$this->controller = new FeedController(
diff --git a/tests/Unit/Controller/FolderApiControllerTest.php b/tests/Unit/Controller/FolderApiControllerTest.php
index d8035d902..3a93a460a 100644
--- a/tests/Unit/Controller/FolderApiControllerTest.php
+++ b/tests/Unit/Controller/FolderApiControllerTest.php
@@ -16,16 +16,18 @@
namespace OCA\News\Tests\Unit\Controller;
use OCA\News\Controller\FolderApiController;
+use OCA\News\Service\FolderService;
+use OCA\News\Service\ItemService;
use \OCP\AppFramework\Http;
-use \OCP\AppFramework\Http\JSONResponse;
use \OCA\News\Service\ServiceNotFoundException;
use \OCA\News\Service\ServiceConflictException;
use \OCA\News\Service\ServiceValidationException;
use \OCA\News\Db\Folder;
-use \OCA\News\Db\Feed;
-use \OCA\News\Db\Item;
+use OCP\IRequest;
+use OCP\IUser;
+use OCP\IUserSession;
use PHPUnit\Framework\TestCase;
@@ -45,19 +47,13 @@ class FolderApiControllerTest extends TestCase
protected function setUp()
{
$this->appName = 'news';
- $this->request = $this->getMockBuilder(
- '\OCP\IRequest'
- )
+ $this->request = $this->getMockBuilder(IRequest::class)
->disableOriginalConstructor()
->getMock();
- $this->userSession = $this->getMockBuilder(
- '\OCP\IUserSession'
- )
+ $this->userSession = $this->getMockBuilder(IUserSession::class)
->disableOriginalConstructor()
->getMock();
- $this->user = $this->getMockBuilder(
- '\OCP\IUser'
- )
+ $this->user = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
$this->userSession->expects($this->any())
@@ -66,14 +62,10 @@ class FolderApiControllerTest extends TestCase
$this->user->expects($this->any())
->method('getUID')
->will($this->returnValue('123'));
- $this->folderService = $this->getMockBuilder(
- '\OCA\News\Service\FolderService'
- )
+ $this->folderService = $this->getMockBuilder(FolderService::class)
->disableOriginalConstructor()
->getMock();
- $this->itemService = $this->getMockBuilder(
- '\OCA\News\Service\ItemService'
- )
+ $this->itemService = $this->getMockBuilder(ItemService::class)
->disableOriginalConstructor()
->getMock();
$this->folderAPI = new FolderApiController(
diff --git a/tests/Unit/Controller/FolderControllerTest.php b/tests/Unit/Controller/FolderControllerTest.php
index 98b96c5c3..b9e0485a4 100644
--- a/tests/Unit/Controller/FolderControllerTest.php
+++ b/tests/Unit/Controller/FolderControllerTest.php
@@ -14,6 +14,9 @@
namespace OCA\News\Tests\Unit\Controller;
use OCA\News\Controller\FolderController;
+use OCA\News\Service\FeedService;
+use OCA\News\Service\FolderService;
+use OCA\News\Service\ItemService;
use \OCP\AppFramework\Http;
use \OCA\News\Db\Folder;
@@ -21,6 +24,7 @@ use \OCA\News\Db\Feed;
use \OCA\News\Service\ServiceNotFoundException;
use \OCA\News\Service\ServiceConflictException;
use \OCA\News\Service\ServiceValidationException;
+use OCP\IRequest;
use PHPUnit\Framework\TestCase;
@@ -44,24 +48,16 @@ class FolderControllerTest extends TestCase
{
$this->appName = 'news';
$this->user = 'jack';
- $this->folderService = $this->getMockBuilder(
- '\OCA\News\Service\FolderService'
- )
+ $this->folderService = $this->getMockBuilder(FolderService::class)
->disableOriginalConstructor()
->getMock();
- $this->feedService = $this->getMockBuilder(
- '\OCA\News\Service\FeedService'
- )
+ $this->feedService = $this->getMockBuilder(FeedService::class)
->disableOriginalConstructor()
->getMock();
- $this->itemService = $this->getMockBuilder(
- '\OCA\News\Service\ItemService'
- )
+ $this->itemService = $this->getMockBuilder(ItemService::class)
->disableOriginalConstructor()
->getMock();
- $this->request = $this->getMockBuilder(
- '\OCP\IRequest'
- )
+ $this->request = $this->getMockBuilder(IRequest::class)
->disableOriginalConstructor()
->getMock();
$this->controller = new FolderController(
diff --git a/tests/Unit/Controller/ItemApiControllerTest.php b/tests/Unit/Controller/ItemApiControllerTest.php
index 1e6fde59b..5733a0c87 100644
--- a/tests/Unit/Controller/ItemApiControllerTest.php
+++ b/tests/Unit/Controller/ItemApiControllerTest.php
@@ -16,10 +16,14 @@
namespace OCA\News\Tests\Unit\Controller;
use OCA\News\Controller\ItemApiController;
+use OCA\News\Service\ItemService;
use \OCP\AppFramework\Http;
use \OCA\News\Service\ServiceNotFoundException;
use \OCA\News\Db\Item;
+use OCP\IRequest;
+use OCP\IUser;
+use OCP\IUserSession;
use PHPUnit\Framework\TestCase;
@@ -39,19 +43,13 @@ class ItemApiControllerTest extends TestCase
{
$this->user = 'tom';
$this->appName = 'news';
- $this->request = $this->getMockBuilder(
- '\OCP\IRequest'
- )
+ $this->request = $this->getMockBuilder(IRequest::class)
->disableOriginalConstructor()
->getMock();
- $this->userSession = $this->getMockBuilder(
- '\OCP\IUserSession'
- )
+ $this->userSession = $this->getMockBuilder(IUserSession::class)
->disableOriginalConstructor()
->getMock();
- $this->user = $this->getMockBuilder(
- '\OCP\IUser'
- )
+ $this->user = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
$this->userSession->expects($this->any())
@@ -60,9 +58,7 @@ class ItemApiControllerTest extends TestCase
$this->user->expects($this->any())
->method('getUID')
->will($this->returnValue('123'));
- $this->itemService = $this->getMockBuilder(
- '\OCA\News\Service\ItemService'
- )
+ $this->itemService = $this->getMockBuilder(ItemService::class)
->disableOriginalConstructor()
->getMock();
$this->itemAPI = new ItemApiController(
diff --git a/tests/Unit/Controller/ItemControllerTest.php b/tests/Unit/Controller/ItemControllerTest.php
index 0093083f4..b24d74148 100644
--- a/tests/Unit/Controller/ItemControllerTest.php
+++ b/tests/Unit/Controller/ItemControllerTest.php
@@ -14,12 +14,16 @@
namespace OCA\News\Tests\Unit\Controller;
use OCA\News\Controller\ItemController;
+use OCA\News\Service\FeedService;
+use OCA\News\Service\ItemService;
use \OCP\AppFramework\Http;
use \OCA\News\Db\Item;
use \OCA\News\Db\Feed;
use \OCA\News\Db\FeedType;
use \OCA\News\Service\ServiceNotFoundException;
+use OCP\IConfig;
+use OCP\IRequest;
use PHPUnit\Framework\TestCase;
@@ -43,22 +47,18 @@ class ItemControllerTest extends TestCase
{
$this->appName = 'news';
$this->user = 'jackob';
- $this->settings = $this->getMockBuilder(
- '\OCP\IConfig'
- )
+ $this->settings