diff options
author | Daniel Opitz <git@copynpaste.de> | 2018-10-16 22:37:48 +0200 |
---|---|---|
committer | Sean Molenaar <SMillerDev@users.noreply.github.com> | 2018-12-04 17:10:46 +0100 |
commit | e158cc1d3b1fb33de5aaa1aaac0c7828016fb7b9 (patch) | |
tree | 4d3b4da643a428f259ca9fe1c63d97f8cecfb5fc /tests | |
parent | 5c7fdb08534018ba86ec4a38f45b63cbbf67a72f (diff) |
use magic class constant instead of classname strings
Diffstat (limited to 'tests')
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 = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock(); $this->itemService = - $this->getMockBuilder('\OCA\News\Service\ItemService') + $this->getMockBuilder(ItemService::class) ->disableOriginalConstructor() ->getMock(); $this->feedService = - $this->getMockBuilder('\OCA\News\Service\FeedService') + $this->getMockBuilder(FeedService::class) ->disableOriginalConstructor() ->getMock(); - $this->request = $this->getMockBuilder( - '\OCP\IRequest' - ) + $this->request = $this->getMockBuilder(IRequest::class) ->disableOriginalConstructor() ->getMock(); $this->controller = new ItemController( diff --git a/tests/Unit/Controller/PageControllerTest.php b/tests/Unit/Controller/PageControllerTest.php index 84671ea6d..ce7a3e73d 100644 --- a/tests/Unit/Controller/PageControllerTest.php +++ b/tests/Unit/Controller/PageControllerTest.php @@ -13,8 +13,15 @@ namespace OCA\News\Tests\Unit\Controller; +use OCA\News\Config\Config; use OCA\News\Controller\PageController; use \OCA\News\Db\FeedType; +use OCA\News\Explore\RecommendedSites; +use OCA\News\Service\StatusService; +use OCP\IConfig; +use OCP\IL10N; +use OCP\IRequest; +use OCP\IURLGenerator; use PHPUnit\Framework\TestCase; @@ -51,44 +58,28 @@ class PageControllerTest extends TestCase 'description' => 'This is a test app', 'homepage' => 'https://github.com/owncloud/test' ]; - $this->l10n = $this->request = $this->getMockBuilder( - '\OCP\IL10n' - ) + $this->l10n = $this->request = $this->getMockBuilder(IL10N::class) ->disableOriginalConstructor() ->getMock(); - $this->settings = $this->getMockBuilder( - '\OCP\IConfig' - ) + $this->settings = $this->getMockBuilder(IConfig::class) ->disableOriginalConstructor() ->getMock(); - $this->request = $this->getMockBuilder( - '\OCP\IRequest' - ) + $this->request = $this->getMockBuilder(IRequest::class) ->disableOriginalConstructor() ->getMock(); - $this->urlGenerator = $this->getMockBuilder( - '\OCP\IURLGenerator' - ) + $this->urlGenerator = $this->getMockBuilder(IURLGenerator::class) ->disableOriginalConstructor() ->getMock(); - $this->appConfig = $this->getMockBuilder( - '\OCA\News\Config\Config' - ) + $this->appConfig = $this->getMockBuilder(Config::class) ->disableOriginalConstructor() ->getMock(); - $this->config = $this->getMockBuilder( - '\OCA\News\Config\Config' - ) + $this->config = $this->getMockBuilder(Config::class) ->disableOriginalConstructor() ->getMock(); - $this->recommended = $this->getMockBuilder( - '\OCA\News\Explore\RecommendedSites' - ) + $this->recommended = $this->getMockBuilder(RecommendedSites::class) ->disableOriginalConstructor() ->getMock(); - $this->status = $this->getMockBuilder( - '\OCA\News\Service\StatusService' - ) + $this->status = $this->getMockBuilder(StatusService::class) ->disableOriginalConstructor() ->getMock(); $this->controller = new PageController( diff --git a/tests/Unit/Controller/UserApiControllerTest.php b/tests/Unit/Controller/UserApiControllerTest.php index d562329f3..d9df73fe7 100644 --- a/tests/Unit/Controller/UserApiControllerTest.php +++ b/tests/Unit/Controller/UserApiControllerTest.php @@ -14,6 +14,11 @@ namespace OCA\News\Tests\Unit\Controller; use OCA\News\Controller\UserApiController; +use OCP\Files\File; +use OCP\Files\IRootFolder; +use OCP\IRequest; +use OCP\IUser; +use OCP\IUserSession; use PHPUnit\Framework\TestCase; @@ -31,29 +36,19 @@ class UserApiControllerTest extends TestCase protected function setUp() { $this->appName = 'news'; - $this->request = $this->getMockBuilder( - '\OCP\IRequest' - ) + $this->request = $this->getMockBuilder(IRequest::class) ->disableOriginalConstructor() ->getMock(); - $this->rootFolder = $this->getMockBuilder( - '\OCP\Files\IRootFolder' - ) + $this->rootFolder = $this->getMockBuilder(IRootFolder::class) ->disableOriginalConstructor() ->getMock(); - $this->file = $this->getMockBuilder( - '\OCP\Files\File' - ) + $this->file = $this->getMockBuilder(File::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) |