summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSean Molenaar <SMillerDev@users.noreply.github.com>2018-03-18 15:01:08 +0100
committerBernhard Posselt <BernhardPosselt@users.noreply.github.com>2018-03-18 15:01:08 +0100
commit17e85dd5079b7ee0b1f18a450b66ec5df3cf5eb3 (patch)
tree4a4ddbea25429a4a9d82b8b28cd935d8838b30f3 /tests
parent2de169e43a17bdb6e1d19054e76de3ce7e220052 (diff)
Unit: Fix unittests (#278)
* Unit: Fix unittests Issue #171 * Tests: Move test namespace to the expected nextcloud namespace
Diffstat (limited to 'tests')
-rw-r--r--tests/Integration/Db/FeedMapperTest.php5
-rw-r--r--tests/Integration/Db/FolderMapperTest.php6
-rw-r--r--tests/Integration/Db/ItemMapperTest.php4
-rw-r--r--tests/Unit/Config/ConfigTest.php3
-rw-r--r--tests/Unit/Controller/AdminControllerTest.php4
-rw-r--r--tests/Unit/Controller/EntityApiSerializerTest.php4
-rw-r--r--tests/Unit/Controller/ExportControllerTest.php3
-rw-r--r--tests/Unit/Controller/FeedApiControllerTest.php3
-rw-r--r--tests/Unit/Controller/FeedControllerTest.php4
-rw-r--r--tests/Unit/Controller/FolderApiControllerTest.php3
-rw-r--r--tests/Unit/Controller/FolderControllerTest.php138
-rw-r--r--tests/Unit/Controller/ItemApiControllerTest.php3
-rw-r--r--tests/Unit/Controller/ItemControllerTest.php3
-rw-r--r--tests/Unit/Controller/JSONHttpErrorTest.php3
-rw-r--r--tests/Unit/Controller/PageControllerTest.php27
-rw-r--r--tests/Unit/Controller/UserApiControllerTest.php3
-rw-r--r--tests/Unit/Controller/UtilityApiControllerTest.php3
-rw-r--r--tests/Unit/Db/FeedTest.php4
-rw-r--r--tests/Unit/Db/FolderMapperTest.php11
-rw-r--r--tests/Unit/Db/FolderTest.php3
-rw-r--r--tests/Unit/Db/ItemTest.php4
-rw-r--r--tests/Unit/Db/MapperFactoryTest.php4
-rw-r--r--tests/Unit/Db/MapperTestUtility.php1
-rw-r--r--tests/Unit/Fetcher/FeedFetcherTest.php3
-rw-r--r--tests/Unit/Fetcher/FetcherTest.php4
-rw-r--r--tests/Unit/Fetcher/YoutubeFetcherTest.php3
-rw-r--r--tests/Unit/Http/TextDownloadResponseTest.php4
-rw-r--r--tests/Unit/Http/TextResponseTest.php4
-rw-r--r--tests/Unit/Migration/MigrateStatusFlagsTest.php3
-rw-r--r--tests/Unit/Service/FeedServiceTest.php3
-rw-r--r--tests/Unit/Service/FolderServiceTest.php20
-rw-r--r--tests/Unit/Service/ItemServiceTest.php3
-rw-r--r--tests/Unit/Service/ServiceTest.php3
-rw-r--r--tests/Unit/Service/StatusServiceTest.php3
-rw-r--r--tests/Unit/Utility/OPMLExporterTest.php3
-rw-r--r--tests/Unit/Utility/ProxyConfigParserTest.php4
-rw-r--r--tests/Unit/Utility/UpdaterTest.php4
37 files changed, 185 insertions, 125 deletions
diff --git a/tests/Integration/Db/FeedMapperTest.php b/tests/Integration/Db/FeedMapperTest.php
index b429149a4..bcf1cb895 100644
--- a/tests/Integration/Db/FeedMapperTest.php
+++ b/tests/Integration/Db/FeedMapperTest.php
@@ -11,10 +11,11 @@
* @copyright Daniel Opitz 2017
*/
-namespace OCA\News\Db;
+namespace OCA\News\Tests\Integration\Db;
-use OCA\News\Tests\Integration\Fixtures\FeedFixture;
+use OCA\News\Db\Feed;
use OCA\News\Tests\Integration\IntegrationTest;
+use OCA\News\Tests\Integration\Fixtures\FeedFixture;
class FeedMapperTest extends IntegrationTest {
diff --git a/tests/Integration/Db/FolderMapperTest.php b/tests/Integration/Db/FolderMapperTest.php
index 80ff1963c..4be407566 100644
--- a/tests/Integration/Db/FolderMapperTest.php
+++ b/tests/Integration/Db/FolderMapperTest.php
@@ -8,10 +8,10 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2015
*/
-
-namespace OCA\News\Db;
-use \OCA\News\Tests\Integration\IntegrationTest;
+namespace OCA\News\Tests\Integration\Db;
+
+use OCA\News\Tests\Integration\IntegrationTest;
class FolderMapperTest extends IntegrationTest {
diff --git a/tests/Integration/Db/ItemMapperTest.php b/tests/Integration/Db/ItemMapperTest.php
index fa9cc7d25..546c43d85 100644
--- a/tests/Integration/Db/ItemMapperTest.php
+++ b/tests/Integration/Db/ItemMapperTest.php
@@ -9,11 +9,11 @@
* @copyright Bernhard Posselt 2015
*/
-namespace OCA\News\Db;
+namespace OCA\News\Tests\Integration\Db;
+use OCA\News\Tests\Integration\IntegrationTest;
use OCA\News\Tests\Integration\Fixtures\FeedFixture;
use OCA\News\Tests\Integration\Fixtures\ItemFixture;
-use OCA\News\Tests\Integration\IntegrationTest;
class ItemMapperTest extends IntegrationTest {
diff --git a/tests/Unit/Config/ConfigTest.php b/tests/Unit/Config/ConfigTest.php
index 0d9ca434b..da9dd4522 100644
--- a/tests/Unit/Config/ConfigTest.php
+++ b/tests/Unit/Config/ConfigTest.php
@@ -11,8 +11,9 @@
* @copyright Bernhard Posselt 2012, 2014
*/
-namespace OCA\News\Config;
+namespace OCA\News\Tests\Unit\Config;
+use OCA\News\Config\Config;
use PHPUnit_Framework_TestCase;
diff --git a/tests/Unit/Controller/AdminControllerTest.php b/tests/Unit/Controller/AdminControllerTest.php
index 8b4fd7955..33926d0d2 100644
--- a/tests/Unit/Controller/AdminControllerTest.php
+++ b/tests/Unit/Controller/AdminControllerTest.php
@@ -11,9 +11,11 @@
* @copyright Bernhard Posselt 2012, 2014
*/
-namespace OCA\News\Controller;
+namespace OCA\News\Tests\Unit\Controller;
+use OCA\News\Controller\AdminController;
+
class AdminControllerTest extends \PHPUnit_Framework_TestCase {
private $appName;
diff --git a/tests/Unit/Controller/EntityApiSerializerTest.php b/tests/Unit/Controller/EntityApiSerializerTest.php
index 63de1ed7e..261d5f7c4 100644
--- a/tests/Unit/Controller/EntityApiSerializerTest.php
+++ b/tests/Unit/Controller/EntityApiSerializerTest.php
@@ -11,9 +11,9 @@
* @copyright Bernhard Posselt 2012, 2014
*/
-namespace OCA\News\Controller;
-
+namespace OCA\News\Tests\Unit\Controller;
+use OCA\News\Controller\EntityApiSerializer;
use \OCP\AppFramework\Http\Response;
use \OCP\AppFramework\Db\Entity;
diff --git a/tests/Unit/Controller/ExportControllerTest.php b/tests/Unit/Controller/ExportControllerTest.php
index 42fb2ac85..6701b38a6 100644
--- a/tests/Unit/Controller/ExportControllerTest.php
+++ b/tests/Unit/Controller/ExportControllerTest.php
@@ -11,8 +11,9 @@
* @copyright Bernhard Posselt 2012, 2014
*/
-namespace OCA\News\Controller;
+namespace OCA\News\Tests\Unit\Controller;
+use OCA\News\Controller\ExportController;
use \OCP\AppFramework\Http;
use \OCA\News\Http\TextDownloadResponse;
diff --git a/tests/Unit/Controller/FeedApiControllerTest.php b/tests/Unit/Controller/FeedApiControllerTest.php
index b58bbfbb1..8c0b25873 100644
--- a/tests/Unit/Controller/FeedApiControllerTest.php
+++ b/tests/Unit/Controller/FeedApiControllerTest.php
@@ -11,8 +11,9 @@
* @copyright Bernhard Posselt 2012, 2014
*/
-namespace OCA\News\Controller;
+namespace OCA\News\Tests\Unit\Controller;
+use OCA\News\Controller\FeedApiController;
use \OCP\AppFramework\Http;
use \OCA\News\Service\ServiceNotFoundException;
diff --git a/tests/Unit/Controller/FeedControllerTest.php b/tests/Unit/Controller/FeedControllerTest.php
index 478765091..4018e2174 100644
--- a/tests/Unit/Controller/FeedControllerTest.php
+++ b/tests/Unit/Controller/FeedControllerTest.php
@@ -11,8 +11,9 @@
* @copyright Bernhard Posselt 2012, 2014
*/
-namespace OCA\News\Controller;
+namespace OCA\News\Tests\Unit\Controller;
+use OCA\News\Controller\FeedController;
use OCP\AppFramework\Http;
use OCA\News\Db\Feed;
@@ -31,6 +32,7 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase {
private $itemService;
private $settings;
private $exampleResult;
+ private $user;
/**
diff --git a/tests/Unit/Controller/FolderApiControllerTest.php b/tests/Unit/Controller/FolderApiControllerTest.php
index e03581cae..df050911b 100644
--- a/tests/Unit/Controller/FolderApiControllerTest.php
+++ b/tests/Unit/Controller/FolderApiControllerTest.php
@@ -11,8 +11,9 @@
* @copyright Bernhard Posselt 2012, 2014
*/
-namespace OCA\News\Controller;
+namespace OCA\News\Tests\Unit\Controller;
+use OCA\News\Controller\FolderApiController;
use \OCP\AppFramework\Http;
use \OCP\AppFramework\Http\JSONResponse;
diff --git a/tests/Unit/Controller/FolderControllerTest.php b/tests/Unit/Controller/FolderControllerTest.php
index f7ec6596e..a46228ae0 100644
--- a/tests/Unit/Controller/FolderControllerTest.php
+++ b/tests/Unit/Controller/FolderControllerTest.php
@@ -11,8 +11,9 @@
* @copyright Bernhard Posselt 2012, 2014
*/
-namespace OCA\News\Controller;
+namespace OCA\News\Tests\Unit\Controller;
+use OCA\News\Controller\FolderController;
use \OCP\AppFramework\Http;
use \OCA\News\Db\Folder;
@@ -36,63 +37,67 @@ class FolderControllerTest extends \PHPUnit_Framework_TestCase {
/**
* Gets run before each test
*/
- public function setUp(){
+ public function setUp()
+ {
$this->appName = 'news';
$this->user = 'jack';
- $this->folderService = $this->getMockBuilder(
- '\OCA\News\Service\FolderService')
+ $this->folderService = $this->getMockBuilder('\OCA\News\Service\FolderService')
->disableOriginalConstructor()
->getMock();
- $this->feedService = $this->getMockBuilder(
- '\OCA\News\Service\FeedService')
+ $this->feedService = $this->getMockBuilder('\OCA\News\Service\FeedService')
->disableOriginalConstructor()
->getMock();
- $this->itemService = $this->getMockBuilder(
- '\OCA\News\Service\ItemService')
+ $this->itemService = $this->getMockBuilder('\OCA\News\Service\ItemService')
->disableOriginalConstructor()
->getMock();
- $this->request = $this->getMockBuilder(
- '\OCP\IRequest')
+ $this->request = $this->getMockBuilder('\OCP\IRequest')
->disableOriginalConstructor()
->getMock();
- $this->controller = new FolderController($this->appName, $this->request,
- $this->folderService,
- $this->feedService,
- $this->itemService,
- $this->user);
+ $this->controller = new FolderController(
+ $this->appName,
+ $this->request,
+ $this->folderService,
+ $this->feedService,
+ $this->itemService,
+ $this->user
+ );
$this->msg = 'ron';
}
-
-
- public function testIndex(){
+ public function testIndex()
+ {
$return = [new Folder(), new Folder()];
$this->folderService->expects($this->once())
- ->method('findAll')
- ->will($this->returnValue($return));
+ ->method('findAll')
+ ->will($this->returnValue($return));
$response = $this->controller->index();
$expected = ['folders' => $return];
$this->assertEquals($expected, $response);
}
-
- public function testOpen(){
+ public function testOpen()
+ {
$this->folderService->expects($this->once())
->method('open')
- ->with($this->equalTo(3),
- $this->equalTo(true), $this->equalTo($this->user));
+ ->with(
+ $this->equalTo(3),
+ $this->equalTo(true),
+ $this->equalTo($this->user)
+ );
$this->controller->open(3, true);
}
-
- public function testOpenDoesNotExist(){
+ public function testOpenDoesNotExist()
+ {
$this->folderService->expects($this->once())
->method('open')
- ->will($this->throwException(
- new ServiceNotFoundException($this->msg))
+ ->will(
+ $this->throwException(
+ new ServiceNotFoundException($this->msg)
+ )
);
$response = $this->controller->open(5, true);
@@ -103,19 +108,23 @@ class FolderControllerTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals($response->getStatus(), Http::STATUS_NOT_FOUND);
}
-
- public function testCollapse(){
+ public function testCollapse()
+ {
$this->folderService->expects($this->once())
->method('open')
- ->with($this->equalTo(5),
- $this->equalTo(false), $this->equalTo($this->user));
+ ->with(
+ $this->equalTo(5),
+ $this->equalTo(false),
+ $this->equalTo($this->user)
+ );
$this->controller->open(5, false);
}
- public function testCreate(){
+ public function testCreate()
+ {
$result = ['folders' => [new Folder()]];
$this->folderService->expects($this->once())
@@ -123,8 +132,10 @@ class FolderControllerTest extends \PHPUnit_Framework_TestCase {
->with($this->equalTo($this->user), $this->equalTo(false));
$this->folderService->expects($this->once())
->method('create')
- ->with($this->equalTo('tech'),
- $this->equalTo($this->user))
+ ->with(
+ $this->equalTo('tech'),
+ $this->equalTo($this->user)
+ )
->will($this->returnValue($result['folders'][0]));
$response = $this->controller->create('tech');
@@ -133,7 +144,8 @@ class FolderControllerTest extends \PHPUnit_Framework_TestCase {
}
- public function testCreateReturnsErrorForInvalidCreate(){
+ public function testCreateReturnsErrorForInvalidCreate()
+ {
$msg = 'except';
$ex = new ServiceValidationException($msg);
$this->folderService->expects($this->once())
@@ -146,13 +158,16 @@ class FolderControllerTest extends \PHPUnit_Framework_TestCase {
$response = $this->controller->create('tech');
$params = json_decode($response->render(), true);
- $this->assertEquals($response->getStatus(),
- Http::STATUS_UNPROCESSABLE_ENTITY);
+ $this->assertEquals(
+ $response->getStatus(),
+ Http::STATUS_UNPROCESSABLE_ENTITY
+ );
$this->assertEquals($msg, $params['message']);
}
- public function testCreateReturnsErrorForDuplicateCreate(){
+ public function testCreateReturnsErrorForDuplicateCreate()
+ {
$msg = 'except';
$ex = new ServiceConflictException($msg);
$this->folderService->expects($this->once())
@@ -170,17 +185,21 @@ class FolderControllerTest extends \PHPUnit_Framework_TestCase {
}
- public function testDelete(){
+ public function testDelete()
+ {
$this->folderService->expects($this->once())
->method('markDeleted')
- ->with($this->equalTo(5),
- $this->equalTo($this->user));
+ ->with(
+ $this->equalTo(5),
+ $this->equalTo($this->user)
+ );
$this->controller->delete(5);
}
- public function testDeleteDoesNotExist(){
+ public function testDeleteDoesNotExist()
+ {
$this->folderService->expects($this->once())
->method('markDeleted')
->will(
@@ -196,7 +215,8 @@ class FolderControllerTest extends \PHPUnit_Framework_TestCase {
}
- public function testRename(){
+ public function testRename()
+ {
$result = ['folders' => [new Folder()]];
$this->folderService->expects($this->once())
@@ -212,7 +232,8 @@ class FolderControllerTest extends \PHPUnit_Framework_TestCase {
}
- public function testRenameReturnsErrorForInvalidCreate(){
+ public function testRenameReturnsErrorForInvalidCreate()
+ {
$msg = 'except';
$ex = new ServiceValidationException($msg);
$this->folderService->expects($this->once())
@@ -228,7 +249,8 @@ class FolderControllerTest extends \PHPUnit_Framework_TestCase {
}
- public function testRenameDoesNotExist(){
+ public function testRenameDoesNotExist()
+ {
$msg = 'except';
$ex = new ServiceNotFoundException($msg);
$this->folderService->expects($this->once())
@@ -243,7 +265,8 @@ class FolderControllerTest extends \PHPUnit_Framework_TestCase {
}
- public function testRenameReturnsErrorForDuplicateCreate(){
+ public function testRenameReturnsErrorForDuplicateCreate()
+ {
$msg = 'except';
$ex = new ServiceConflictException($msg);
$this->folderService->expects($this->once())
@@ -259,15 +282,18 @@ class FolderControllerTest extends \PHPUnit_Framework_TestCase {
- public function testRead(){
+ public function testRead()
+ {
$feed = new Feed();
$expected = ['feeds' => [$feed]];
$this->itemService->expects($this->once())
->method('readFolder')
- ->with($this->equalTo(4),
+ ->with(
+ $this->equalTo(4),
$this->equalTo(5),
- $this->equalTo($this->user));