From 17e85dd5079b7ee0b1f18a450b66ec5df3cf5eb3 Mon Sep 17 00:00:00 2001 From: Sean Molenaar Date: Sun, 18 Mar 2018 15:01:08 +0100 Subject: Unit: Fix unittests (#278) * Unit: Fix unittests Issue #171 * Tests: Move test namespace to the expected nextcloud namespace --- tests/Integration/Db/FeedMapperTest.php | 5 +- tests/Integration/Db/FolderMapperTest.php | 6 +- tests/Integration/Db/ItemMapperTest.php | 4 +- tests/Unit/Config/ConfigTest.php | 3 +- tests/Unit/Controller/AdminControllerTest.php | 4 +- tests/Unit/Controller/EntityApiSerializerTest.php | 4 +- tests/Unit/Controller/ExportControllerTest.php | 3 +- tests/Unit/Controller/FeedApiControllerTest.php | 3 +- tests/Unit/Controller/FeedControllerTest.php | 4 +- tests/Unit/Controller/FolderApiControllerTest.php | 3 +- tests/Unit/Controller/FolderControllerTest.php | 138 +++++++++++++-------- tests/Unit/Controller/ItemApiControllerTest.php | 3 +- tests/Unit/Controller/ItemControllerTest.php | 3 +- tests/Unit/Controller/JSONHttpErrorTest.php | 3 +- tests/Unit/Controller/PageControllerTest.php | 27 +--- tests/Unit/Controller/UserApiControllerTest.php | 3 +- tests/Unit/Controller/UtilityApiControllerTest.php | 3 +- tests/Unit/Db/FeedTest.php | 4 +- tests/Unit/Db/FolderMapperTest.php | 11 +- tests/Unit/Db/FolderTest.php | 3 +- tests/Unit/Db/ItemTest.php | 4 +- tests/Unit/Db/MapperFactoryTest.php | 4 +- tests/Unit/Db/MapperTestUtility.php | 1 - tests/Unit/Fetcher/FeedFetcherTest.php | 3 +- tests/Unit/Fetcher/FetcherTest.php | 4 +- tests/Unit/Fetcher/YoutubeFetcherTest.php | 3 +- tests/Unit/Http/TextDownloadResponseTest.php | 4 +- tests/Unit/Http/TextResponseTest.php | 4 +- tests/Unit/Migration/MigrateStatusFlagsTest.php | 3 +- tests/Unit/Service/FeedServiceTest.php | 3 +- tests/Unit/Service/FolderServiceTest.php | 20 ++- tests/Unit/Service/ItemServiceTest.php | 3 +- tests/Unit/Service/ServiceTest.php | 3 +- tests/Unit/Service/StatusServiceTest.php | 3 +- tests/Unit/Utility/OPMLExporterTest.php | 3 +- tests/Unit/Utility/ProxyConfigParserTest.php | 4 +- tests/Unit/Utility/UpdaterTest.php | 4 +- 37 files changed, 185 insertions(+), 125 deletions(-) (limited to 'tests') 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 * @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)); + $this->equalTo($this->user) + ); $this->feedService->expects($this->once()) ->method('findAll') ->with($this->equalTo($this->user)) @@ -278,17 +304,21 @@ class FolderControllerTest extends \PHPUnit_Framework_TestCase { } - public function testRestore(){ + public function testRestore() + { $this->folderService->expects($this->once()) ->method('unmarkDeleted') - ->with($this->equalTo(5), - $this->equalTo($this->user)); + ->with( + $this->equalTo(5), + $this->equalTo($this->user) + ); $this->controller->restore(5); } - public function testRestoreDoesNotExist(){ + public function testRestoreDoesNotExist() + { $this->folderService->expects($this->once()) ->method('unmarkDeleted') ->will( diff --git a/tests/Unit/Controller/ItemApiControllerTest.php b/tests/Unit/Controller/ItemApiControllerTest.php index 9ce405956..e30bc349a 100644 --- a/tests/Unit/Controller/ItemApiControllerTest.php +++ b/tests/Unit/Controller/ItemApiControllerTest.php @@ -11,8 +11,9 @@ * @copyright Bernhard Posselt 2012, 2014 */ -namespace OCA\News\Controller; +namespace OCA\News\Tests\Unit\Controller; +use OCA\News\Controller\ItemApiController; use \OCP\AppFramework\Http; use \OCA\News\Service\ServiceNotFoundException; diff --git a/tests/Unit/Controller/ItemControllerTest.php b/tests/Unit/Controller/ItemControllerTest.php index b9e04a75d..1c85748d5 100644 --- a/tests/Unit/Controller/ItemControllerTest.php +++ b/tests/Unit/Controller/ItemControllerTest.php @@ -11,8 +11,9 @@ * @copyright Bernhard Posselt 2012, 2014 */ -namespace OCA\News\Controller; +namespace OCA\News\Tests\Unit\Controller; +use OCA\News\Controller\ItemController; use \OCP\AppFramework\Http; use \OCA\News\Db\Item; diff --git a/tests/Unit/Controller/JSONHttpErrorTest.php b/tests/Unit/Controller/JSONHttpErrorTest.php index 31e702513..d7dcaa90a 100644 --- a/tests/Unit/Controller/JSONHttpErrorTest.php +++ b/tests/Unit/Controller/JSONHttpErrorTest.php @@ -11,8 +11,9 @@ * @copyright Bernhard Posselt 2012, 2014 */ -namespace OCA\News\Controller; +namespace OCA\News\Tests\Unit\Controller; +use OCA\News\Controller\JSONHttpError; class Test { use JSONHttpError; diff --git a/tests/Unit/Controller/PageControllerTest.php b/tests/Unit/Controller/PageControllerTest.php index 9923befb4..0ab433f05 100644 --- a/tests/Unit/Controller/PageControllerTest.php +++ b/tests/Unit/Controller/PageControllerTest.php @@ -11,8 +11,9 @@ * @copyright Bernhard Posselt 2012, 2014 */ -namespace OCA\News\Controller; +namespace OCA\News\Tests\Unit\Controller; +use OCA\News\Controller\PageController; use \OCA\News\Db\FeedType; @@ -64,7 +65,7 @@ class PageControllerTest extends \PHPUnit_Framework_TestCase { ->disableOriginalConstructor() ->getMock(); $this->appConfig = $this->getMockBuilder( - '\OCA\News\Config\AppConfig') + '\OCA\News\Config\Config') ->disableOriginalConstructor() ->getMock(); $this->config = $this->getMockBuilder( @@ -270,28 +271,6 @@ class PageControllerTest extends \PHPUnit_Framework_TestCase { } - public function testManifest(){ - $this->appConfig->expects($this->once()) - ->method('getConfig') - ->will($this->returnValue($this->configData)); - $this->l10n->expects($this->once()) - ->method('getLanguageCode') - ->will($this->returnValue('de_DE')); - - $result = $this->controller->manifest()->getData(); - $this->assertEquals($this->configData['name'], $result['name']); - $this->assertEquals('web', $result['type']); - $this->assertEquals( - $this->configData['description'], $result['description'] - ); - $this->assertEquals('de-DE', $result['default_locale']); - $this->assertEquals( - $this->configData['homepage'], $result['developer']['url'] - ); - $this->assertEquals('john, test', $result['developer']['name']); - } - - public function testExplore(){ $in = 'test'; $this->settings->expects($this->at(0)) diff --git a/tests/Unit/Controller/UserApiControllerTest.php b/tests/Unit/Controller/UserApiControllerTest.php index bb73de088..af49e59f1 100644 --- a/tests/Unit/Controller/UserApiControllerTest.php +++ b/tests/Unit/Controller/UserApiControllerTest.php @@ -11,8 +11,9 @@ * @copyright Bernhard Posselt 2012, 2014 */ -namespace OCA\News\Controller; +namespace OCA\News\Tests\Unit\Controller; +use OCA\News\Controller\UserApiController; class UserApiControllerTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Controller/UtilityApiControllerTest.php b/tests/Unit/Controller/UtilityApiControllerTest.php index ebd43f66e..f45502d39 100644 --- a/tests/Unit/Controller/UtilityApiControllerTest.php +++ b/tests/Unit/Controller/UtilityApiControllerTest.php @@ -11,8 +11,9 @@ * @copyright Bernhard Posselt 2012, 2014 */ -namespace OCA\News\Controller; +namespace OCA\News\Tests\Unit\Controller; +use OCA\News\Controller\UtilityApiController; class UtilityApiControllerTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Db/FeedTest.php b/tests/Unit/Db/FeedTest.php index 2e0d5535d..9b0c96f86 100644 --- a/tests/Unit/Db/FeedTest.php +++ b/tests/Unit/Db/FeedTest.php @@ -11,9 +11,11 @@ * @copyright Bernhard Posselt 2012, 2014 */ -namespace OCA\News\Db; +namespace OCA\News\Tests\Unit\Db; +use OCA\News\Db\Feed; + class FeedTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Db/FolderMapperTest.php b/tests/Unit/Db/FolderMapperTest.php index 2d5ed0f13..87b276d7c 100644 --- a/tests/Unit/Db/FolderMapperTest.php +++ b/tests/Unit/Db/FolderMapperTest.php @@ -11,18 +11,21 @@ * @copyright Bernhard Posselt 2012, 2014 */ -namespace OCA\News\Db; - +namespace OCA\News\Tests\Unit\Db; +use OCA\News\Db\Folder; +use OCA\News\Db\FolderMapper; use OCA\News\Utility\Time; -class FolderMapperTest extends \OCA\News\Tests\Unit\Db\MapperTestUtility { +class FolderMapperTest extends MapperTestUtility +{ private $folderMapper; private $folders; private $user; - protected function setUp(){ + protected function setUp() + { parent::setUp(); $this->folderMapper = new FolderMapper($this->db, new Time()); diff --git a/tests/Unit/Db/FolderTest.php b/tests/Unit/Db/FolderTest.php index 8be6e4302..39352425e 100644 --- a/tests/Unit/Db/FolderTest.php +++ b/tests/Unit/Db/FolderTest.php @@ -11,8 +11,9 @@ * @copyright Bernhard Posselt 2012, 2014 */ -namespace OCA\News\Db; +namespace OCA\News\Tests\Unit\Db; +use OCA\News\Db\Folder; class FolderTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Db/ItemTest.php b/tests/Unit/Db/ItemTest.php index 6f0b48e5a..cceca4b8b 100644 --- a/tests/Unit/Db/ItemTest.php +++ b/tests/Unit/Db/ItemTest.php @@ -11,8 +11,10 @@ * @copyright Bernhard Posselt 2012, 2014 */ -namespace OCA\News\Db; +namespace OCA\News\Tests\Unit\Db; +use OCA\News\Db\Feed; +use OCA\News\Db\Item; class ItemTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Db/MapperFactoryTest.php b/tests/Unit/Db/MapperFactoryTest.php index d519b1105..f7c1ffa08 100644 --- a/tests/Unit/Db/MapperFactoryTest.php +++ b/tests/Unit/Db/MapperFactoryTest.php @@ -11,8 +11,10 @@ * @copyright Bernhard Posselt 2012, 2014 */ -namespace OCA\News\Db; +namespace OCA\News\Tests\Unit\Db; +use OCA\News\Db\ItemMapper; +use OCA\News\Db\MapperFactory; use OCA\News\Utility\Time; use PHPUnit_Framework_TestCase; diff --git a/tests/Unit/Db/MapperTestUtility.php b/tests/Unit/Db/MapperTestUtility.php index 474def163..2448d8ddc 100644 --- a/tests/Unit/Db/MapperTestUtility.php +++ b/tests/Unit/Db/MapperTestUtility.php @@ -24,7 +24,6 @@ namespace OCA\News\Tests\Unit\Db; - /** * Simple utility class for testing mappers */ diff --git a/tests/Unit/Fetcher/FeedFetcherTest.php b/tests/Unit/Fetcher/FeedFetcherTest.php index 16d26cb66..ae0895d15 100644 --- a/tests/Unit/Fetcher/FeedFetcherTest.php +++ b/tests/Unit/Fetcher/FeedFetcherTest.php @@ -11,10 +11,11 @@ * @copyright Bernhard Posselt 2012, 2014 */ -namespace OCA\News\Fetcher; +namespace OCA\News\Tests\Unit\Fetcher; use \OCA\News\Db\Item; use \OCA\News\Db\Feed; +use OCA\News\Fetcher\FeedFetcher; use OCP\Http\Client\IClientService; use PicoFeed\Processor\ItemPostProcessor; diff --git a/tests/Unit/Fetcher/FetcherTest.php b/tests/Unit/Fetcher/FetcherTest.php index 7450b61d5..67619f71d 100644 --- a/tests/Unit/Fetcher/FetcherTest.php +++ b/tests/Unit/Fetcher/FetcherTest.php @@ -23,9 +23,11 @@ * */ -namespace OCA\News\Fetcher; +namespace OCA\News\Tests\Unit\Fetcher; +use OCA\News\Fetcher\Fetcher; + class FetcherTest extends \PHPUnit_Framework_TestCase { private $fetcher; diff --git a/tests/Unit/Fetcher/YoutubeFetcherTest.php b/tests/Unit/Fetcher/YoutubeFetcherTest.php index ae04ce916..64dcf5f98 100644 --- a/tests/Unit/Fetcher/YoutubeFetcherTest.php +++ b/tests/Unit/Fetcher/YoutubeFetcherTest.php @@ -9,9 +9,10 @@ * @copyright Bernhard Posselt 2012, 2014 */ -namespace OCA\News\Fetcher; +namespace OCA\News\Tests\Unit\Fetcher; use \OCA\News\Db\Feed; +use OCA\News\Fetcher\YoutubeFetcher; class YoutubeFetcherTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Http/TextDownloadResponseTest.php b/tests/Unit/Http/TextDownloadResponseTest.php index d1554a3da..84e5c8c60 100644 --- a/tests/Unit/Http/TextDownloadResponseTest.php +++ b/tests/Unit/Http/TextDownloadResponseTest.php @@ -12,9 +12,11 @@ */ -namespace OCA\News\Http; +namespace OCA\News\Tests\Unit\Http; +use OCA\News\Http\TextDownloadResponse; + class TextDownloadResponseTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Http/TextResponseTest.php b/tests/Unit/Http/TextResponseTest.php index c87ddab21..972b6cc3f 100644 --- a/tests/Unit/Http/TextResponseTest.php +++ b/tests/Unit/Http/TextResponseTest.php @@ -12,9 +12,11 @@ */ -namespace OCA\News\Http; +namespace OCA\News\Tests\Unit\Http; +use OCA\News\Http\TextResponse; + class TextResponseTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Migration/MigrateStatusFlagsTest.php b/tests/Unit/Migration/MigrateStatusFlagsTest.php index bee3532c1..dfb35b507 100644 --- a/tests/Unit/Migration/MigrateStatusFlagsTest.php +++ b/tests/Unit/Migration/MigrateStatusFlagsTest.php @@ -9,9 +9,10 @@ * @copyright Daniel Opitz 2017 */ -namespace OCA\News\Migration; +namespace OCA\News\Tests\Unit\Migration; use Doctrine\DBAL\Driver\Statement; +use OCA\News\Migration\MigrateStatusFlags; use OCP\IConfig; use OCP\IDBConnection; use OCP\Migration\IOutput; diff --git a/tests/Unit/Service/FeedServiceTest.php b/tests/Unit/Service/FeedServiceTest.php index 6df02e51c..08e25db8c 100644 --- a/tests/Unit/Service/FeedServiceTest.php +++ b/tests/Unit/Service/FeedServiceTest.php @@ -12,8 +12,9 @@ */ -namespace OCA\News\Service; +namespace OCA\News\Tests\Unit\Service; +use OCA\News\Service\FeedService; use OCP\AppFramework\Db\DoesNotExistException; use OCA\News\Db\Feed; diff --git a/tests/Unit/Service/FolderServiceTest.php b/tests/Unit/Service/FolderServiceTest.php index 65563b644..68dcda3f1 100644 --- a/tests/Unit/Service/FolderServiceTest.php +++ b/tests/Unit/Service/FolderServiceTest.php @@ -11,9 +11,10 @@ * @copyright Bernhard Posselt 2012, 2014 */ -namespace OCA\News\Service; +namespace OCA\News\Tests\Unit\Service; use \OCA\News\Db\Folder; +use OCA\News\Service\FolderService; class FolderServiceTest extends \PHPUnit_Framework_TestCase { @@ -80,6 +81,11 @@ class FolderServiceTest extends \PHPUnit_Framework_TestCase { ->with($this->equalTo($folder)) ->will($this->returnValue($folder)); + $this->folderMapper->expects($this->once()) + ->method('findByName') + ->with('hey', 'john') + ->will($this->returnValue([])); + $result = $this->folderService->create('hey', 'john', 5); $this->assertEquals($folder, $result); @@ -103,7 +109,9 @@ class FolderServiceTest extends \PHPUnit_Framework_TestCase { $this->folderService->create($folderName, 'john', 3); } - + /** + * @expectedException \OCA\News\Service\ServiceValidationException + */ public function testCreateThrowsExWhenFolderNameEmpty(){ $folderName = ''; @@ -112,9 +120,6 @@ class FolderServiceTest extends \PHPUnit_Framework_TestCase { ->with($this->equalTo($folderName)) ->will($this->returnValue([])); - $this->setExpectedException( - '\OCA\News\Service\ServiceValidationException' - ); $this->folderService->create($folderName, 'john', 3); } @@ -151,6 +156,11 @@ class FolderServiceTest extends \PHPUnit_Framework_TestCase { ->method('update') ->with($this->equalTo($folder)); + $this->folderMapper->expects($this->once()) + ->method('findByName') + ->with('bogus', '') + ->will($this->returnValue([])); + $this->folderService->rename(3, 'bogus', ''); $this->assertEquals('bogus', $folder->getName()); diff --git a/tests/Unit/Service/ItemServiceTest.php b/tests/Unit/Service/ItemServiceTest.php index 4beebbb63..8ec1a5c45 100644 --- a/tests/Unit/Service/ItemServiceTest.php +++ b/tests/Unit/Service/ItemServiceTest.php @@ -11,8 +11,9 @@ * @copyright Bernhard Posselt 2012, 2014 */ -namespace OCA\News\Service; +namespace OCA\News\Tests\Unit\Service; +use OCA\News\Service\ItemService; use \OCP\AppFramework\Db\DoesNotExistException; use \OCA\News\Db\Item; diff --git a/tests/Unit/Service/ServiceTest.php b/tests/Unit/Service/ServiceTest.php index 780f606df..46242434b 100644 --- a/tests/Unit/Service/ServiceTest.php +++ b/tests/Unit/Service/ServiceTest.php @@ -11,8 +11,9 @@ * @copyright Bernhard Posselt 2012, 2014 */ -namespace OCA\News\Service; +namespace OCA\News\Tests\Unit\Service; +use OCA\News\Service\Service; use \OCP\AppFramework\Db\DoesNotExistException; use \OCP\AppFramework\Db\MultipleObjectsReturnedException; diff --git a/tests/Unit/Service/StatusServiceTest.php b/tests/Unit/Service/StatusServiceTest.php index 095bf6247..ca1029504 100644 --- a/tests/Unit/Service/StatusServiceTest.php +++ b/tests/Unit/Service/StatusServiceTest.php @@ -11,9 +11,10 @@ * @copyright Bernhard Posselt 2012, 2014 */ -namespace OCA\News\Service; +namespace OCA\News\Tests\Unit\Service; use \OCA\News\Db\FeedType; +use OCA\News\Service\StatusService; class StatusServiceTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Utility/OPMLExporterTest.php b/tests/Unit/Utility/OPMLExporterTest.php index 4a4ff6ce3..cf33b779b 100644 --- a/tests/Unit/Utility/OPMLExporterTest.php +++ b/tests/Unit/Utility/OPMLExporterTest.php @@ -11,10 +11,11 @@ * @copyright Bernhard Posselt 2012, 2014 */ -namespace OCA\News\Utility; +namespace OCA\News\Tests\Unit\Utility; use \OCA\News\Db\Folder; use \OCA\News\Db\Feed; +use OCA\News\Utility\OPMLExporter; class OPMLExporterTest extends \PHPUnit_Framework_TestCase { diff --git a/tests/Unit/Utility/ProxyConfigParserTest.php b/tests/Unit/Utility/ProxyConfigParserTest.php index 685d88256..cc7833c31 100644 --- a/tests/Unit/Utility/ProxyConfigParserTest.php +++ b/tests/Unit/Utility/ProxyConfigParserTest.php @@ -11,9 +11,11 @@ * @copyright Bernhard Posselt 2012, 2014 */ -namespace OCA\News\Utility; +namespace OCA\News\Tests\Unit\Utility; +use OCA\News\Utility\ProxyConfigParser; + class ProxyConfigParserTest extends \PHPUnit_Framework_TestCase { private $config; diff --git a/tests/Unit/Utility/UpdaterTest.php b/tests/Unit/Utility/UpdaterTest.php index defa8c745..76ebe74f7 100644 --- a/tests/Unit/Utility/UpdaterTest.php +++ b/tests/Unit/Utility/UpdaterTest.php @@ -11,9 +11,11 @@ * @copyright Bernhard Posselt 2012, 2014 */ -namespace OCA\News\Utility; +namespace OCA\News\Tests\Unit\Utility; +use OCA\News\Utility\Updater; + class UpdaterTest extends \PHPUnit_Framework_TestCase { private $folderService; -- cgit v1.2.3