Unit: Fix unittests (#278)
* Unit: Fix unittests Issue #171 * Tests: Move test namespace to the expected nextcloud namespace
This commit is contained in:
parent
2de169e43a
commit
17e85dd507
13
.travis.yml
13
.travis.yml
|
@ -5,6 +5,8 @@ php:
|
|||
- 5.6
|
||||
- 7
|
||||
- 7.1
|
||||
- 7.2
|
||||
- nightly
|
||||
|
||||
env:
|
||||
global:
|
||||
|
@ -16,20 +18,17 @@ env:
|
|||
matrix:
|
||||
allow_failures:
|
||||
- env: DB=pgsql CORE_BRANCH=master
|
||||
- php: nightly
|
||||
include:
|
||||
- php: 5.6
|
||||
- php: 7.1
|
||||
env: DB=sqlite
|
||||
- php: 5.6
|
||||
- php: 7.1
|
||||
env: DB=mysql
|
||||
- php: 5.6
|
||||
- php: 7.1
|
||||
env: DB=pgsql CORE_BRANCH=master
|
||||
fast_finish: true
|
||||
|
||||
before_install:
|
||||
# re-enable once mariadb is added as an option
|
||||
# - if [[ "$DB" == 'mysql' ]]; then sudo apt-get -y install mariadb-server; fi
|
||||
- nvm install 6
|
||||
- npm install -g npm@latest
|
||||
- make
|
||||
# install core
|
||||
- cd ../
|
||||
|
|
|
@ -35,7 +35,7 @@ Before you update to a new version, [check the changelog](https://github.com/nex
|
|||
<lib>SimpleXML</lib>
|
||||
<lib>iconv</lib>
|
||||
<owncloud max-version="0" min-version="0"/>
|
||||
<nextcloud min-version="13" max-version="13"/>
|
||||
<nextcloud min-version="13" max-version="14"/>
|
||||
</dependencies>
|
||||
|
||||
<background-jobs>
|
||||
|
|
|
@ -35,6 +35,16 @@
|
|||
"riimu/kit-pathjoin": "1.1.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^5.4"
|
||||
"phpunit/phpunit": "^5.7"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"OCA\\News\\": "lib/"
|
||||
}
|
||||
},
|
||||
"autoload-dev": {
|
||||
"psr-4": {
|
||||
"OCA\\News\\Tests\\": "tests/"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "3e09cb824fc2eb931014dc99a3b5b648",
|
||||
"content-hash": "b969e56c53d7689ef20e4d37aa320376",
|
||||
"packages": [
|
||||
{
|
||||
"name": "ezyang/htmlpurifier",
|
||||
|
@ -104,6 +104,7 @@
|
|||
],
|
||||
"description": "Modern library to handle RSS/Atom feeds",
|
||||
"homepage": "https://github.com/miniflux/picoFeed",
|
||||
"abandoned": true,
|
||||
"time": "2017-06-12T00:22:06+00:00"
|
||||
},
|
||||
{
|
||||
|
@ -414,16 +415,16 @@
|
|||
},
|
||||
{
|
||||
"name": "phpdocumentor/reflection-docblock",
|
||||
"version": "4.2.0",
|
||||
"version": "4.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
|
||||
"reference": "66465776cfc249844bde6d117abff1d22e06c2da"
|
||||
"reference": "94fd0001232e47129dd3504189fa1c7225010d08"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/66465776cfc249844bde6d117abff1d22e06c2da",
|
||||
"reference": "66465776cfc249844bde6d117abff1d22e06c2da",
|
||||
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08",
|
||||
"reference": "94fd0001232e47129dd3504189fa1c7225010d08",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -461,7 +462,7 @@
|
|||
}
|
||||
],
|
||||
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
|
||||
"time": "2017-11-27T17:38:31+00:00"
|
||||
"time": "2017-11-30T07:14:17+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpdocumentor/type-resolver",
|
||||
|
@ -512,16 +513,16 @@
|
|||
},
|
||||
{
|
||||
"name": "phpspec/prophecy",
|
||||
"version": "1.7.3",
|
||||
"version": "1.7.5",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/phpspec/prophecy.git",
|
||||
"reference": "e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf"
|
||||
"reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf",
|
||||
"reference": "e4ed002c67da8eceb0eb8ddb8b3847bb53c5c2bf",
|
||||
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/dfd6be44111a7c41c2e884a336cc4f461b3b2401",
|
||||
"reference": "dfd6be44111a7c41c2e884a336cc4f461b3b2401",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -533,7 +534,7 @@
|
|||
},
|
||||
"require-dev": {
|
||||
"phpspec/phpspec": "^2.5|^3.2",
|
||||
"phpunit/phpunit": "^4.8.35 || ^5.7"
|
||||
"phpunit/phpunit": "^4.8.35 || ^5.7 || ^6.5"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
|
@ -571,7 +572,7 @@
|
|||
"spy",
|
||||
"stub"
|
||||
],
|
||||
"time": "2017-11-24T13:59:53+00:00"
|
||||
"time": "2018-02-19T10:16:54+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/php-code-coverage",
|
||||
|
@ -824,16 +825,16 @@
|
|||
},
|
||||
{
|
||||
"name": "phpunit/phpunit",
|
||||
"version": "5.7.26",
|
||||
"version": "5.7.27",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
||||
"reference": "7fbc25c13309de0c4c9bb48b7361f1eca34c7fbd"
|
||||
"reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/7fbc25c13309de0c4c9bb48b7361f1eca34c7fbd",
|
||||
"reference": "7fbc25c13309de0c4c9bb48b7361f1eca34c7fbd",
|
||||
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c",
|
||||
"reference": "b7803aeca3ccb99ad0a506fa80b64cd6a56bbc0c",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -857,7 +858,7 @@
|
|||
"sebastian/global-state": "^1.1",
|
||||
"sebastian/object-enumerator": "~2.0",
|
||||
"sebastian/resource-operations": "~1.0",
|
||||
"sebastian/version": "~1.0.3|~2.0",
|
||||
"sebastian/version": "^1.0.6|^2.0.1",
|
||||
"symfony/yaml": "~2.1|~3.0|~4.0"
|
||||
},
|
||||
"conflict": {
|
||||
|
@ -902,7 +903,7 @@
|
|||
"testing",
|
||||
"xunit"
|
||||
],
|
||||
"time": "2017-12-17T06:14:38+00:00"
|
||||
"time": "2018-02-01T05:50:59+00:00"
|
||||
},
|
||||
{
|
||||
"name": "phpunit/phpunit-mock-objects",
|
||||
|
@ -1478,16 +1479,16 @@
|
|||
},
|
||||
{
|
||||
"name": "symfony/yaml",
|
||||
"version": "v4.0.2",
|
||||
"version": "v4.0.6",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/yaml.git",
|
||||
"reference": "a5ee52d155f06ad23b19eb63c31228ff56ad1116"
|
||||
"reference": "de5f125ea39de846b90b313b2cfb031a0152d223"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/yaml/zipball/a5ee52d155f06ad23b19eb63c31228ff56ad1116",
|
||||
"reference": "a5ee52d155f06ad23b19eb63c31228ff56ad1116",
|
||||
"url": "https://api.github.com/repos/symfony/yaml/zipball/de5f125ea39de846b90b313b2cfb031a0152d223",
|
||||
"reference": "de5f125ea39de846b90b313b2cfb031a0152d223",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1532,20 +1533,20 @@
|
|||
],
|
||||
"description": "Symfony Yaml Component",
|
||||
"homepage": "https://symfony.com",
|
||||
"time": "2017-12-12T08:41:51+00:00"
|
||||
"time": "2018-02-19T20:08:53+00:00"
|
||||
},
|
||||
{
|
||||
"name": "webmozart/assert",
|
||||
"version": "1.2.0",
|
||||
"version": "1.3.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/webmozart/assert.git",
|
||||
"reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f"
|
||||
"reference": "0df1908962e7a3071564e857d86874dad1ef204a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/webmozart/assert/zipball/2db61e59ff05fe5126d152bd0655c9ea113e550f",
|
||||
"reference": "2db61e59ff05fe5126d152bd0655c9ea113e550f",
|
||||
"url": "https://api.github.com/repos/webmozart/assert/zipball/0df1908962e7a3071564e857d86874dad1ef204a",
|
||||
"reference": "0df1908962e7a3071564e857d86874dad1ef204a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
|
@ -1582,7 +1583,7 @@
|
|||
"check",
|
||||
"validate"
|
||||
],
|
||||
"time": "2016-11-23T20:04:58+00:00"
|
||||
"time": "2018-01-29T19:49:41+00:00"
|
||||
}
|
||||
],
|
||||
"aliases": [],
|
||||
|
|
|
@ -15,7 +15,6 @@ namespace OCA\News\Controller;
|
|||
|
||||
use \OCP\IRequest;
|
||||
use \OCP\ILogger;
|
||||
use \OCP\AppFramework\ApiController;
|
||||
use \OCP\AppFramework\Http;
|
||||
|
||||
use \OCA\News\Service\FeedService;
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
namespace OCA\News\Controller;
|
||||
|
||||
use \OCP\IRequest;
|
||||
use \OCP\AppFramework\ApiController;
|
||||
use \OCP\AppFramework\Http;
|
||||
|
||||
use \OCA\News\Service\FolderService;
|
||||
|
|
|
@ -14,7 +14,6 @@
|
|||
namespace OCA\News\Controller;
|
||||
|
||||
use \OCP\IRequest;
|
||||
use \OCP\AppFramework\ApiController;
|
||||
use \OCP\AppFramework\Http;
|
||||
|
||||
use \OCA\News\Service\ItemService;
|
||||
|
|
|
@ -17,7 +17,6 @@ use \OCP\IRequest;
|
|||
use \OCP\IUserSession;
|
||||
use \OCP\IURLGenerator;
|
||||
use \OCP\Files\IRootFolder;
|
||||
use \OCP\AppFramework\ApiController;
|
||||
use \OCP\AppFramework\Http;
|
||||
|
||||
class UserApiController extends ApiController {
|
||||
|
|
|
@ -15,7 +15,6 @@ namespace OCA\News\Controller;
|
|||
|
||||
use \OCP\IRequest;
|
||||
use \OCP\IConfig;
|
||||
use \OCP\AppFramework\ApiController;
|
||||
use \OCP\AppFramework\Http;
|
||||
|
||||
use \OCA\News\Utility\Updater;
|
||||
|
|
20
phpunit.xml
20
phpunit.xml
|
@ -4,4 +4,24 @@
|
|||
<directory>./tests/Unit</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
<directory suffix=".php">./lib/</directory>
|
||||
<exclude>
|
||||
<file>./lib/Config/DependencyException.php</file>
|
||||
<file>./lib/Explore/feeds/RecommendedSiteNotFoundException.php</file>
|
||||
<file>./lib/Explore/feeds/RecommendedSiteNotFoundException.php</file>
|
||||
<file>./lib/Fetcher/FetcherException.php</file>
|
||||
<file>./lib/Service/ServiceConflictException.php</file>
|
||||
<file>./lib/Service/ServiceException.php</file>
|
||||
<file>./lib/Service/ServiceNotFoundException.php</file>
|
||||
<file>./lib/Service/ServiceValidationException.php</file>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<logging>
|
||||
<log type="coverage-html" target="./build/report" lowUpperBound="35" highLowerBound="70"/>
|
||||
<log type="coverage-clover" target="./build/coverage.xml"/>
|
||||
<log type="junit" target="./build/junit.xml"/>
|
||||
</logging>
|
||||
</phpunit>
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -24,7 +24,6 @@
|
|||
|
||||
namespace OCA\News\Tests\Unit\Db;
|
||||
|
||||
|
||||
/**
|
||||
* Simple utility class for testing mappers
|
||||
*/
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue