summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSean Molenaar <sean@seanmolenaar.eu>2020-08-29 23:39:35 +0200
committerBenjamin Brahmer <info@b-brahmer.de>2020-09-27 15:35:31 +0200
commitd00d1ab2a28f428223e52b17052c072c64784016 (patch)
treec019f85fb7ac67147dd43ca64b4ac3cda99832f7 /tests
parent5687baca75d47dbdffd3de74e865ad2f71ef0cb7 (diff)
Create V2 mapper, Service and management commands
Signed-off-by: Sean Molenaar <sean@seanmolenaar.eu>
Diffstat (limited to 'tests')
-rw-r--r--tests/Integration/Db/FeedMapperTest.php16
-rw-r--r--tests/Integration/Db/ItemMapperTest.php52
-rw-r--r--tests/Integration/IntegrationTest.php30
-rw-r--r--tests/Unit/Controller/FeedApiControllerTest.php36
-rw-r--r--tests/Unit/Controller/FeedControllerTest.php16
-rw-r--r--tests/Unit/Controller/FolderApiControllerTest.php23
-rw-r--r--tests/Unit/Controller/FolderControllerTest.php14
-rw-r--r--tests/Unit/Controller/ItemApiControllerTest.php2
-rw-r--r--tests/Unit/Controller/ItemControllerTest.php2
-rw-r--r--tests/Unit/Controller/UtilityApiControllerTest.php57
-rw-r--r--tests/Unit/Db/FeedTest.php25
-rw-r--r--tests/Unit/Db/FolderMapperTest.php6
-rw-r--r--tests/Unit/Db/FolderTest.php9
-rw-r--r--tests/Unit/Db/MapperFactoryTest.php4
-rw-r--r--tests/Unit/Fetcher/FeedFetcherTest.php32
-rw-r--r--tests/Unit/Service/FeedServiceTest.php168
-rw-r--r--tests/Unit/Service/FolderServiceTest.php30
-rw-r--r--tests/Unit/Service/ItemServiceTest.php59
-rw-r--r--tests/Unit/Service/ServiceTest.php39
-rw-r--r--tests/Unit/Service/UpdaterTest.php (renamed from tests/Unit/Utility/UpdaterTest.php)38
20 files changed, 373 insertions, 285 deletions
diff --git a/tests/Integration/Db/FeedMapperTest.php b/tests/Integration/Db/FeedMapperTest.php
index 626b8f9a9..f07103d10 100644
--- a/tests/Integration/Db/FeedMapperTest.php
+++ b/tests/Integration/Db/FeedMapperTest.php
@@ -25,7 +25,7 @@ class FeedMapperTest extends IntegrationTest
$feed = new FeedFixture();
$feed = $this->feedMapper->insert($feed);
- $fetched = $this->feedMapper->find($feed->getId(), $this->user);
+ $fetched = $this->feedMapper->find($this->user, $feed->getId());
$this->assertInstanceOf(Feed::class, $fetched);
$this->assertEquals($feed->getLink(), $fetched->getLink());
@@ -34,7 +34,7 @@ class FeedMapperTest extends IntegrationTest
public function testFindNotExisting()
{
$this->expectException('OCP\AppFramework\Db\DoesNotExistException');
- $this->feedMapper->find(0, $this->user);
+ $this->feedMapper->find($this->user, 0);
}
@@ -252,22 +252,14 @@ class FeedMapperTest extends IntegrationTest
$this->assertCount(4, $this->feedMapper->findAllFromUser($this->user));
- $items = $this->itemMapper->findAll(100, 0, 0, true, false, $this->user);
+ $items = $this->itemMapper->findAllItems(100, 0, 0, true, false, $this->user);
$this->assertCount(9, $items);
$this->feedMapper->deleteUser($this->user);
$this->assertCount(0, $this->feedMapper->findAllFromUser($this->user));
- $items = $this->itemMapper->findAll(100, 0, 0, true, false, $this->user);
+ $items = $this->itemMapper->findAllItems(100, 0, 0, true, false, $this->user);
$this->assertCount(0, $items);
}
-
- /**
- * @coversNothing
- */
- public function testDeleteUserNotExisting()
- {
- $this->feedMapper->deleteUser('notexistinguser');
- }
}
diff --git a/tests/Integration/Db/ItemMapperTest.php b/tests/Integration/Db/ItemMapperTest.php
index 026834e6b..28a6c3e11 100644
--- a/tests/Integration/Db/ItemMapperTest.php
+++ b/tests/Integration/Db/ItemMapperTest.php
@@ -27,7 +27,7 @@ class ItemMapperTest extends IntegrationTest
$item = $this->itemMapper->insert($item);
- $fetched = $this->itemMapper->find($item->getId(), $this->user);
+ $fetched = $this->itemMapper->find($this->user, $item->getId());
$this->assertEquals($item->getTitle(), $fetched->getTitle());
}
@@ -44,7 +44,7 @@ class ItemMapperTest extends IntegrationTest
}
/**
- * @expectedException OCP\AppFramework\Db\DoesNotExistException
+ * @expectedException \OCP\AppFramework\Db\DoesNotExistException
*/
public function testFindNotFoundWhenDeletedFeed()
{
@@ -52,12 +52,12 @@ class ItemMapperTest extends IntegrationTest
$this->loadFixtures('default');
$id = $this->whereTitleId('not found feed');
- $this->itemMapper->find($id, $this->user);
+ $this->itemMapper->find($this->user, $id);
}
/**
- * @expectedException OCP\AppFramework\Db\DoesNotExistException
+ * @expectedException \OCP\AppFramework\Db\DoesNotExistException
*/
public function testFindNotFoundWhenDeletedFolder()
{
@@ -66,7 +66,7 @@ class ItemMapperTest extends IntegrationTest
$id = $this->whereTitleId('not found folder');
- $this->itemMapper->find($id, $this->user);
+ $this->itemMapper->find($this->user, $id);
}
@@ -76,15 +76,15 @@ class ItemMapperTest extends IntegrationTest
$this->itemMapper->deleteReadOlderThanThreshold(1);
- $this->itemMapper->find($this->whereTitleId('a title1'), $this->user);
- $this->itemMapper->find($this->whereTitleId('a title2'), $this->user);
- $this->itemMapper->find($this->whereTitleId('a title3'), $this->user);
- $this->itemMapper->find($this->whereTitleId('del3'), $this->user);
- $this->itemMapper->find($this->whereTitleId('del4'), $this->user);
+ $this->itemMapper->find($this->user, $this->whereTitleId('a title1'));
+ $this->itemMapper->find($this->user, $this->whereTitleId('a title2'));
+ $this->itemMapper->find($this->user, $this->whereTitleId('a title3'));
+ $this->itemMapper->find($this->user, $this->whereTitleId('del3'));
+ $this->itemMapper->find($this->user, $this->whereTitleId('del4'));
}
/**
- * @expectedException OCP\AppFramework\Db\DoesNotExistException
+ * @expectedException \OCP\AppFramework\Db\DoesNotExistException
*/
public function testDeleteOlderThanThresholdOne()
{
@@ -94,11 +94,11 @@ class ItemMapperTest extends IntegrationTest
$this->deleteReadOlderThanThreshold();
- $this->itemMapper->find($id, $this->user);
+ $this->itemMapper->find($this->user, $id);
}
/**
- * @expectedException OCP\AppFramework\Db\DoesNotExistException
+ * @expectedException \OCP\AppFramework\Db\DoesNotExistException
*/
public function testDeleteOlderThanThresholdTwo()
{
@@ -108,7 +108,7 @@ class ItemMapperTest extends IntegrationTest
$this->deleteReadOlderThanThreshold();
- $this->itemMapper->find($id, $this->user);
+ $this->itemMapper->find($this->user, $id);
}
@@ -127,24 +127,24 @@ class ItemMapperTest extends IntegrationTest
$this->itemMapper->readAll(PHP_INT_MAX, 10, $this->user);
- $items = $this->itemMapper->findAll(
+ $items = $this->itemMapper->findAllItems(
30, 0, 0, false, false, $this->user
);
$this->assertEquals(0, count($items));
$itemId = $this->whereTitleId('a title1');
- $item = $this->itemMapper->find($itemId, $this->user);
+ $item = $this->itemMapper->find($this->user, $itemId);
$this->assertEquals(10, $item->getLastModified());
$itemId = $this->whereTitleId('a title3');
- $item = $this->itemMapper->find($itemId, $this->user);
+ $item = $this->itemMapper->find($this->user, $itemId);
$this->assertEquals(10, $item->getLastModified());
$itemId = $this->whereTitleId('a title9');
- $item = $this->itemMapper->find($itemId, $this->user);
+ $item = $this->itemMapper->find($this->user, $itemId);
$this->assertEquals(10, $item->getLastModified());
}
@@ -159,24 +159,24 @@ class ItemMapperTest extends IntegrationTest
$folderId, PHP_INT_MAX, 10, $this->user
);
- $items = $this->itemMapper->findAll(
+ $items = $this->itemMapper->findAllItems(
30, 0, 0, false, false, $this->user
);
$this->assertEquals(1, count($items));
$item = $this->findItemByTitle('a title1');
- $item = $this->itemMapper->find($item->getId(), $this->user);
+ $item = $this->itemMapper->find($this->user, $item->getId());
$this->assertEquals(10, $item->getLastModified());
$item = $this->findItemByTitle('a title3');
- $item = $this->itemMapper->find($item->getId(), $this->user);
+ $item = $this->itemMapper->find($this->user, $item->getId());
$this->assertEquals(10, $item->getLastModified());
$item = $this->findItemByTitle('a title9');
- $item = $this->itemMapper->find($item->getId(), $this->user);
+ $item = $this->itemMapper->find($this->user, $item->getId());
$this->assertTrue($item->isUnread());
}
@@ -191,24 +191,24 @@ class ItemMapperTest extends IntegrationTest
$feedId, PHP_INT_MAX, 10, $this->user
);
- $items = $this->itemMapper->findAll(
+ $items = $this->itemMapper->findAllItems(
30, 0, 0, false, false, $this->user
);
$this->assertEquals(2, count($items));
$item = $this->findItemByTitle('a title9');
- $item = $this->itemMapper->find($item->getId(), $this->user);
+ $item = $this->itemMapper->find($this->user, $item->getId());
$this->assertEquals(10, $item->getLastModified());
$item = $this->findItemByTitle('a title3');
- $item = $this->itemMapper->find($item->getId(), $this->user);
+ $item = $this->itemMapper->find($this->user, $item->getId());
$this->assertTrue($item->isUnread());
$item = $this->findItemByTitle('a title1');
- $item = $this->itemMapper->find($item->getId(), $this->user);
+ $item = $this->itemMapper->find($this->user, $item->getId());
$this->assertTrue($item->isUnread());
}
diff --git a/tests/Integration/IntegrationTest.php b/tests/Integration/IntegrationTest.php
index 13969e7c3..276c6c394 100644
--- a/tests/Integration/IntegrationTest.php
+++ b/tests/Integration/IntegrationTest.php
@@ -39,22 +39,22 @@ abstract class IntegrationTest extends \Test\TestCase
protected $userPassword = 'test';
/**
- * @var ItemMapper
+ * @var ItemMapper
*/
protected $itemMapper;
/**
- * @var FeedMapper
+ * @var FeedMapper
*/
protected $feedMapper;
/**
- * @var FolderMapper
+ * @var FolderMapper
*/
protected $folderMapper;
/**
- * @var IAppContainer
+ * @var IAppContainer
*/
protected $container;
@@ -72,7 +72,7 @@ abstract class IntegrationTest extends \Test\TestCase
$this->folderMapper = $this->container->query(FolderMapper::class);
}
- protected function findItemByTitle($title)
+ protected function findItemByTitle($title)
{
// db logic in app code, negligible since its a test
$items = $this->itemMapper->where(['title' => $title]);
@@ -97,7 +97,7 @@ abstract class IntegrationTest extends \Test\TestCase
return $result;
}
- protected function findFolderByName($name)
+ protected function findFolderByName($name)
{
return $this->folderMapper->where(
[
@@ -107,7 +107,7 @@ abstract class IntegrationTest extends \Test\TestCase
)[0];
}
- protected function findFeedByTitle($title)
+ protected function findFeedByTitle($title)
{
return $this->feedMapper->where(
[
@@ -120,7 +120,7 @@ abstract class IntegrationTest extends \Test\TestCase
/**
* @param string $name loads fixtures from a given file
*/
- protected function loadFixtures($name)
+ protected function loadFixtures($name)
{
$fixtures = include __DIR__ . '/Fixtures/data/' . $name . '.php';
if (array_key_exists('folders', $fixtures)) {
@@ -131,7 +131,7 @@ abstract class IntegrationTest extends \Test\TestCase
}
}
- protected function loadFolderFixtures(array $folderFixtures=[])
+ protected function loadFolderFixtures(array $folderFixtures = [])
{
foreach ($folderFixtures as $folderFixture) {
$folder = new FolderFixture($folderFixture);
@@ -140,7 +140,7 @@ abstract class IntegrationTest extends \Test\TestCase
}
}
- protected function loadFeedFixtures(array $feedFixtures=[], $folderId=0)
+ protected function loadFeedFixtures(array $feedFixtures = [], $folderId = 0)
{
foreach ($feedFixtures as $feedFixture) {
$feed = new FeedFixture($feedFixture);
@@ -153,7 +153,7 @@ abstract class IntegrationTest extends \Test\TestCase
}
}
- protected function loadItemFixtures(array $itemFixtures=[], $feedId)
+ protected function loadItemFixtures(array $itemFixtures, $feedId)
{
foreach ($itemFixtures as $itemFixture) {
$item = new ItemFixture($itemFixture);
@@ -168,7 +168,7 @@ abstract class IntegrationTest extends \Test\TestCase
* @param Entity $fixture
* @return int the id
*/
- protected function loadFixture(Entity $fixture)
+ protected function loadFixture(Entity $fixture)
{
if ($fixture instanceof FeedFixture) {
return $this->feedMapper->insert($fixture)->getId();
@@ -187,7 +187,7 @@ abstract class IntegrationTest extends \Test\TestCase
* @param $user
* @param $password
*/
- protected function setupUser($user, $password)
+ protected function setupUser($user, $password)
{
$userManager = $this->container->query(IUserManager::class);
$userManager->createUser($user, $password);
@@ -200,7 +200,7 @@ abstract class IntegrationTest extends \Test\TestCase
*
* @param $user
*/
- protected function tearDownUser($user)
+ protected function tearDownUser($user)
{
$userManager = $this->container->query(IUserManager::class);
@@ -216,7 +216,7 @@ abstract class IntegrationTest extends \Test\TestCase
*
* @param string $user
*/
- protected function clearUserNewsDatabase($user)
+ protected function clearUserNewsDatabase($user)
{
$sql = [
'DELETE FROM `*PREFIX*news_items` WHERE `feed_id` IN
diff --git a/tests/Unit/Controller/FeedApiControllerTest.php b/tests/Unit/Controller/FeedApiControllerTest.php
index c889a54b3..1dbac6f42 100644
--- a/tests/Unit/Controller/FeedApiControllerTest.php
+++ b/tests/Unit/Controller/FeedApiControllerTest.php
@@ -18,10 +18,11 @@ namespace OCA\News\Tests\Unit\Controller;
use OCA\News\Controller\FeedApiController;
use OCA\News\Service\FeedService;
use OCA\News\Service\ItemService;
+use OCA\News\Utility\PsrLogger;
use \OCP\AppFramework\Http;
-use \OCA\News\Service\ServiceNotFoundException;
-use \OCA\News\Service\ServiceConflictException;
+use \OCA\News\Service\Exceptions\ServiceNotFoundException;
+use \OCA\News\Service\Exceptions\ServiceConflictException;
use \OCA\News\Db\Feed;
use OCP\ILogger;
use OCP\IRequest;
@@ -29,6 +30,7 @@ use OCP\IUser;
use OCP\IUserSession;
use PHPUnit\Framework\TestCase;
+use Psr\Log\LoggerInterface;
class FeedApiControllerTest extends TestCase
{
@@ -36,10 +38,7 @@ class FeedApiControllerTest extends TestCase
private $feedService;
private $itemService;
private $feedAPI;
- private $appName;
- private $userSession;
private $user;
- private $request;
private $msg;
private $logger;
private $loggerParams;
@@ -47,20 +46,20 @@ class FeedApiControllerTest extends TestCase
protected function setUp(): void
{
$this->loggerParams = ['hi'];
- $this->logger = $this->getMockBuilder(ILogger::class)
+ $this->logger = $this->getMockBuilder(LoggerInterface::class)
->disableOriginalConstructor()
->getMock();
- $this->appName = 'news';
- $this->request = $this->getMockBuilder(IRequest::class)
+ $appName = 'news';
+ $request = $this->getMockBuilder(IRequest::class)
->disableOriginalConstructor()
->getMock();
- $this->userSession = $this->getMockBuilder(IUserSession::class)
+ $userSession = $this->getMockBuilder(IUserSession::class)
->disableOriginalConstructor()
->getMock();
$this->user = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
- $this->userSession->expects($this->any())
+ $userSession->expects($this->any())
->method('getUser')
->will($this->returnValue($this->user));
$this->user->expects($this->any())
@@ -73,9 +72,9 @@ class FeedApiControllerTest extends TestCase
->disableOriginalConstructor()
->getMock();
$this->feedAPI = new FeedApiController(
- $this->appName,
- $this->request,
- $this->userSession,
+ $appName,
+ $request,
+ $userSession,
$this->feedService,
$this->itemService,
$this->logger,
@@ -100,7 +99,7 @@ class FeedApiControllerTest extends TestCase
->with($this->equalTo($this->user->getUID()))
->will($this->returnValue($newestItemId));
$this->feedService->expects($this->once())
- ->method('findAll')
+ ->method('findAllForUser')
->with($this->equalTo($this->user->getUID()))
->will($this->returnValue($feeds));
@@ -130,7 +129,7 @@ class FeedApiControllerTest extends TestCase
->with($this->equalTo($this->user->getUID()))
->will($this->throwException(new ServiceNotFoundException('')));
$this->feedService->expects($this->once())
- ->method('findAll')
+ ->method('findAllForUser')
->with($this->equalTo($this->user->getUID()))
->will($this->returnValue($feeds));
@@ -377,7 +376,7 @@ class FeedApiControllerTest extends TestCase
$this->feedService->expects($this->once())
->method('update')
- ->with($this->equalTo($feedId), $this->equalTo($userId));
+ ->with($userId, $feedId);
$this->feedAPI->update($userId, $feedId);
}
@@ -392,10 +391,7 @@ class FeedApiControllerTest extends TestCase
->will($this->throwException(new \Exception($this->msg)));
$this->logger->expects($this->once())
->method('debug')
- ->with(
- $this->equalTo('Could not update feed ' . $this->msg),
- $this->equalTo($this->loggerParams)
- );
+ ->with('Could not update feed ' . $this->msg);
$this->feedAPI->update($userId, $feedId);
diff --git a/tests/Unit/Controller/FeedControllerTest.php b/tests/Unit/Controller/FeedControllerTest.php
index 9a3114da0..7498d0ccb 100644
--- a/tests/Unit/Controller/FeedControllerTest.php
+++ b/tests/Unit/Controller/FeedControllerTest.php
@@ -21,8 +21,8 @@ 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 OCA\News\Service\Exceptions\ServiceNotFoundException;
+use OCA\News\Service\Exceptions\ServiceConflictException;
use OCP\IConfig;
use OCP\IRequest;
@@ -93,7 +93,7 @@ class FeedControllerTest extends TestCase
'starred' => 13
];
$this->feedService->expects($this->once())
- ->method('findAll')
+ ->method('findAllForUser')
->with($this->equalTo($this->user))
->will($this->returnValue($result['feeds']));
$this->itemService->expects($this->once())
@@ -121,7 +121,7 @@ class FeedControllerTest extends TestCase
'newestItemId' => 5
];
$this->feedService->expects($this->once())
- ->method('findAll')
+ ->method('findAllForUser')
->with($this->equalTo($this->user))
->will($this->returnValue($result['feeds']));
$this->itemService->expects($this->once())
@@ -189,7 +189,7 @@ class FeedControllerTest extends TestCase
$this->feedService->expects($this->once())
->method('find')
- ->with($this->equalTo($id), $this->equalTo($this->user))
+ ->with($this->user, $id)
->will($this->throwException($ex));
$this->activeInitMocks($id, $type);
@@ -209,7 +209,7 @@ class FeedControllerTest extends TestCase
$this->folderService->expects($this->once())
->method('find')
- ->with($this->equalTo($id), $this->equalTo($this->user))
+ ->with($this->user, $id)
->will($this->throwException($ex));
$this->activeInitMocks($id, $type);
@@ -374,7 +374,7 @@ class FeedControllerTest extends TestCase
$this->feedService->expects($this->once())
->method('update')
- ->with($this->equalTo(4), $this->equalTo($this->user))
+ ->with($this->equalTo($this->user), $this->equalTo(4))
->will($this->returnValue($feed));
$response = $this->controller->update(4);
@@ -387,7 +387,7 @@ class FeedControllerTest extends TestCase
{
$this->feedService->expects($this->once())
->method('update')
- ->with($this->equalTo(4), $this->equalTo($this->user))
+ ->with($this->equalTo($this->user), $this->equalTo(4))
->will($this->throwException(new ServiceNotFoundException('NO!')));
$response = $this->controller->update(4);
diff --git a/tests/Unit/Controller/FolderApiControllerTest.php b/tests/Unit/Controller/FolderApiControllerTest.php
index 311212169..de62b887a 100644
--- a/tests/Unit/Controller/FolderApiControllerTest.php
+++ b/tests/Unit/Controller/FolderApiControllerTest.php
@@ -20,9 +20,9 @@ use OCA\News\Service\FolderService;
use OCA\News\Service\ItemService;
use \OCP\AppFramework\Http;
-use \OCA\News\Service\ServiceNotFoundException;
-use \OCA\News\Service\ServiceConflictException;
-use \OCA\News\Service\ServiceValidationException;
+use \OCA\News\Service\Exceptions\ServiceNotFoundException;
+use \OCA\News\Service\Exceptions\ServiceConflictException;
+use \OCA\News\Service\Exceptions\ServiceValidationException;
use \OCA\News\Db\Folder;
use OCP\IRequest;
@@ -38,25 +38,22 @@ class FolderApiControllerTest extends TestCase
private $folderService;
private $itemService;
private $folderAPI;
- private $appName;
- private $userSession;
private $user;
- private $request;
private $msg;
protected function setUp(): void
{
- $this->appName = 'news';
- $this->request = $this->getMockBuilder(IRequest::class)
+ $appName = 'news';
+ $request = $this->getMockBuilder(IRequest::class)
->disableOriginalConstructor()
->getMock();
- $this->userSession = $this->getMockBuilder(IUserSession::class)
+ $userSession = $this->getMockBuilder(IUserSession::class)
->disableOriginalConstructor()
->getMock();
$this->user = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
- $this->userSession->expects($this->any())
+ $userSession->expects($this->any())
->method('getUser')
->will($this->returnValue($this->user));
$this->user->expects($this->any())
@@ -69,9 +66,9 @@ class FolderApiControllerTest extends TestCase
->disableOriginalConstructor()
->getMock();
$this->folderAPI = new FolderApiController(
- $this->appName,
- $this->request,
- $this->userSession,
+ $appName,
+ $request,
+ $userSession,
$this->folderService,
$this->itemService
);
diff --git a/tests/Unit/Controller/FolderControllerTest.php b/tests/Unit/Controller/FolderControllerTest.php
index abe1ebd7a..ea3454656 100644
--- a/tests/Unit/Controller/FolderControllerTest.php
+++ b/tests/Unit/Controller/FolderControllerTest.php
@@ -21,9 +21,9 @@ use \OCP\AppFramework\Http;
use \OCA\News\Db\Folder;
use \OCA\News\Db\Feed;
-use \OCA\News\Service\ServiceNotFoundException;
-use \OCA\News\Service\ServiceConflictException;
-use \OCA\News\Service\ServiceValidationException;
+use \OCA\News\Service\Exceptions\ServiceNotFoundException;
+use \OCA\News\Service\Exceptions\ServiceConflictException;
+use \OCA\News\Service\Exceptions\ServiceValidationException;
use OCP\IRequest;
use PHPUnit\Framework\TestCase;
@@ -32,11 +32,9 @@ use PHPUnit\Framework\TestCase;
class FolderControllerTest extends TestCase
{
- private $appName;
private $folderService;
private $itemService;
private $feedService;
- private $request;
private $controller;
private $msg;
@@ -46,7 +44,7 @@ class FolderControllerTest extends TestCase
*/
public function setUp(): void
{
- $this->appName = 'news';
+ $appName = 'news';
$this->user = 'jack';
$this->folderService = $this->getMockBuilder(FolderService::class)
->disableOriginalConstructor()
@@ -57,11 +55,11 @@ class FolderControllerTest extends TestCase
$this->itemService = $this->getMockBuilder(ItemService::class)
->disableOriginalConstructor()
->getMock();
- $this->request = $this->getMockBuilder(IRequest::class)
+ $request = $this->getMockBuilder(IRequest::class)
->disableOriginalConstructor()
->getMock();
$this->controller = new FolderController(
- $this->appName, $this->request,
+ $appName, $request,
$this->folderService,
$this->feedService,
$this->itemService,
diff --git a/tests/Unit/Controller/ItemApiControllerTest.php b/tests/Unit/Controller/ItemApiControllerTest.php
index 412b9dd51..1360ad872 100644
--- a/tests/Unit/Controller/ItemApiControllerTest.php
+++ b/tests/Unit/Controller/ItemApiControllerTest.php
@@ -19,7 +19,7 @@ use OCA\News\Controller\ItemApiController;
use OCA\News\Service\ItemService;
use \OCP\AppFramework\Http;
-use \OCA\News\Service\ServiceNotFoundException;
+use \OCA\News\Service\Exceptions\ServiceNotFoundException;
use \OCA\News\Db\Item;
use OCP\IRequest;
use OCP\IUser;
diff --git a/tests/Unit/Controller/ItemControllerTest.php b/tests/Unit/Controller/ItemControllerTest.php
index 9dbcf15ce..a0780cecb 100644
--- a/tests/Unit/Controller/ItemControllerTest.php
+++ b/tests/Unit/Controller/ItemControllerTest.php
@@ -21,7 +21,7 @@ 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 \OCA\News\Service\Exceptions\ServiceNotFoundException;
use OCP\IConfig;
use OCP\IRequest;
diff --git a/tests/Unit/Controller/UtilityApiControllerTest.php b/tests/Unit/Controller/UtilityApiControllerTest.php
index 32a66b2e8..127618288 100644
--- a/tests/Unit/Controller/UtilityApiControllerTest.php
+++ b/tests/Unit/Controller/UtilityApiControllerTest.php
@@ -17,7 +17,7 @@ namespace OCA\News\Tests\Unit\Controller;
use OCA\News\Controller\UtilityApiController;
use OCA\News\Service\StatusService;
-use OCA\News\Utility\Updater;
+use OCA\News\Service\UpdaterService;
use OCP\IConfig;
use OCP\IRequest;
use OCP\IUser;
@@ -28,21 +28,52 @@ use PHPUnit\Framework\TestCase;
class UtilityApiControllerTest extends TestCase
{
+ /**
+ * @var \PHPUnit\Framework\MockObject\MockObject|IConfig
+ */
private $settings;
+
+ /**
+ * @var \PHPUnit\Framework\MockObject\MockObject|IRequest
+ */
private $request;
+
+ /**
+ * @var \PHPUnit\Framework\MockObject\MockObject|IUserSession
+ */
private $userSession;
+
+ /**
+ * @var \PHPUnit\Framework\MockObject\MockObject|IUser
+ */
private $user;
+
+ /**
+ * @var UtilityApiController
+ */
private $newsAPI;
- private $updater;
+
+ /**
+ * @var string
+ */
private $appName;
+
+ /**
+ * @var \PHPUnit\Framework\MockObject\MockObject|StatusService
+ */
private $status;
+ /**
+ * @var \PHPUnit\Framework\MockObject\MockObject|UpdaterService
+ */
+ private $updateService;
+
protected function setUp(): void
{
$this->appName = 'news';
$this->settings = $this->getMockBuilder(IConfig::class)
- ->disableOriginalConstructor()
- ->getMock();
+ ->disableOriginalConstructor()
+ ->getMock();
$thi