Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/news.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.scrutinizer.yml2
-rw-r--r--appinfo/application.php26
-rw-r--r--appinfo/routes.php354
-rw-r--r--articleenhancer/globalarticleenhancer.php3
-rw-r--r--articleenhancer/xpatharticleenhancer.php26
-rw-r--r--config/appconfig.php30
-rw-r--r--config/config.php37
-rw-r--r--controller/admincontroller.php6
-rw-r--r--controller/exportcontroller.php4
-rw-r--r--controller/feedapicontroller.php8
-rw-r--r--controller/foldercontroller.php4
-rw-r--r--controller/itemapicontroller.php4
-rw-r--r--controller/itemcontroller.php13
-rw-r--r--controller/pagecontroller.php16
-rw-r--r--db/feedmapper.php48
-rw-r--r--db/item.php3
-rw-r--r--db/itemmapper.php21
-rw-r--r--fetcher/feedfetcher.php18
-rw-r--r--fetcher/fetcher.php4
-rw-r--r--fetcher/ifeedfetcher.php4
-rw-r--r--http/textdownloadresponse.php3
-rw-r--r--service/feedservice.php45
-rw-r--r--service/folderservice.php13
-rw-r--r--service/itemservice.php26
-rw-r--r--templates/admin.php13
-rw-r--r--templates/index.php28
-rw-r--r--templates/part.content.firstrun.php12
-rw-r--r--templates/part.content.php91
-rw-r--r--templates/part.content.shortcuts.php12
-rw-r--r--templates/part.navigation.addfeed.php33
-rw-r--r--templates/part.navigation.addfolder.php14
-rw-r--r--templates/part.navigation.feed.php38
-rw-r--r--templates/part.navigation.folder.php72
-rw-r--r--templates/part.navigation.unreadfeed.php6
-rw-r--r--templates/part.settings.php31
-rw-r--r--tests/classloader.php11
-rw-r--r--tests/unit/articleenhancer/GlobalArticleEnhancerTest.php18
-rw-r--r--tests/unit/articleenhancer/XPathArticleEnhancerTest.php18
-rw-r--r--tests/unit/config/ConfigTest.php60
-rw-r--r--tests/unit/controller/ExportControllerTest.php5
-rw-r--r--tests/unit/controller/FeedApiControllerTest.php16
-rw-r--r--tests/unit/controller/FeedControllerTest.php21
-rw-r--r--tests/unit/controller/FolderApiControllerTest.php32
-rw-r--r--tests/unit/controller/FolderControllerTest.php14
-rw-r--r--tests/unit/controller/ItemApiControllerTest.php16
-rw-r--r--tests/unit/controller/ItemControllerTest.php2
-rw-r--r--tests/unit/controller/PageControllerTest.php8
-rw-r--r--tests/unit/controller/UtilityApiControllerTest.php5
-rw-r--r--tests/unit/db/FeedMapperTest.php79
-rw-r--r--tests/unit/db/FolderMapperTest.php12
-rw-r--r--tests/unit/db/ItemMapperTest.php106
-rw-r--r--tests/unit/db/MapperFactoryTest.php3
-rw-r--r--tests/unit/db/postgres/ItemMapperTest.php2
-rw-r--r--tests/unit/fetcher/FeedFetcherTest.php6
-rw-r--r--tests/unit/http/TextDownloadResponseTest.php4
-rw-r--r--tests/unit/service/FeedServiceTest.php35
-rw-r--r--tests/unit/service/FolderServiceTest.php16
-rw-r--r--tests/unit/service/ItemServiceTest.php12
-rw-r--r--tests/unit/service/ServiceTest.php8
-rw-r--r--tests/unit/utility/FaviconFetcherTest.php6
-rw-r--r--tests/unit/utility/OPMLExporterTest.php37
61 files changed, 1147 insertions, 473 deletions
diff --git a/.scrutinizer.yml b/.scrutinizer.yml
index ead3dd199..d343f1edc 100644
--- a/.scrutinizer.yml
+++ b/.scrutinizer.yml
@@ -27,3 +27,5 @@ checks:
# this is not working properly with core exceptions
catch_class_exists: false
avoid_tab_indentation: true
+ line_length:
+ max_length: '80'
diff --git a/appinfo/application.php b/appinfo/application.php
index 8a1f02a4c..5b76680c4 100644
--- a/appinfo/application.php
+++ b/appinfo/application.php
@@ -72,7 +72,7 @@ foreach ($thirdPartyLibs as $class => $path) {
class Application extends App {
- public function __construct(array $urlParams=array()){
+ public function __construct(array $urlParams=[]) {
parent::__construct('news', $urlParams);
$container = $this->getContainer();
@@ -323,7 +323,8 @@ class Application extends App {
});
$container->registerService('DatabaseType', function($c) {
- return $c->query('ServerContainer')->getConfig()->getSystemValue('dbtype');
+ return $c->query('ServerContainer')
+ ->getConfig()->getSystemValue('dbtype');
});
@@ -354,8 +355,8 @@ class Application extends App {
});
$container->registerService('simplePieCacheDirectory', function($c) {
- $directory = $c->query('CoreConfig')->getSystemValue('datadirectory') .
- '/news/cache/simplepie';
+ $directory = $c->query('CoreConfig')
+ ->getSystemValue('datadirectory') . '/news/cache/simplepie';
if(!is_dir($directory)) {
mkdir($directory, 0770, true);
@@ -364,8 +365,8 @@ class Application extends App {
});
$container->registerService('HTMLPurifier', function($c) {
- $directory = $c->query('CoreConfig')->getSystemValue('datadirectory') .
- '/news/cache/purifier';
+ $directory = $c->query('CoreConfig')
+ ->getSystemValue('datadirectory') . '/news/cache/purifier';
if(!is_dir($directory)) {
mkdir($directory, 0770, true);
@@ -394,7 +395,8 @@ class Application extends App {
__DIR__ . '/../articleenhancer/xpathenhancers.json'
);
- foreach(json_decode($xpathEnhancerConfig, true) as $feed => $config) {
+ $xpathEnhancerConfig = json_decode($xpathEnhancerConfig, true);
+ foreach($xpathEnhancerConfig as $feed => $config) {
$articleEnhancer = new XPathArticleEnhancer(
$c->query('SimplePieAPIFactory'),
$config,
@@ -406,14 +408,18 @@ class Application extends App {
$regexEnhancerConfig = file_get_contents(
__DIR__ . '/../articleenhancer/regexenhancers.json'
);
- foreach(json_decode($regexEnhancerConfig, true) as $feed => $config) {
+ $regexEnhancerConfig = json_decode($regexEnhancerConfig, true);
+ foreach($regexEnhancerConfig as $feed => $config) {
foreach ($config as $matchArticleUrl => $regex) {
- $articleEnhancer = new RegexArticleEnhancer($matchArticleUrl, $regex);
+ $articleEnhancer =
+ new RegexArticleEnhancer($matchArticleUrl, $regex);
$enhancer->registerEnhancer($feed, $articleEnhancer);
}
}
- $enhancer->registerGlobalEnhancer($c->query('GlobalArticleEnhancer'));
+ $enhancer->registerGlobalEnhancer(
+ $c->query('GlobalArticleEnhancer')
+ );
return $enhancer;
});
diff --git a/appinfo/routes.php b/appinfo/routes.php
index 4287bd4a9..ac309a5ea 100644
--- a/appinfo/routes.php
+++ b/appinfo/routes.php
@@ -18,81 +18,317 @@ use \OCA\News\AppInfo\Application;
$application = new Application();
$application->registerRoutes($this, ['routes' => [
// page
- ['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
- ['name' => 'page#settings', 'url' => '/settings', 'verb' => 'GET'],
- ['name' => 'page#update_settings', 'url' => '/settings', 'verb' => 'PUT'],
- ['name' => 'page#manifest', 'url' => '/manifest.webapp', 'verb' => 'GET'],
+ [
+ 'name' => 'page#index',
+ 'url' => '/',
+ 'verb' => 'GET'
+ ],
+ [
+ 'name' => 'page#settings',
+ 'url' => '/settings',
+ 'verb' => 'GET'
+ ],
+ [
+ 'name' => 'page#update_settings',
+ 'url' => '/settings',
+ 'verb' => 'PUT'
+ ],
+ [
+ 'name' => 'page#manifest',
+ 'url' => '/manifest.webapp',
+ 'verb' => 'GET'
+ ],
// admin
- ['name' => 'admin#update', 'url' => '/admin', 'verb' => 'PUT'],
+ [
+ 'name' => 'admin#update',
+ 'url' => '/admin',
+ 'verb' => 'PUT'
+ ],
// folders
- ['name' => 'folder#index', 'url' => '/folders', 'verb' => 'GET'],
- ['name' => 'folder#create', 'url' => '/folders', 'verb' => 'POST'],
- ['name' => 'folder#delete', 'url' => '/folders/{folderId}', 'verb' => 'DELETE'],
- ['name' => 'folder#restore', 'url' => '/folders/{folderId}/restore', 'verb' => 'POST'],
- ['name' => 'folder#rename', 'url' => '/folders/{folderId}/rename', 'verb' => 'POST'],
- ['name' => 'folder#read', 'url' => '/folders/{folderId}/read', 'verb' => 'POST'],
- ['name' => 'folder#open', 'url' => '/folders/{folderId}/open', 'verb' => 'POST'],
+ [
+ 'name' => 'folder#index',
+ 'url' => '/folders',
+ 'verb' => 'GET'
+ ],
+ [
+ 'name' => 'folder#create',
+ 'url' => '/folders',
+ 'verb' => 'POST'
+ ],
+ [
+ 'name' => 'folder#delete',
+ 'url' => '/folders/{folderId}',
+ 'verb' => 'DELETE'
+ ],
+ [
+ 'name' => 'folder#restore',
+ 'url' => '/folders/{folderId}/restore',
+ 'verb' => 'POST'
+ ],
+ [
+ 'name' => 'folder#rename',
+ 'url' => '/folders/{folderId}/rename',
+ 'verb' => 'POST'
+ ],
+ [
+ 'name' => 'folder#read',
+ 'url' => '/folders/{folderId}/read',
+ 'verb' => 'POST'
+ ],
+ [
+ 'name' => 'folder#open',
+ 'url' => '/folders/{folderId}/open',
+ 'verb' => 'POST'
+ ],
// feeds
- ['name' => 'feed#index', 'url' => '/feeds', 'verb' => 'GET'],
- ['name' => 'feed#create', 'url' => '/feeds', 'verb' => 'POST'],
- ['name' => 'feed#delete', 'url' => '/feeds/{feedId}', 'verb' => 'DELETE'],
- ['name' => 'feed#restore', 'url' => '/feeds/{feedId}/restore', 'verb' => 'POST'],
- ['name' => 'feed#move', 'url' => '/feeds/{feedId}/move', 'verb' => 'POST'],
- ['name' => 'feed#rename', 'url' => '/feeds/{feedId}/rename', 'verb' => 'POST'],
- ['name' => 'feed#read', 'url' => '/feeds/{feedId}/read', 'verb' => 'POST'],
- ['name' => 'feed#update', 'url' => '/feeds/{feedId}/update', 'verb' => 'POST'],
- ['name' => 'feed#active', 'url' => '/feeds/active', 'verb' => 'GET'],
- ['name' => 'feed#import', 'url' => '/feeds/import/articles', 'verb' => 'POST'],
+ [
+ 'name' => 'feed#index',
+ 'url' => '/feeds',
+ 'verb' => 'GET'
+ ],
+ [
+ 'name' => 'feed#create',
+ 'url' => '/feeds',
+ 'verb' => 'POST'
+ ],
+ [
+ 'name' => 'feed#delete',
+ 'url' => '/feeds/{feedId}',
+ 'verb' => 'DELETE'
+ ],
+ [
+ 'name' => 'feed#restore',
+ 'url' => '/feeds/{feedId}/restore',
+ 'verb' => 'POST'
+ ],
+ [
+ 'name' => 'feed#move',
+ 'url' => '/feeds/{feedId}/move',
+ 'verb' => 'POST'
+ ],
+ [
+ 'name' => 'feed#rename',
+ 'url' => '/feeds/{feedId}/rename',
+ 'verb' => 'POST'
+ ],
+ [
+ 'name' => 'feed#read',
+ 'url' => '/feeds/{feedId}/read',
+ 'verb' => 'POST'
+ ],
+ [
+ 'name' => 'feed#update',
+ 'url' => '/feeds/{feedId}/update',
+ 'verb' => 'POST'
+ ],
+ [
+ 'name' => 'feed#active',
+ 'url' => '/feeds/active',
+ 'verb' => 'GET'
+ ],
+ [
+ 'name' => 'feed#import',
+ 'url' => '/feeds/import/articles',
+ 'verb' => 'POST'
+ ],
// items
- ['name' => 'item#index', 'url' => '/items', 'verb' => 'GET'],
- ['name' => 'item#new_items', 'url' => '/items/new', 'verb' => 'GET'],
- ['name' => 'item#readAll', 'url' => '/items/read', 'verb' => 'POST'],
- ['name' => 'item#read', 'url' => '/items/{itemId}/read', 'verb' => 'POST'],
- ['name' => 'item#read_multiple', 'url' => '/items/read/multiple', 'verb' => 'POST'],
- ['name' => 'item#star', 'url' => '/items/{feedId}/{guidHash}/star', 'verb' => 'POST'],
+ [
+ 'name' => 'item#index',
+ 'url' => '/items',
+ 'verb' => 'GET'
+ ],
+ [
+ 'name' => 'item#new_items',
+ 'url' => '/items/new',
+ 'verb' => 'GET'
+ ],
+ [
+ 'name' => 'item#readAll',
+ 'url' => '/items/read',
+ 'verb' => 'POST'
+ ],
+ [
+ 'name' => 'item#read',
+ 'url' => '/items/{itemId}/read',
+ 'verb' => 'POST'
+ ],
+ [
+ 'name' => 'item#read_multiple',
+ 'url' => '/items/read/multiple',
+ 'verb' => 'POST'
+ ],
+ [
+ 'name' => 'item#star',
+ 'url' => '/items/{feedId}/{guidHash}/star',
+ 'verb' => 'POST'
+ ],
// export
- ['name' => 'export#opml', 'url' => '/export/opml', 'verb' => 'GET'],
- ['name' => 'export#articles', 'url' => '/export/articles', 'verb' => 'GET'],
+ [
+ 'name' => 'export#opml',
+ 'url' => '/export/opml',
+ 'verb' => 'GET'
+ ],
+ [
+ 'name' => 'export#articles',
+ 'url' => '/export/articles',
+ 'verb' => 'GET'
+ ],
// API 1.2
- ['name' => 'utility_api#version', 'url' => '/api/v1-2/version', 'verb' => 'GET'],
- ['name' => 'utility_api#before_update', 'url' => '/api/v1-2/cleanup/before-update', 'verb' => 'GET'],
- ['name' => 'utility_api#after_update', 'url' => '/api/v1-2/cleanup/after-update', 'verb' => 'GET'],
- ['name' => 'utility_api#preflighted_cors', 'url' => '/api/v1-2/{path}', 'verb' => 'OPTIONS', 'requirements' => ['path' => '.+']],
+ [
+ 'name' => 'utility_api#version',
+ 'url' => '/api/v1-2/version',
+ 'verb' => 'GET'
+ ],
+ [
+ 'name' => 'utility_api#before_update',
+ 'url' => '/api/v1-2/cleanup/before-update',
+ 'verb' => 'GET'
+ ],
+ [
+ 'name' => 'utility_api#after_update',
+ 'url' => '/api/v1-2/cleanup/after-update',
+ 'verb' => 'GET'
+ ],
+ [
+ 'name' => 'utility_api#preflighted_cors',
+ 'url' => '/api/v1-2/{path}',
+ 'verb' => 'OPTIONS'
+ , 'requirements' => ['path' => '.+']],
// folders
- ['name' => 'folder_api#index', 'url' => '/api/v1-2/folders', 'verb' => 'GET'],
- ['name' => 'folder_api#create', 'url' => '/api/v1-2/folders', 'verb' => 'POST'],
- ['name' => 'folder_api#update', 'url' => '/api/v1-2/folders/{folderId}', 'verb' => 'PUT'],
- ['name' => 'folder_api#delete', 'url' => '/api/v1-2/folders/{folderId}', 'verb' => 'DELETE'],
- ['name' => 'folder_api#read', 'url' => '/api/v1-2/folders/{folderId}/read', 'verb' => 'PUT'], // FIXME: POST would be more correct
+ [
+ 'name' => 'folder_api#index',
+ 'url' => '/api/v1-2/folders',
+ 'verb' => 'GET'
+ ],
+ [
+ 'name' => 'folder_api#create',
+ 'url' => '/api/v1-2/folders',
+ 'verb' => 'POST'
+ ],
+ [
+ 'name' => 'folder_api#update',
+ 'url' => '/api/v1-2/folders/{folderId}',
+ 'verb' => 'PUT'
+ ],
+ [
+ 'name' => 'folder_api#delete',
+ 'url' => '/api/v1-2/folders/{folderId}',
+ 'verb' => 'DELETE'
+ ],
+ [
+ 'name' => 'folder_api#read',
+ 'url' => '/api/v1-2/folders/{folderId}/read',
+ 'verb' => 'PUT'
+ ], // FIXME: POST would be more correct
// feeds
- ['name' => 'feed_api#index', 'url' => '/api/v1-2/feeds', 'verb' => 'GET'],
- ['name' => 'feed_api#create', 'url' => '/api/v1-2/feeds', 'verb' => 'POST'],
- ['name' => 'feed_api#update', 'url' => '/api/v1-2/feeds/{feedId}', 'verb' => 'PUT'],
- ['name' => 'feed_api#delete', 'url' => '/api/v1-2/feeds/{feedId}', 'verb' => 'DELETE'],
- ['name' => 'feed_api#from_all_users', 'url' => '/api/v1-2/feeds/all', 'verb' => 'GET'],
- ['name' => 'feed_api#move', 'url' => '/api/v1-2/feeds/{feedId}/move', 'verb' => 'PUT'], // FIXME: POST would be more correct
- ['name' => 'feed_api#rename', 'url' => '/api/v1-2/feeds/{feedId}/rename', 'verb' => 'PUT'], // FIXME: POST would be more correct
- ['name' => 'feed_api#read', 'url' => '/api/v1-2/feeds/{feedId}/read', 'verb' => 'PUT'], // FIXME: POST would be more correct
- ['name' => 'feed_api#update', 'url' => '/api/v1-2/feeds/update', 'verb' => 'GET'],
+ [
+ 'name' => 'feed_api#index',
+ 'url' => '/api/v1-2/feeds',
+ 'verb' => 'GET'
+ ],
+ [
+ 'name' => 'feed_api#create',
+ 'url' => '/api/v1-2/feeds',
+ 'verb' => 'POST'
+ ],
+ [
+ 'name' => 'feed_api#update',
+ 'url' => '/api/v1-2/feeds/{feedId}',
+ 'verb' => 'PUT'
+ ],
+ [
+ 'name' => 'feed_api#delete',
+ 'url' => '/api/v1-2/feeds/{feedId}',
+ 'verb' => 'DELETE'
+ ],
+ [
+ 'name' => 'feed_api#from_all_users',
+ 'url' => '/api/v1-2/feeds/all',
+ 'verb' => 'GET'
+ ],
+ [
+ 'name' => 'feed_api#move',
+ 'url' => '/api/v1-2/feeds/{feedId}/move',
+ 'verb' => 'PUT'
+ ], // FIXME: POST would be more correct
+ [
+ 'name' => 'feed_api#rename',
+ 'url' => '/api/v1-2/feeds/{feedId}/rename',
+ 'verb' => 'PUT'
+ ], // FIXME: POST would be more correct
+ [
+ 'name' => 'feed_api#read',
+ 'url' => '/api/v1-2/feeds/{feedId}/read',
+ 'verb' => 'PUT'
+ ], // FIXME: POST would be more correct
+ [
+ 'name' => 'feed_api#update',
+ 'url' => '/api/v1-2/feeds/update',
+ 'verb' => 'GET'
+ ],
// items
- ['name' => 'item_api#index', 'url' => '/api/v1-2/items', 'verb' => 'GET'],
- ['name' => 'item_api#updated', 'url' => '/api/v1-2/items/updated', 'verb' => 'GET'],
- ['name' => 'item_api#read', 'url' => '/api/v1-2/items/{itemId}/read', 'verb' => 'PUT'], // FIXME: POST would be more correct
- ['name' => 'item_api#unread', 'url' => '/api/v1-2/items/{itemId}/unread', 'verb' => 'PUT'], // FIXME: POST would be more correct
- ['name' => 'item_api#read_all', 'url' => '/api/v1-2/items/read', 'verb' => 'PUT'], // FIXME: POST would be more correct
- ['name' => 'item_api#read_multiple', 'url' => '/api/v1-2/items/read/multiple', 'verb' => 'PUT'], // FIXME: POST would be more correct
- ['name' => 'item_api#unread_multiple', 'url' => '/api/v1-2/items/unread/multiple', 'verb' => 'PUT'], // FIXME: POST would be more correct
- ['name' => 'item_api#star', 'url' => '/api/v1-2/items/{feedId}/{guidHash}/star', 'verb' => 'PUT'], // FIXME: POST would be more correct
- ['name' => 'item_api#unstar', 'url' => '/api/v1-2/items/{feedId}/{guidHash}/unstar', 'verb' => 'PUT'], // FIXME: POST would be more correct
- ['name' => 'item_api#star_multiple', 'url' => '/api/v1-2/items/star/multiple', 'verb' => 'PUT'], // FIXME: POST would be more correct
- ['name' => 'item_api#unstar_multiple', 'url' => '/api/v1-2/items/unstar/multiple', 'verb' => 'PUT'], // FIXME: POST would be more correct
+ [
+ 'name' => 'item_api#index',
+ 'url' => '/api/v1-2/items',
+ 'verb' => 'GET'
+ ],
+ [
+ 'name' => 'item_api#updated',
+ 'url' => '/api/v1-2/items/updated',
+ 'verb' => 'GET'
+ ],
+ [
+ 'name' => 'item_api#read',
+ 'url' => '/api/v1-2/items/{itemId}/read',
+ 'verb' => 'PUT'
+ ], // FIXME: POST would be more correct
+ [
+ 'name' => 'item_api#unread',
+ 'url' => '/api/v1-2/items/{itemId}/unread',
+ 'verb' => 'PUT'
+ ], // FIXME: POST would be more correct
+ [
+ 'name' => 'item_api#read_all',
+ 'url' => '/api/v1-2/items/read',
+ 'verb' => 'PUT'
+ ], // FIXME: POST would be more correct
+ [
+ 'name' => 'item_api#read_multiple',
+ 'url' => '/api/v1-2/items/read/multiple',
+ 'verb' => 'PUT'
+ ], // FIXME: POST would be more correct
+ [
+ 'name' => 'item_api#unread_multiple',
+ 'url' => '/api/v1-2/items/unread/multiple',
+ 'verb' => 'PUT'
+ ], // FIXME: POST would be more correct
+ [
+ 'name' => 'item_api#star',
+ 'url' => '/api/v1-2/items/{feedId}/{guidHash}/star',
+ 'verb' => 'PUT'
+ ], // FIXME: POST would be more correct
+ [
+ 'name' => 'item_api#unstar',
+ 'url' => '/api/v1-2/items/{feedId}/{guidHash}/unstar',
+ 'verb' => 'PUT'
+ ], // FIXME: POST would be more correct
+ [
+ 'name' => 'item_api#star_multiple',
+ 'url' => '/api/v1-2/items/star/multiple',
+ 'verb' => 'PUT'
+ ], // FIXME: POST would be more correct
+ [
+ 'name' => 'item_api#unstar_multiple',
+ 'url' => '/api/v1-2/items/unstar/multiple',
+ 'verb' => 'PUT'
+ ], // FIXME: POST would be more correct
]]);
diff --git a/articleenhancer/globalarticleenhancer.php b/articleenhancer/globalarticleenhancer.php
index b556a285a..4c01a238c 100644
--- a/articleenhancer/globalarticleenhancer.php
+++ b/articleenhancer/globalarticleenhancer.php
@@ -49,7 +49,8 @@ class GlobalArticleEnhancer implements ArticleEnhancer {
// src needs to be matched against regex to prevent false positives
// and because theres no XPath matches function available
$src = $element->getAttribute('src');
- $regex = '%^(http://|https://|//)(www\.)?youtube.com/.*\?.*autoplay=1.*%i';
+ $regex = '%^(http://|https://|//)(www\.)?youtube.com/' .
+ '.*\?.*autoplay=1.*%i';
if (preg_match($regex, $src)) {
$replaced = str_replace('autoplay=1', 'autoplay=0', $src);
diff --git a/articleenhancer/xpatharticleenhancer.php b/articleenhancer/xpatharticleenhancer.php
index 7d80868f5..7dcb9a340 100644
--- a/articleenhancer/xpatharticleenhancer.php
+++ b/articleenhancer/xpatharticleenhancer.php
@@ -64,8 +64,10 @@ class XPathArticleEnhancer implements ArticleEnhancer {
$contentType = $file->headers['content-type'];
$body = $file->body;
- if( preg_match( '/(?<=charset=)[^;]*/', $contentType, $matches ) ) {
- $body = mb_convert_encoding($body, 'HTML-ENTITIES', $matches[0]);
+ if(preg_match('/(?<=charset=)[^;]*/', $contentType, $matches)) {
+ $encoding = $matches[0];
+ $body = mb_convert_encoding($body, 'HTML-ENTITIES',
+ $encoding);
}
$dom = new DOMDocument();
@@ -86,7 +88,9 @@ class XPathArticleEnhancer implements ArticleEnhancer {
$xpathResult = trim($xpathResult);
// convert all relative to absolute URLs
- $xpathResult = $this->substituteRelativeLinks($xpathResult, $item->getUrl());
+ $xpathResult = $this->substituteRelativeLinks(
+ $xpathResult, $item->getUrl()
+ );
if($xpathResult) {
$item->setBody($xpathResult);
@@ -108,8 +112,10 @@ class XPathArticleEnhancer implements ArticleEnhancer {
/**
* Method which converts all relative "href" and "src" URLs of
* a HTML snippet with their absolute equivalent
- * @param string $xmlString a HTML snippet as string with the relative URLs to be replaced
- * @param string $absoluteUrl the approptiate absolute url of the HTML snippet
+ * @param string $xmlString a HTML snippet as string with the relative URLs
+ * to be replaced
+ * @param string $absoluteUrl the approptiate absolute url of the HTML
+ * snippet
* @return string the result HTML snippet as a string
*/
protected function substituteRelativeLinks($xmlString, $absoluteUrl) {
@@ -136,14 +142,17 @@ class XPathArticleEnhancer implements ArticleEnhancer {
"and not(starts-with(@" . $attribute . ", '//'))]");
foreach ($xpathResult as $linkNode) {
$urlElement = $linkNode->attributes->getNamedItem($attribute);
- $abs = $this->relativeToAbsoluteUrl($urlElement->nodeValue, $absoluteUrl);
+ $abs = $this->relativeToAbsoluteUrl(
+ $urlElement->nodeValue, $absoluteUrl
+ );
$urlElement->nodeValue = htmlspecialchars($abs);
}
}
$xmlString = $dom->saveHTML();
- // domdocument spoils the string with line breaks between the elements. strip them.
+ // domdocument spoils the string with line breaks between the elements
+ // strip them
$xmlString = str_replace("\n", '', $xmlString);
return $xmlString;
@@ -153,9 +162,6 @@ class XPathArticleEnhancer implements ArticleEnhancer {
/**
* Method which builds a URL by taking a relative URL and its corresponding
* absolute URL
- * For example relative URL "../example/path/file.php?a=1#anchor" and
- * absolute URL "https://username:password@www.website.com/subfolder/index.html"
- * will result in "https://username:password@www.website.com/example/path/file.php?a=1#anchor"
* @param string $relativeUrl the relative URL
* @param string $absoluteUrl the absolute URL with at least scheme and host
* @return string the resulting absolute URL
diff --git a/config/appconfig.php b/config/appconfig.php
index a9045eb9a..62e1490ee 100644
--- a/config/appconfig.php
+++ b/config/appconfig.php
@@ -52,7 +52,8 @@ class AppConfig {
/**
- * @param string|array $data path to the config file or an array with the config
+ * @param string|array $data path to the config file or an array with the
+ * config
*/
public function loadConfig($data) {
if(is_array($data)) {
@@ -122,7 +123,8 @@ class AppConfig {
'name' => $nav['name']
];
- $navConfig['href'] = $this->urlGenerator->linkToRoute($nav['route']);
+ $navConfig['href'] =
+ $this->urlGenerator->linkToRoute($nav['route']);
$navConfig['icon'] = $this->urlGenerator->imagePath($nav['id'],
$nav['icon']);
@@ -157,8 +159,8 @@ class AppConfig {
* Registers all hooks in the config
*/
public function registerHooks() {
- // FIXME: this is temporarily static because core emitters are not future
- // proof, therefore legacy code in here
+ // FIXME: this is temporarily static because core emitters are not
+ // future proof, therefore legacy code in here
foreach ($this->config['hooks'] as $listen => $react) {
$listener = explode('::', $listen);
$reaction = explode('::', $react);
@@ -200,10 +202,13 @@ class AppConfig {
if (array_key_exists('libs', $deps)) {
foreach ($deps['libs'] as $lib => $versions) {
if(array_key_exists($lib, $this->installedExtensions)) {
- return $this->requireVersion($this->installedExtensions[$lib],
- $versions, 'PHP extension ' . $lib);
+ return $this->requireVersion(
+ $this->installedExtensions[$lib],
+ $versions, 'PHP extension ' . $lib
+ );
} else {
- return 'PHP extension ' . $lib . ' required but not installed';
+ return 'PHP extension ' . $lib .
+ ' required but not installed';
}
}
}
@@ -249,9 +254,11 @@ class AppConfig {
if($version['version'] === '*') {
continue;
}
- if(!version_compare($actual, $version['version'], $version['operator'])) {
- return $versionType . ' Version not satisfied: ' . $version['operator'] .
- $version['version'] . ' required but found ' . $actual . '\n';
+ $operator = $version['operator'];
+ $requiredVersion = $version['version'];
+ if(!version_compare($actual, $requiredVersion, $operator)) {
+ return $versionType . ' Version not satisfied: ' . $operator .
+ $requiredVersion . ' required but found ' . $actual . '\n';
}
}
@@ -270,7 +277,8 @@ class AppConfig {
$versions = explode(',', $versions);
foreach($versions as $version) {
- preg_match('/^(?<operator><|<=|>=|>|<>)?(?<version>.*)$/', $version, $matches);
+ preg_match('/^(?<operator><|<=|>=|>|<>)?(?<version>.*)$/', $version,
+ $matches);
if($matches['operator'] !== '') {
$required = [
'version' => $matches['version'],
diff --git a/config/config.php b/config/config.php
index 25e8a2294..44650c3ac 100644
--- a/config/config.php
+++ b/config/config.php
@@ -156,8 +156,10 @@ class Config {
$configValues = parse_ini_string($content);
if($configValues === false || count($configValues) === 0) {
- $this->logger->warning('Configuration invalid. Ignoring values.',
- $this->loggerParams);
+ $this->logger->warning(
+ 'Configuration invalid. Ignoring values.',
+ $this->loggerParams
+ );
} else {
foreach($configValues as $key => $value) {
@@ -166,8 +168,11 @@ class Config {
settype($value, $type);
$this->$key = $value;
} else {
- $this->logger->warning('Configuration value "' . $key .
- '" does not exist. Ignored value.' , $this->loggerParams);
+ $this->logger->warning(
+ 'Configuration value "' . $key .
+ '" does not exist. Ignored value.' ,
+ $this->loggerParams
+ );
}
}
@@ -178,15 +183,21 @@ class Config {
public function write($configPath) {
$ini =
- "autoPurgeMinimumInterval = " . $this->autoPurgeMinimumInterval . "\n" .
- "autoPurgeCount = " . $this->autoPurgeCount . "\n" .
- "simplePieCacheDuration = " . $this->simplePieCacheDuration . "\n" .
- "feedFetcherTimeout = " . $this->feedFetcherTimeout . "\n" .
- "useCronUpdates = " . var_export($this->useCronUpdates, true) . "\n" .
- "proxyHost = " . $this->proxyHost . "\n" .
- "proxyPort = " . $this->proxyPort . "\n" .
- "proxyUser = " . $this->proxyUser . "\n" .
- "proxyPassword = " . $this->proxyPassword;
+ 'autoPurgeMinimumInterval = ' .
+ $this->autoPurgeMinimumInterval . "\n" .
+ 'autoPurgeCount = ' .
+ $this->autoPurgeCount . "\n" .
+ 'simplePieCacheDuration = ' .
+ $this->simplePieCacheDuration . "\n" .
+ 'feedFetcherTimeout = ' .
+ $this->feedFetcherTimeout . "\n" .
+ 'useCronUpdates = ' .
+ var_export($this->useCronUpdates, true) . "\n" .
+
+ 'proxyHost = ' . $this->proxyHost . "\n" .
+ 'proxyPort = ' . $this->proxyPort . "\n" .
+ 'proxyUser = ' . $this->proxyUser . "\n" .
+ 'proxyPassword = ' . $this->proxyPassword;
;
$this->fileSystem->file_put_contents($configPath, $ini);
diff --git a/controller/admincontroller.php b/controller/admincontroller.php
index cd3ae9df4..71bcf0d29 100644
--- a/controller/admincontroller.php
+++ b/controller/admincontroller.php
@@ -35,7 +35,8 @@ class AdminController extends Controller {
// in admin/admin.php
public function index() {
$data = [
- 'autoPurgeMinimumInterval' => $this->config->getAutoPurgeMinimumInterval(),
+ 'autoPurgeMinimumInterval' =>
+ $this->config->getAutoPurgeMinimumInterval(),
'autoPurgeCount' => $this->config->getAutoPurgeCount(),
'cacheDuration' => $this->config->getSimplePieCacheDuration(),
'feedFetcherTimeout' => $this->config->getFeedFetcherTimeout(),
@@ -64,7 +65,8 @@ class AdminController extends Controller {
$this->config->write($this->configPath);
return [
- 'autoPurgeMinimumInterval' => $this->config->getAutoPurgeMinimumInterval(),
+ 'autoPurgeMinimumInterval' =>
+ $this->config->getAutoPurgeMinimumInterval(),
'autoPurgeCount' => $this->config->getAutoPurgeCount(),
'cacheDuration' => $this->config->getSimplePieCacheDuration(),
'feedFetcherTimeout' => $this->config->getFeedFetcherTimeout(),
diff --git a/controller/exportcontroller.php b/controller/exportcontroller.php
index 1d0f7086c..b1d62f015 100644
--- a/controller/exportcontroller.php
+++ b/controller/exportcontroller.php
@@ -56,7 +56,9 @@ class ExportController extends Controller {
$feeds = $this->feedService->findAll($this->userId);
$folders = $this->folderService->findAll($this->userId);
$opml = $this->opmlExporter->build($folders, $feeds)->saveXML();
- return new TextDownloadResponse($opml, 'subscriptions.opml', 'text/xml');
+ $name = 'subscriptions.opml';
+ $mimeType = 'text/xml';
+ return new TextDownloadResponse($opml, $name, $mimeType);
}
diff --git a/controller/feedapicontroller.php b/controller/feedapicontroller.php
index c75cd5879..2e48b5afe 100644
--- a/controller/feedapicontroller.php
+++ b/controller/feedapicontroller.php
@@ -66,7 +66,8 @@ class FeedApiController extends ApiController {
try {
- $result['newestItemId'] = $this->itemService->getNewestItemId($this->userId);
+ $result['newestItemId'] =
+ $this->itemService->getNewestItemId($this->userId);
// in case there are no items, ignore
} catch(ServiceNotFoundException $ex) {}
@@ -92,7 +93,8 @@ class FeedApiController extends ApiController {
$result = ['feeds' => [$feed]];
try {
- $result['newestItemId'] = $this->itemService->getNewestItemId($this->userId);
+ $result['newestItemId'] =
+ $this->itemService->getNewestItemId($this->userId);
// in case there are no items, ignore
} catch(ServiceNotFoundException $ex) {}
@@ -207,7 +209,7 @@ class FeedApiController extends ApiController {
public function update($userId, $feedId) {
try {
$this->feedService->update($feedId, $userId);
- // ignore update failure (feed could not be reachable etc, we don't care)
+ // ignore update failure
} catch(\Exception $ex) {
$this->logger->debug('Could not update feed ' . $ex->getMessage(),
$this->loggerParams);
diff --git a/controller/foldercontroller.php b/controller/foldercontroller.php
index d5ccc7c62..e5ad9a24f 100644
--- a/controller/foldercontroller.php
+++ b/controller/foldercontroller.php
@@ -148,7 +148,9 @@ class FolderController extends Controller {
* @return array
*/
public function read($folderId, $highestItemId) {
- $this->itemService->readFolder($folderId, $highestItemId, $this->userId);
+ $this->itemService->readFolder(
+ $folderId, $highestItemId, $this->userId
+ );
return ['feeds' => $this->feedService->findAll($this->userId)];
}
diff --git a/controller/itemapicontroller.php b/controller/itemapicontroller.php
index 3674d644c..187a2b6b1 100644
--- a/controller/itemapicontroller.php
+++ b/controller/itemapicontroller.php
@@ -120,7 +120,9 @@ class ItemApiController extends ApiController {
private function setStarred($isStarred, $feedId, $guidHash) {
try {
- $this->itemService->star($feedId, $guidHash, $isStarred, $this->userId);
+ $this->itemService->star(
+ $feedId, $guidHash, $isStarred, $this->userId
+ );
} catch(ServiceNotFoundException $ex){
return $this->error($ex, Http::STATUS_NOT_FOUND);
}
diff --git a/controller/itemcontroller.php b/controller/itemcontroller.php
index 89dd51d03..4aee6402a 100644
--- a/controller/itemcontroller.php
+++ b/controller/itemcontroller.php
@@ -59,8 +59,8 @@ class ItemController extends Controller {
public function index($type, $id, $limit=50, $offset=0) {
$showAll = $this->settings->getUserValue($this->userId, $this->appName,
'showAll') === '1';
- $oldestFirst = $this->settings->getUserValue($this->userId, $this->appName,
- 'oldestFirst') === '1';
+ $oldestFirst = $this->settings->getUserValue($this->userId,
+ $this->appName, 'oldestFirst') === '1';
$this->settings->setUserValue($this->userId, $this->appName,
'lastViewedFeedId', $id);
@@ -78,7 +78,8 @@ class ItemController extends Controller {
$params['newestItemId'] =
$this->itemService->getNewestItemId($this->userId);
$params['feeds'] = $this->feedService->findAll($this->userId);
- $params['starred'] = $this->itemService->starredCount($this->userId);
+ $params['starred'] =
+ $this->itemService->starredCount($this->userId);
}
$params['items'] = $this->itemService->findAll(
@@ -109,9 +110,11 @@ class ItemController extends Controller {
$params = [];
try {
- $params['newestItemId'] = $this->itemService->getNewestItemId($this->userId);
+ $params['newestItemId'] =
+ $this->itemService->getNewestItemId($this->userId);
$params['feeds'] = $this->feedService->findAll($this->userId);
- $params['starred'] = $this->itemService->starredCount($this->userId);
+ $params['starred'] =
+ $this->itemService->starredCount($this->userId);
$params['items'] = $this->itemService->findAllNew($id, $type,
$lastModified, $showAll, $this->userId);
diff --git a/controller/pagecontroller.php b/controller/pagecontroller.php
index 90f702d49..f55900a39 100644
--- a/controller/pagecontroller.php
+++ b/controller/pagecontroller.php
@@ -59,7 +59,12 @@ class PageController extends Controller {
* @NoAdminRequired
*/
public function settings() {
- $settings = ['showAll', 'compact', 'preventReadOnScroll', 'oldestFirst'];
+ $settings = [
+ 'showAll',
+ 'compact',
+ 'preventReadOnScroll',
+ 'oldestFirst'
+ ];
$result = ['language' => $this->l10n->getLanguageCode()];
@@ -80,8 +85,13 @@ class PageController extends Controller {
* @param bool $preventReadOnScroll
* @param bool $oldestFirst
*/
- public function updateSettings($showAll, $compact, $preventReadOnScroll, $oldestFirst) {
- $settings = ['showAll', 'compact', 'preventReadOnScroll', 'oldestFirst'];
+ public function updateSettings($showAll, $compact, $preventReadOnScroll,
+ $oldestFirst) {
+ $settings = ['showAll',
+ 'compact',
+ 'preventReadOnScroll',
+ 'oldestFirst'
+ ];
foreach ($settings as $setting) {
$this->settings->setUserValue($this->userId, $this->appName,
diff --git a/db/feedmapper.php b/db/feedmapper.php
index ab55c6f1b..0d00057d3 100644
--- a/db/feedmapper.php
+++ b/db/feedmapper.php
@@ -30,18 +30,19 @@ class FeedMapper extends NewsMapper {
'FROM `*PREFIX*news_feeds` `feeds` ' .
'LEFT JOIN `*PREFIX*news_items` `items` ' .
'ON `feeds`.`id` = `items`.`feed_id` ' .
- // WARNING: this is a desperate attempt at making this query work
- // because prepared statements dont work. This is a possible
- // SQL INJECTION RISK WHEN MODIFIED WITHOUT THOUGHT.
+ // WARNING: this is a desperate attempt at making this query
+ // work because prepared statements dont work. This is a
+ // POSSIBLE SQL INJECTION RISK WHEN MODIFIED WITHOUT THOUGHT.
// think twice when changing this
'AND (`items`.`status` & ' . StatusFlag::UNREAD . ') = ' .
StatusFlag::UNREAD . ' ' .
'WHERE `feeds`.`id` = ? ' .
'AND `feeds`.`user_id` = ? ' .
- 'GROUP BY `feeds`.`id`, `feeds`.`user_id`, `feeds`.`url_hash`,'.
- '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'.
- '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'.
- '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`';
+ 'GROUP BY `feeds`.`id`, `feeds`.`user_id`, `feeds`.`url_hash`, '.
+ '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`, '.
+ '`feeds`.`favicon_link`, `feeds`.`added`, ' .
+ '`feeds`.`articles_per_update`, `feeds`.`folder_id`, ' .
+ '`feeds`.`prevent_update`, `feeds`.`deleted_at`';
$params = [$id, $userId];
return $this->findEntity($sql, $params);
@@ -55,9 +56,9 @@ class FeedMapper extends NewsMapper {
'ON `feeds`.`folder_id` = `folders`.`id` ' .
'LEFT JOIN `*PREFIX*news_items` `items` ' .
'ON `feeds`.`id` = `items`.`feed_id` ' .
- // WARNING: this is a desperate attempt at making this query work
- // because prepared statements dont work. This is a possible
- // SQL INJECTION RISK WHEN MODIFIED WITHOUT THOUGHT.
+ // WARNING: this is a desperate attempt at making this query
+ // work because prepared statements dont work. This is a
+ // POSSIBLE SQL INJECTION RISK WHEN MODIFIED WITHOUT THOUGHT.
// think twice when changing this
'AND (`items`.`status` & ' . StatusFlag::UNREAD . ') = ' .
StatusFlag::UNREAD . ' ' .
@@ -68,8 +69,9 @@ class FeedMapper extends NewsMapper {
'AND `feeds`.`deleted_at` = 0 ' .
'GROUP BY `feeds`.`id`, `feeds`.`user_id`, `feeds`.`url_hash`,'.
'`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'.
- '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'.
- '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`';
+ '`feeds`.`favicon_link`, `feeds`.`added`, ' .
+ '`feeds`.`articles_per_update`, `feeds`.`folder_id`, ' .
+ '`feeds`.`prevent_update`, `feeds`.`deleted_at`';
$params = [$userId];
return $this->findEntities($sql, $params);
@@ -83,9 +85,9 @@ class FeedMapper extends NewsMapper {
'ON `feeds`.`folder_id` = `folders`.`id` ' .
'LEFT JOIN `*PREFIX*news_items` `items` ' .
'ON `feeds`.`id` = `items`.`feed_id` ' .
- // WARNING: this is a desperate attempt at making this query work
- // because prepared statements don't work. This is a possible
- // SQL INJECTION RISK WHEN MODIFIED WITHOUT THOUGHT.
+ // WARNING: this is a desperate attempt at making this query
+ // work because prepared statements dont work. This is a
+ // POSSIBLE SQL INJECTION RISK WHEN MODIFIED WITHOUT THOUGHT.
// think twice when changing this
'AND (`items`.`status` & ' . StatusFlag::UNREAD . ') = ' .
StatusFlag::UNREAD . ' ' .
@@ -95,8 +97,9 @@ class FeedMapper extends NewsMapper {
'AND `feeds`.`deleted_at` = 0 ' .
'GROUP BY `feeds`.`id`, `feeds`.`user_id`, `feeds`.`url_hash`,'.
'`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'.
- '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'.
- '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`';
+ '`feeds`.`favicon_link`, `feeds`.`added`, ' .
+ '`feeds`.`articles_per_update`, `feeds`.`folder_id`, ' .
+ '`feeds`.`prevent_update`, `feeds`.`deleted_at`';
return $this->findEntities($sql);
}
@@ -107,9 +110,9 @@ class FeedMapper extends NewsMapper {
'FROM `*PREFIX*news_feeds` `feeds` ' .
'LEFT JOIN `*PREFIX*news_items` `items` ' .
'ON `feeds`.`id` = `items`.`feed_id` ' .
- // WARNING: this is a desperate attempt at making this query work
- // because prepared statements dont work. This is a possible
- // SQL INJECTION RISK WHEN MODIFIED WITHOUT THOUGHT.
+ // WARNING: this is a desperate attempt at making this query
+ // work because prepared statements dont work. This is a
+ // POSSIBLE SQL INJECTION RISK WHEN MODIFIED WITHOUT THOUGHT.
// think twice when changing this
'AND (`items`.`status` & ' . StatusFlag::UNREAD . ') = ' .
StatusFlag::UNREAD . ' ' .
@@ -117,8 +120,9 @@ class FeedMapper extends NewsMapper {
'AND `feeds`.`user_id` = ? ' .
'GROUP BY `feeds`.`id`, `feeds`.`user_id`, `feeds`.`url_hash`,'.
'`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'.
- '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'.
- '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`';
+ '`feeds`.`favicon_link`, `feeds`.`added`, ' .
+ '`feeds`.`articles_per_update`, `feeds`.`folder_id`, ' .
+ '`feeds`.`prevent_update`, `feeds`.`deleted_at`';
$params = [$hash, $userId];
return $this->findEntity($sql, $params);
diff --git a/db/item.php b/db/item.php
index 5c353b058..8a8b19e59 100644
--- a/db/item.php
+++ b/db/item.php
@@ -209,7 +209,8 @@ class Item extends Entity implements IAPI, \JsonSerializable {
public function setBody($body) {
- // FIXME: this should not happen if the target="_blank" is already on the link
+ // FIXME: this should not happen if the target="_blank" is already
+ // on the link
parent::setBody(str_replace('<a', '<a target="_blank"', $body));
}
diff --git a/db/itemmapper.php b/db/itemmapper.php
index 5923372b9..b1763ed6a 100644
--- a/db/itemmapper.php
+++ b/db/itemmapper.php
@@ -43,7 +43,8 @@ class ItemMapper extends NewsMapper {
'ORDER BY `items`.`id` ' . $ordering;
}
- private function makeSelectQueryStatus($prependTo, $status, $oldestFirst=false) {
+ private function makeSelectQueryStatus($prependTo, $status,
+ $oldestFirst=false) {
// Hi this is Ray and you're watching Jack Ass
// Now look closely: this is how we adults handle weird bugs in our
// code: we take them variables and we cast the shit out of them
@@ -171,11 +172,13 @@ class ItemMapper extends NewsMapper {
}
- public function findAllFeed($id, $limit, $offset, $status, $oldestFirst, $userId){
+ public function findAllFeed($id, $limit, $offset, $status, $oldestFirst,
+ $userId){
$params = [$userId, $id];
$sql = 'AND `items`.`feed_id` = ? ';
if($offset !== 0){
- $sql .= 'AND `items`.`id` ' . $this->getOperator($oldestFirst) . ' ? ';
+ $sql .= 'AND `items`.`id` ' .
+ $this->getOperator($oldestFirst) . ' ? ';
$params[] = $offset;
}
$sql = $this->makeSelectQueryStatus($sql, $status, $oldestFirst);
@@ -183,11 +186,13 @@ class ItemMapper extends NewsMapper {
}
- public function findAllFolder($id, $limit, $offset, $status, $oldestFirst, $userId){
+ public function findAllFolder($id, $limit, $offset, $status, $oldestFirst,
+ $userId){
$params = [$userId, $id];
$sql = 'AND `feeds`.`folder_id` = ? ';
if($offset !== 0){
- $sql .= 'AND `items`.`id` ' . $this->getOperator($oldestFirst) . ' ? ';
+ $sql .= 'AND `items`.`id` ' .
+ $this->getOperator($oldestFirst) . ' ? ';
$params[] = $offset;
}
$sql = $this->makeSelectQueryStatus($sql, $status, $oldestFirst);
@@ -199,7 +204,8 @@ class ItemMapper extends NewsMapper {
$params = [$userId];
$sql = '';
if($offset !== 0){
- $sql .= 'AND `items`.`id` ' . $this->getOperator($oldestFirst) . ' ? ';
+ $sql .= 'AND `items`.`id` ' .
+ $this->getOperator($oldestFirst) . ' ? ';
$params[] = $offset;
}
$sql = $this->makeSelectQueryStatus($sql, $status, $oldestFirst);
@@ -262,7 +268,8 @@ class ItemMapper extends NewsMapper {
public function getNewestItemId($userId) {
- $sql = 'SELECT MAX(`items`.`id`) AS `max_id` FROM `*PREFIX*news_items` `items` '.
+ $sql = 'SELECT MAX(`items`.`id`) AS `max_id` ' .
+ 'FROM `*PREFIX*news_items` `items` '.
'JOIN `*PREFIX*news_feeds` `feeds` ' .
'ON `feeds`.`id` = `items`.`feed_id` '.
'AND `feeds`.`user_id` = ?';
diff --git a/fetcher/feedfetcher.php b/fetcher/feedfetcher.php
index 648cb90d8..c658dd36c 100644
--- a/fetcher/feedfetcher.php
+++ b/fetcher/feedfetcher.php
@@ -64,8 +64,8 @@ class FeedFetcher implements IFeedFetcher {
/**
* Fetch a feed from remote
* @param string $url remote url of the feed
- * @param boolean $getFavicon if the favicon should also be fetched, defaults
- * to true
+ * @param boolean $getFavicon if the favicon should also be fetched,
+ * defaults to true
* @throws FetcherException if simple pie fails
* @return array an array containing the new feed and its items, first
* element being the Feed and second element being an array of Items
@@ -74,9 +74,12 @@ class FeedFetcher implements IFeedFetcher {
$simplePie = $this->simplePieFactory->getCore();
$simplePie->set_feed_url($url);
$simplePie->enable_cache(true);
- $simplePie->set_useragent('ownCloud News/' .
+ $simplePie->set_useragent(
+ 'ownCloud News/' .
$this->appConfig->getConfig('version') .
- ' (+https://owncloud.org/; 1 subscriber; feed-url=' . $url . ')');
+ ' (+https://owncloud.org/; 1 subscriber; ' .
+ 'feed-url=' . $url . ')'
+ );
$simplePie->set_stupidly_fast(true); // disable simple pie sanitation
// we use htmlpurifier
$simplePie->set_timeout($this->fetchTimeout);
@@ -91,7 +94,9 @@ class FeedFetcher implements IFeedFetcher {
try {
if (!$simplePie->init()) {
- throw new \Exception('Could not initialize simple pie on feed with url ' . $url);
+ throw new \Exception(
+ 'Could not initialize simple pie on feed with url ' . $url
+ );
}
// somehow $simplePie turns into a feed after init
@@ -204,7 +209,8 @@ class FeedFetcher implements IFeedFetcher {
$feed->setAdded($this->time->getTime());
if ($getFavicon) {
- // use the favicon from the page first since most feeds use a weird image
+ // use the favicon from the page first since most feeds use a weird
+ // image
$favicon = $this->faviconFetcher->fetch($feed->getLink());
if (!$favicon) {
diff --git a/fetcher/fetcher.php b/fetcher/fetcher.php
index 4b4c09e1c..ae46d6212 100644
--- a/fetcher/fetcher.php
+++ b/fetcher/fetcher.php
@@ -34,8 +34,8 @@ class Fetcher {
/**
* Fetch a feed from remote
* @param string $url remote url of the feed
- * @param boolean $getFavicon if the favicon should also be fetched, defaults
- * to true
+ * @param boolean $getFavicon if the favicon should also be fetched,
+ * defaults to true
* @throws FetcherException if simple pie fails
* @return array an array containing the new feed and its items, first
* element being the Feed and second element being an array of Items
diff --git a/fetcher/ifeedfetcher.php b/fetcher/ifeedfetcher.php
index 8869d9292..68b1bcf64 100644
--- a/fetcher/ifeedfetcher.php
+++ b/fetcher/ifeedfetcher.php
@@ -17,8 +17,8 @@ interface IFeedFetcher {
/**
* @param string $url remote url of the feed
- * @param boolean $getFavicon if the favicon should also be fetched, defaults
- * to true
+ * @param boolean $getFavicon if the favicon should also be fetched,
+ * defaults to true
* @throws FetcherException if the fetcher encounters a problem
* @return array an array containing the new feed and its items, first
* element being the Feed and second element being an array of Items
diff --git a/http/textdownloadresponse.php b/http/textdownloadresponse.php
index 9a90e6454..ccf959b5b 100644
--- a/http/textdownloadresponse.php
+++ b/http/textdownloadresponse.php
@@ -28,7 +28,8 @@ class TextDownloadResponse extends DownloadResponse {
* contains the passed string
* @param string $content the content that should be written into the file
* @param string $filename the name that the downloaded file should have
- * @param string $contentType the mimetype that the downloaded file should have
+ * @param string $contentType the mimetype that the downloaded file should
+ * have
*/
public function __construct($content, $filename, $contentType){
parent::__construct($filename, $contentType);
diff --git a/service/feedservice.php b/service/feedservice.php
index ca3335396..872f05ef8 100644
--- a/service/feedservice.php
+++ b/service/feedservice.php
@@ -56,7 +56,8 @@ class FeedService extends Service {
$this->logger = $logger;
$this->l10n = $l10n;
$this->timeFactory = $timeFactory;
- $this->autoPurgeMinimumInterval = $config->getAutoPurgeMinimumInterval();
+ $this->autoPurgeMinimumInterval =
+ $config->getAutoPurgeMinimumInterval();
$this->enhancer = $enhancer;
$this->purifier = $purifier;
$this->feedMapper = $feedMapper;
@@ -85,7 +86,8 @@ class FeedService extends Service {
/**
* Creates a new feed
* @param string $feedUrl the url to the feed
- * @param int $folderId the folder where it should be put into, 0 for root folder
+ * @param int $folderId the folder where it should be put into, 0 for root
+ * folder
* @param string $userId for which user the feed should be created
* @param string $title if given, this is used for the opml feed title
* @throws ServiceConflictException if the feed exists already
@@ -117,8 +119,8 @@ class FeedService extends Service {
$feed = $this->feedMapper->insert($feed);
- // insert items in reverse order because the first one is usually the
- // newest item
+ // insert items in reverse order because the first one is usually
+ // the newest item
$unreadCount = 0;
for($i=count($items)-1; $i>=0; $i--){
$item = $items[$i];
@@ -146,8 +148,11 @@ class FeedService extends Service {
$this->logger->debug($ex->getMessage(), $this->loggerParams);
throw new ServiceNotFoundException(
$this->l10n->t(
- 'Can not add feed: URL does not exist, SSL Certificate can not be validated ' .
- 'or feed has invalid xml'));
+ 'Can not add feed: URL does not exist, ' .
+ 'SSL Certificate can not be validated ' .
+ 'or feed has invalid xml'
+ )
+ );
}
}
@@ -162,8 +167,10 @@ class FeedService extends Service {
try {
$this->update($feed->getId(), $feed->getUserId());
} catch(\Exception $ex){
- $this->logger->debug('Could not update feed ' . $ex->getMessage(),
- $this->loggerParams);
+ $this->logger->debug(
+ 'Could not update feed ' . $ex->getMessage(),
+ $this->loggerParams
+ );
}
}
}
@@ -194,18 +201,22 @@ class FeedService extends Service {
$this->feedMapper->update($existingFeed);
}
- // insert items in reverse order because the first one is usually
- // the newest item
+ // insert items in reverse order because the first one is
+ // usually the newest item
for($i=count($items)-1; $i>=0; $i--){
$item = $items[$i];
$item->setFeedId($existingFeed->getId());
try {
- $this->itemMapper->findByGuidHash($item->getGuidHash(), $feedId, $userId);
+ $this->itemMapper->findByGuidHash(
+ $item->getGuidHash(), $feedId, $userId
+ );
} catch(DoesNotExistException $ex){
$item = $this->enhancer->enhance($item,
$existingFeed->getLink());
- $item->setBody($this->purifier->purify($item->getBody()));
+ $item->setBody(
+ $this->purifier->purify($item->getBody())
+ );
$this->itemMapper->insert($item);
}
}
@@ -213,8 +224,11 @@ class FeedService extends Service {
} catch(FetcherException $ex){
// failed updating is not really a problem, so only log it
- $this->logger->debug('Can not update feed with url ' . $existingFeed->getUrl() .
- ': Not found or bad source', $this->loggerParams);
+ $this->logger->debug(
+ 'Can not update feed with url ' . $existingFeed->getUrl() .
+ ': Not found or bad source',
+ $this->loggerParams
+ );
$this->logger->debug($ex->getMessage(), $this->loggerParams);
}
@@ -230,7 +244,8 @@ class FeedService extends Service {
/**
* Moves a feed into a different folder
* @param int $feedId the id of the feed that should be moved
- * @param int $folderId the id of the folder where the feed should be moved to
+ * @param int $folderId the id of the folder where the feed should be moved
+ * to
* @param string $userId the name of the user whose feed should be moved
* @throws ServiceNotFoundException if the feed does not exist
*/
diff --git a/service/folderservice.php b/service/folderservice.php
index eb1e584f5..982837c92 100644
--- a/service/folderservice.php
+++ b/service/folderservice.php
@@ -34,7 +34,8 @@ class FolderService extends Service {
parent::__construct($folderMapper);
$this->l10n = $l10n;
$this->timeFactory = $timeFactory;
- $this->autoPurgeMinimumInterval = $config->getAutoPurgeMinimumInterval();
+ $this->autoPurgeMinimumInterval =
+ $config->getAutoPurgeMinimumInterval();
$this->folderMapper = $folderMapper;
}
@@ -49,7 +50,8 @@ class FolderService extends Service {
private function validateFolder($folderName, $userId){
- $existingFolders = $this->folderMapper->findByName($folderName, $userId);
+ $existingFolders =
+ $this->folderMapper->findByName($folderName, $userId);
if(count($existingFolders) > 0){
throw new ServiceConflictException(
@@ -57,7 +59,9 @@ class FolderService extends Service {
}
if(mb_strlen($folderName) === 0) {
- throw new ServiceValidationException('Folder name can not be empty');
+ throw new ServiceValidationException(
+ 'Folder name can not be empty'
+ );
}
}
@@ -66,7 +70,8 @@ class FolderService extends Service {
* Creates a new folder
* @param string $folderName the name of the folder
* @param string $userId the name of the user for whom it should be created
- * @param int $parentId the parent folder id, deprecated we don't nest folders
+ * @param int $parentId the parent folder id, deprecated we don't nest
+ * folders
* @throws ServiceConflictException if name exists already
* @throws ServiceValidationException if the folder has invalid parameters
* @return Folder the newly created folder
diff --git a/service/itemservice.php b/service/itemservice.php
index 1b94c089f..628f89206 100644
--- a/service/itemservice.php
+++ b/service/itemservice.php
@@ -106,13 +106,16 @@ class ItemService extends Service {
* Star or unstar an item
* @param int $feedId the id of the item's feed that should be starred
* @param string $guidHash the guidHash of the item that should be starred
- * @param boolean $isStarred if true the item will be marked as starred, if false unstar
+ * @param boolean $isStarred if true the item will be marked as starred,
+ * if false unstar
* @param string $userId the name of the user for security reasons
* @throws ServiceNotFoundException if the item does not exist
*/
public function star($feedId, $guidHash, $isStarred, $userId){
try {
- $item = $this->itemMapper->findByGuidHash($guidHash, $feedId, $userId);
+ $item = $this->itemMapper->findByGuidHash(
+ $guidHash, $feedId, $userId
+ );
$item->setLastModified($this->timeFactory->getTime());
if($isStarred){
@@ -130,7 +133,8 @@ class ItemService extends Service {
/**
* Read or unread an item
* @param int $itemId the id of the item that should be read
- * @param boolean $isRead if true the item will be marked as read, if false unread
+ * @param boolean $isRead if true the item will be marked as read,
+ * if false unread
* @param string $userId the name of the user for security reasons
* @throws ServiceNotFoundException if the item does not exist
*/
@@ -148,8 +152,8 @@ class ItemService extends Service {
/**
* Set all items read
- * @param int $highestItemId all items below that are marked read. This is used
- * to prevent marking items as read that the users hasn't seen yet
+ * @param int $highestItemId all items below that are marked read. This is
+ * used to prevent marking items as read that the users hasn't seen yet
* @param string $userId the name of the user
*/
public function readAll($highestItemId, $userId){
@@ -161,21 +165,23 @@ class ItemService extends Service {
/**
* Set a folder read
* @param int $folderId the id of the folder that should be marked read
- * @param int $highestItemId all items below that are marked read. This is used
- * to prevent marking items as read that the users hasn't seen yet
+ * @param int $highestItemId all items below that are marked read. This is
+ * used to prevent marking items as read that the users hasn't seen yet
* @param string $userId the name of the user
*/
public function readFolder($folderId, $highestItemId, $userId){
$time = $this->timeFactory->getTime();
- $this->itemMapper->readFolder($folderId, $highestItemId, $time, $userId);
+ $this->itemMapper->readFolder(
+ $folderId, $highestItemId, $time, $userId
+ );
}
/**
* Set a feed read
* @param int $feedId the id of the feed that should be marked read
- * @param int $highestItemId all items below that are marked read. This is used
- * to prevent marking items as read that the users hasn't seen yet
+ * @param int $highestItemId all items below that are marked read. This is
+ * used to prevent marking items as read that the users hasn't seen yet
* @param string $userId the name of the user
*/
public function readFeed($feedId, $highestItemId, $userId){
diff --git a/templates/admin.php b/templates/admin.php
index c1aa99b6f..8786e892c 100644
--- a/templates/admin.php
+++ b/templates/admin.php
@@ -27,8 +27,9 @@ style('news', 'admin');
<p>
<em>
<?php p($l->t(
- 'Minimum amount of seconds after deleted feeds and folders are ' .
- 'removed from the database; values below 60 seconds are ignored'
+ 'Minimum amount of seconds after deleted feeds and folders ' .
+ 'are removed from the database; values below 60 seconds are ' .
+ 'ignored'
)); ?></em>
</p>
<p><input type="text" name="news-auto-purge-minimum-interval"
@@ -59,7 +60,9 @@ style('news', 'admin');
</label>
</p>
<p>
- <em><?php p($l->t('How many seconds a feed should be cached')); ?></em>
+ <em>
+ <?php p($l->t('How many seconds a feed should be cached')); ?>
+ </em>
</p>
<p><input type="text" name="news-cache-duration"
value="<?php p($_['cacheDuration']); ?>"></p>
@@ -73,8 +76,8 @@ style('news', 'admin');
<p>
<em>
<?php p($l->t(
- 'Maximum number of seconds to wait for an RSS or Atom feed to ' .
- 'load; if it takes longer the update will be aborted.'
+ 'Maximum number of seconds to wait for an RSS or Atom feed ' .
+ 'to load; if it takes longer the update will be aborted.'
)); ?></em>
</p>
<p><input type="text" name="news-feed-fetcher-timeout"
diff --git a/templates/index.php b/templates/index.php
index f4dd97b7f..7fe58a4c2 100644
--- a/templates/index.php
+++ b/templates/index.php
@@ -18,18 +18,27 @@ script('news', [
<div id="app" ng-app="News" ng-cloak ng-strict-di ng-controller="AppController as App">
- <div id="global-loading" class="icon-loading" ng-show="App.loading.isLoading('global')"></div>
+ <div id="global-loading"
+ class="icon-loading"
+ ng-show="App.loading.isLoading('global')"></div>
<!-- navigation -->
- <div id="app-navigation" ng-controller="NavigationController as Navigation" ng-hide="App.loading.isLoading('global')">
- <news-title-unread-count unread-count="{{ Navigation.getUnreadCount() }}"></news-title-unread-count>
+ <div id="app-navigation"
+ ng-controller="NavigationController as Navigation"
+ ng-hide="App.loading.isLoading('global')">
+
+ <news-title-unread-count
+ unread-count="{{ Navigation.getUnreadCount() }}">
+ </news-title-unread-count>
<ul class="with-icon" data-id="0" news-droppable>
<?php print_unescaped($this->inc('part.navigation.addfeed')) ?>
<?php print_unescaped($this->inc('part.navigation.addfolder')) ?>
<?php print_unescaped($this->inc('part.navigation.unreadfeed')) ?>
<?php print_unescaped($this->inc('part.navigation.starredfeed')) ?>
- <?php print_unescaped($this->inc('part.navigation.feed', ['folderId' => '0'])) ?>
+ <?php print_unescaped($this->inc(
+ 'part.navigation.feed', ['folderId' => '0']
+ )) ?>
<?php print_unescaped($this->inc('part.navigation.folder')) ?>
</ul>
@@ -40,12 +49,17 @@ script('news', [
</div>
<!-- content -->
- <script type="text/ng-template" id="content.html"><?php print_unescaped($this->inc('part.content')) ?></script>
- <script type="text/ng-template" id="shortcuts.html"><?php print_unescaped($this->inc('part.content.shortcuts')) ?></script>
+ <script type="text/ng-template" id="content.html">
+ <?php print_unescaped($this->inc('part.content')) ?>
+ </script>
+ <script type="text/ng-template" id="shortcuts.html">
+ <?php print_unescaped($this->inc('part.content.shortcuts')) ?>
+ </script>
<div id="app-content"
ng-class="{
- 'loading-content': App.loading.isLoading('content') && !App.loading.isLoading('global'),
+ 'loading-content': App.loading.isLoading('content') &&
+ !App.loading.isLoading('global'),
'first-run': App.isFirstRun()
}"
tabindex="-1"
diff --git a/templates/part.content.firstrun.php b/templates/part.content.firstrun.php
index 17d0b22ff..a089ba729 100644
--- a/templates/part.content.firstrun.php
+++ b/templates/part.content.firstrun.php
@@ -1,7 +1,15 @@
<div id="first-run">
<div>
<div class="helper"><h1><?php p($l->t('Add a feed')) ?></h1></div>
- <div class="title"><h1><?php p($l->t('There are no feeds yet. Go ahead and add some')) ?> :)</h1></div>
- <div class="helper"><h1><?php p($l->t('Import feeds and articles')) ?></h1></div>
+ <div class="title">
+ <h1>
+ <?php
+ p($l->t('There are no feeds yet. Go ahead and add some'))
+ ?> :)
+ </h1>
+ </div>
+ <div class="helper">
+ <h1><?php p($l->t('Import feeds and articles')) ?></h1>
+ </div>
</div>
</div> \ No newline at end of file
diff --git a/templates/part.content.php b/templates/part.content.php
index 10f8d860e..beb8bd24d 100644
--- a/templates/part.content.php
+++ b/templates/part.content.php
@@ -2,13 +2,21 @@
<div news-auto-focus="#app-content"
id="articles"
- ng-class="{compact: Content.isCompactView(), 'feed-view': Content.isFeed()}">
- <div class="pull-to-refresh" ng-class="{'show-pull-to-refresh': showPullToRefresh}">
- <button ng-click="Content.refresh()"><?php p($l->t('Refresh')) ?> (r)</button>
+ ng-class="{
+ compact: Content.isCompactView(),
+ 'feed-view': Content.isFeed()
+ }">
+ <div class="pull-to-refresh" ng-class="{
+ 'show-pull-to-refresh': showPullToRefresh
+ }">
+ <button ng-click="Content.refresh()">
+ <?php p($l->t('Refresh')) ?> (r)
+ </button>
</div>
<ul>
<li class="item {{ Content.getFeed(item.feedId).cssClass }}"
- ng-repeat="item in Content.getItems() | orderBy:[Content.orderBy()] track by item.id"
+ ng-repeat="item in Content.getItems() |
+ orderBy:[Content.orderBy()] track by item.id"
ng-click="Content.markRead(item.id)"
ng-class="{read: !item.unread, open: item.show}"
data-id="{{ item.id }}">
@@ -26,22 +34,53 @@
</li>
<li class="title only-in-compact"
title="{{ item.title }}"
- ng-class="{'icon-rss': !Content.getFeed(item.feedId).faviconLink }"
- ng-style="{ backgroundImage: 'url(' + Content.getFeed(item.feedId).faviconLink + ')'}">
+ ng-class="{
+ 'icon-rss':
+ !Content.getFeed(item.feedId).faviconLink
+ }"
+ ng-style="{
+ backgroundImage:
+ 'url('
+ + Content.getFeed(item.feedId).faviconLink +
+ ')'
+ }">
<h1><a>{{ item.title }}</a></h1>
</li>
<li class="only-in-compact">
- <time class="date" title="{{ item.pubDate*1000|date:'yyyy-MM-dd HH:mm:ss' }}"
- datetime="{{ item.pubDate*1000|date:'yyyy-MM-ddTHH:mm:ssZ' }}">{{ Content.getRelativeDate(item.pubDate) }}
+ <time class="date"
+ title="{{ item.pubDate*1000 |
+ date:'yyyy-MM-dd HH:mm:ss' }}"
+ datetime="{{ item.pubDate*1000 |
+ date:'yyyy-MM-ddTHH:mm:ssZ' }}">
+ {{ Content.getRelativeDate(item.pubDate) }}
</time>
</li>
- <li ng-click="Content.toggleStar(item.id)" class="util" news-stop-propagation>
- <button class="star svg" ng-hide="item.starred" title="<?php p($l->t('Star article')); ?>"></button>
- <button class="starred svg" ng-show="item.starred" title="<?php p($l->t('Unstar article')); ?>"></button>
+ <li ng-click="Content.toggleStar(item.id)"
+ class="util"
+ news-stop-propagation>
+ <button class="star svg"
+ ng-hide="item.starred"
+ title="<?php p($l->t('Star article')); ?>">
+ </button>
+ <button class="starred svg"
+ ng-show="item.starred"
+ title="<?php p($l->t('Unstar article')); ?>">
+ </button>
</li>
- <li ng-click="Content.toggleKeepUnread(item.id)" class="util" news-stop-propagation>
- <button class="icon-toggle toggle-keep-unread" ng-hide="item.keepUnread" title="<?php p($l->t('Keep article unread')); ?>"></button>
- <button class="icon-toggle toggle-keep-unread keep-unread" ng-show="item.keepUnread" title="<?php p($l->t('Remove keep article unread')); ?>"></button>
+ <li ng-click="Content.toggleKeepUnread(item.id)"
+ class="util"
+ news-stop-propagation>
+ <button class="icon-toggle toggle-keep-unread"
+ ng-hide="item.keepUnread"
+ title="<?php p($l->t('Keep article unread')); ?>">
+ </button>
+ <button
+ class="icon-toggle toggle-keep-unread keep-unread"
+ ng-show="item.keepUnread"
+ title="<?php
+ p($l->t('Remove keep article unread'));
+ ?>">
+ </button>
</li>
</ul>
</div>
@@ -49,8 +88,13 @@
<div class="article">
<div class="heading only-in-expanded">
- <time class="date" title="{{ item.pubDate*1000|date:'yyyy-MM-dd HH:mm:ss' }}"
- datetime="{{ item.pubDate*1000|date:'yyyy-MM-ddTHH:mm:ssZ' }}">{{ Content.getRelativeDate(item.pubDate) }}</time>
+ <time class="date"
+ title="{{ item.pubDate*1000 |
+ date:'yyyy-MM-dd HH:mm:ss' }}"
+ datetime="{{ item.pubDate*1000 |
+ date:'yyyy-MM-ddTHH:mm:ssZ' }}">
+ {{ Content.getRelativeDate(item.pubDate) }}
+ </time>
<h1>
<a class="external"
target="_blank"
@@ -62,8 +106,14 @@
</div>
<div class="subtitle">
- <span class="author" ng-show="item.author"> <?php p($l->t('by')) ?> {{ item.author }}</span>
- <span class="source"><?php p($l->t('from')) ?> <a ng-href="#/items/feeds/{{ item.feedId }}/">{{ Content.getFeed(item.feedId).title }}</a></span>
+ <span class="author" ng-show="item.author">
+ <?php p($l->t('by')) ?> {{ item.author }}
+ </span>
+ <span class="source"><?php p($l->t('from')) ?>
+ <a ng-href="#/items/feeds/{{ item.feedId }}/">
+ {{ Content.getFeed(item.feedId).title }}
+ </a>
+ </span>
</div>
@@ -72,8 +122,9 @@
<news-enclosure type="{{ item.enclosureMime }}"
link="{{ item.enclosureLink }}">
<p class="enclosure-error">
- <?php p($l->t('Browser can not play media type')) ?>:
- {{ item.enclosureMime }}
+ <?php
+ p($l->t('Browser can not play media type'))
+ ?>: {{ item.enclosureMime }}
</p>
<a class="button"
ng-href="{{ item.enclosureLink | trustUrl }}"
diff --git a/templates/part.content.shortcuts.php b/templates/part.content.shortcuts.php
index e557e360b..705b380f5 100644
--- a/templates/part.content.shortcuts.php
+++ b/templates/part.content.shortcuts.php
@@ -19,11 +19,15 @@
</tr>
<tr>
<td>h</td>
- <td><?php p($l->t('Star article and jump to next one')); ?></td>
+ <td>
+ <?php p($l->t('Star article and jump to next one')); ?>
+ </td>
</tr>
<tr>
<td>u</td>
- <td><?php p($l->t('Toggle keep current article unread')); ?></td>
+ <td>
+ <?php p($l->t('Toggle keep current article unread')); ?>
+ </td>
</tr>
<tr>
<td>o</td>
@@ -31,7 +35,9 @@
</tr>
<tr>
<td>e</td>
- <td><?php p($l->t('Toggle expand article in compact view')); ?></td>
+ <td>
+ <?php p($l->t('Toggle expand article in compact view')); ?>
+ </td>
</tr>
<tr>
<td>r</td>
diff --git a/templates/part.navigation.addfeed.php b/templates/part.navigation.addfeed.php
index 5ef8e858a..386e8800e 100644
--- a/templates/part.navigation.addfeed.php
+++ b/templates/part.navigation.addfeed.php
@@ -7,7 +7,8 @@
<div class="add-new-popup" id="new-feed">
- <form ng-submit="Navigation.createFeed(Navigation.feed)" name="feedform">
+ <form ng-submit="Navigation.createFeed(Navigation.feed)"
+ name="feedform">
<fieldset ng-disabled="Navigation.addingFeed">
<input type="text"
ng-model="Navigation.feed.url"
@@ -21,7 +22,8 @@
required>
<p class="error"
- ng-show="!Navigation.addingFeed && Navigation.feedUrlExists(Navigation.feed.url)">
+ ng-show="!Navigation.addingFeed &&
+ Navigation.feedUrlExists(Navigation.feed.url)">
<?php p($l->t('Feed exists already!')); ?>
</p>
@@ -30,8 +32,10 @@
title="<?php p($l->t('Folder')); ?>"
ng-if="!Navigation.showNewFolder"
ng-model="Navigation.feed.existingFolder"
- ng-options="folder.name for folder in Navigation.getFolders() track by folder.name">
- <option value="">-- <?php p($l->t('No folder')); ?> --</option>
+ ng-options="folder.name for folder in
+ Navigation.getFolders() track by folder.name">
+ <option value=""
+ >-- <?php p($l->t('No folder')); ?> --</option>
</select>
<button type="button"
class="icon-add add-new-folder-primary"
@@ -47,7 +51,9 @@
!Navigation.addingFeed &&
!Navigation.addingFeed &&
Navigation.showNewFolder &&
- Navigation.folderNameExists(Navigation.feed.newFolder)
+ Navigation.folderNameExists(
+ Navigation.feed.newFolder
+ )
}"
placeholder="<?php p($l->t('Folder name')); ?>"
name="folderName"
@@ -57,16 +63,25 @@
ng-show="Navigation.showNewFolder"
class="icon-close add-new-folder-primary"
title="<?php p($l->t('Go back')); ?>"
- ng-click="Navigation.showNewFolder=false; Navigation.feed.newFolder=''"></button>
+ ng-click="Navigation.showNewFolder=false;
+ Navigation.feed.newFolder=''">
+ </button>
- <p class="error" ng-show="!Navigation.addingFeed && Navigation.folderNameExists(Navigation.feed.newFolder)"><?php p($l->t('Folder exists already!')); ?></p>
+ <p class="error" ng-show="!Navigation.addingFeed &&
+ Navigation.folderNameExists(Navigation.feed.newFolder)">
+ <?php p($l->t('Folder exists already!')); ?>
+ </p>
<input type="submit"
value="<?php p($l->t('Subscribe')); ?>"
class="primary"
- ng-disabled="Navigation.feedUrlExists(Navigation.feed.url) ||
- (Navigation.showNewFolder && Navigation.folderNameExists(folder.name))">
+ ng-disabled="
+ Navigation.feedUrlExists(Navigation.feed.url) ||
+ (
+ Navigation.showNewFolder &&
+ Navigation.folderNameExists(folder.name)
+ )">
</fieldset>
</form>
</div>
diff --git a/templates/part.navigation.addfolder.php b/templates/part.navigation.addfolder.php
index 2f65e9d2b..965d92159 100644
--- a/templates/part.navigation.addfolder.php
+++ b/templates/part.navigation.addfolder.php
@@ -2,7 +2,9 @@
<div class="heading icon-add">
<button
data-apps-slide-toggle="#new-folder"
- news-focus="#new-folder [name='folderName']"><?php p($l->t('New Folder'))?></button>
+ news-focus="#new-folder [name='folderName']">
+ <?php p($l->t('New Folder'))?>
+ </button>
</div>
<div class="add-new-popup" id="new-folder">
@@ -11,14 +13,20 @@
<fieldset ng-disabled="Navigation.addingFolder">
<!-- add a folder -->
<input type="text"
- ng-class="{'ng-invalid': !Navigation.addingFolder && Navigation.folderNameExists(folder.name)}"
+ ng-class="{
+ 'ng-invalid': !Navigation.addingFolder &&
+ Navigation.folderNameExists(folder.name)
+ }"
ng-model="folder.name"
placeholder="<?php p($l->t('Folder name')); ?>"
title="<?php p($l->t('Folder name')); ?>"
name="folderName"
required>
- <p class="error" ng-show="!Navigation.addingFolder && Navigation.folderNameExists(folder.name)"><?php p($l->t('Folder exists already!')); ?></p>
+ <p class="error" ng-show="!Navigation.addingFolder &&
+ Navigation.folderNameExists(folder.name)">
+ <?php p($l->t('Folder exists already!')); ?>
+ </p>
<input type="submit"
value="<?php p($l->t('Create')); ?>"
diff --git a/templates/part.navigation.feed.php b/templates/part.navigation.feed.php
index 27f54fd48..fd83576db 100644
--- a/templates/part.navigation.feed.php
+++ b/templates/part.navigation.feed.php
@@ -2,14 +2,20 @@
active: Navigation.isFeedActive(feed.id),
unread: Navigation.getFeedUnreadCount(feed.id) > 0
}"
- ng-repeat="feed in Navigation.getFeedsOfFolder(<?php p($_['folderId']); ?>) | orderBy:'id':true track by feed.url"
+ ng-repeat="feed in Navigation.getFeedsOfFolder(<?php p($_['folderId']); ?>)
+ | orderBy:'id':true track by feed.url"
ng-show="Navigation.getFeedUnreadCount(feed.id) > 0
|| Navigation.isShowAll()
|| Navigation.isFeedActive(feed.id)
|| !feed.id"
data-id="{{ feed.id }}"
class="feed with-counter with-menu"
- news-draggable-disable="{{ feed.error.length > 0 || !feed.id || feed.deleted || feed.editing}}"
+ news-draggable-disable="{{
+ feed.error.length > 0 ||
+ !feed.id ||
+ feed.deleted ||
+ feed.editing
+ }}"
news-draggable="{
stack: '> li',
zIndex: 1000,
@@ -38,7 +44,9 @@
<div ng-if="feed.deleted"
class="app-navigation-entry-deleted"
news-timeout="Navigation.deleteFeed(feed)">
- <div class="app-navigation-entry-deleted-description"><?php p($l->t('Deleted feed')); ?>: {{ feed.title }}</div>
+ <div class="app-navigation-entry-deleted-description">
+ <?php p($l->t('Deleted feed')); ?>: {{ feed.title }}
+ </div>
<button class="icon-history app-navigation-entry-deleted-button"
title="<?php p($l->t('Undo delete feed')); ?>"
ng-click="Navigation.undoDeleteFeed(feed)"></button>
@@ -64,7 +72,8 @@
<li class="app-navigation-entry-utils-counter"
ng-show="feed.id && Navigation.getFeedUnreadCount(feed.id) > 0"
title="{{ Navigation.getFeedUnreadCount(feed.id) }}">
- {{ Navigation.getFeedUnreadCount(feed.id) | unreadCountFormatter }}
+ {{ Navigation.getFeedUnreadCount(feed.id) |
+ unreadCountFormatter }}
</li>
<li class="app-navigation-entry-utils-menu-button">
<button title="<?php p($l->t('Menu')); ?>"></button>
@@ -74,15 +83,24 @@
<div class="app-navigation-entry-menu">
<ul>
- <li><button ng-click="feed.editing=true"
+ <li>
+ <button ng-click="feed.editing=true"
class="icon-rename"
- title="<?php p($l->t('Rename feed')); ?>"></button></li>
- <li><button ng-click="Navigation.reversiblyDeleteFeed(feed)"
+ title="<?php p($l->t('Rename feed')); ?>">
+ </button>
+ </li>
+ <li>
+ <button ng-click="Navigation.reversiblyDeleteFeed(feed)"
class="icon-delete"
- title="<?php p($l->t('Delete feed')); ?>"></button></li>
- <li ng-show="Navigation.getFeedUnreadCount(feed.id) > 0"><button class="icon-checkmark"
+ title="<?php p($l->t('Delete feed')); ?>">
+ </button>
+ </li>
+ <li ng-show="Navigation.getFeedUnreadCount(feed.id) > 0">
+ <button class="icon-checkmark"
ng-click="Navigation.markFeedRead(feed.id)"
- title="<?php p($l->t('Read all')); ?>"></button></li>
+ title="<?php p($l->t('Read all')); ?>">
+ </button>
+ </li>
</ul>
</div>
diff --git a/templates/part.navigation.folder.php b/templates/part.navigation.folder.php
index 4c0874f9f..20b1978ac 100644
--- a/templates/part.navigation.folder.php
+++ b/templates/part.navigation.folder.php
@@ -23,20 +23,33 @@
<div ng-if="folder.deleted"
class="app-navigation-entry-deleted"
news-timeout="Navigation.deleteFolder(folder)">
- <div class="app-navigation-entry-deleted-description"><?php p($l->t('Deleted folder')); ?>: {{ folder.name }}</div>
+ <div class="app-navigation-entry-deleted-description">
+ <?php p($l->t('Deleted folder')); ?>: {{ folder.name }}
+ </div>
<button class="icon-history app-navigation-entry-deleted-button"
title="<?php p($l->t('Undo delete folder')); ?>"
ng-click="Navigation.undoDeleteFolder(folder)"></button>
</div>
<div ng-if="folder.editing" class="app-navigation-entry-edit"
- ng-class="{'folder-rename-error': folder.renameError || (folderName != folder.name && !Navigation.renamingFolder && Navigation.folderNameExists(folderName))}">
+ ng-class="{
+ 'folder-rename-error':
+ folder.renameError ||
+ (folderName != folder.name &&
+ !Navigation.renamingFolder &&
+ Navigation.folderNameExists(folderName))
+ }">
<form ng-submit="Navigation.renameFolder(folder, folderName)">
<fieldset ng-disabled="Navigation.renamingFolder">
<input name="folderName"
type="text"
ng-init="folderName=folder.name"
- ng-class="{'ng-invalid': folderName != folder.name && !Navigation.renamingFolder && Navigation.folderNameExists(folderName)}"
+ ng-class="{
+ 'ng-invalid':
+ folderName != folder.name &&
+ !Navigation.renamingFolder &&
+ Navigation.folderNameExists(folderName)
+ }"
ng-model="folderName"
required
news-auto-focus>
@@ -45,19 +58,28 @@
ng-class="{'entry-loading': Navigation.renamingFolder}"
title="<?php p($l->t('Rename')); ?>"
class="action icon-checkmark"
- ng-disabled="folderName != folder.name && !Navigation.renamingFolder && Navigation.folderNameExists(folderName)">
+ ng-disabled="folderName != folder.name &&
+ !Navigation.renamingFolder &&
+ Navigation.folderNameExists(folderName)">
</button>
</fieldset>
- <p class="error" ng-show="folderName != folder.name && !Navigation.renamingFolder && Navigation.folderNameExists(folderName)">
+ <p class="error" ng-show="folderName != folder.name &&
+ !Navigation.renamingFolder &&
+ Navigation.folderNameExists(folderName)">
<?php p($l->t('Folder exists already!')); ?>
</p>
- <p class="error" ng-show="folder.renameError">{{ folder.renameError }}</p>
+ <p class="error" ng-show="folder.renameError">
+ {{ folder.renameError }}
+ </p>
</form>
</div>
<a ng-href="#/items/folders/{{ folder.id }}/"
class="title icon-folder"
- ng-show="!folder.editing && !folder.error && !folder.deleted && folder.id">
+ ng-show="!folder.editing &&
+ !folder.error &&
+ !folder.deleted &&
+ folder.id">
{{ folder.name }}
</a>
@@ -66,12 +88,17 @@
</a>
<div class="app-navigation-entry-utils"
- ng-show="folder.id && !folder.editing && !folder.error && !folder.deleted">
+ ng-show="folder.id &&
+ !folder.editing &&
+ !folder.error &&
+ !folder.deleted">
<ul>
<li class="app-navigation-entry-utils-counter"
- ng-show="folder.id && Navigation.getFolderUnreadCount(folder.id) > 0"
+ ng-show="folder.id &&
+ Navigation.getFolderUnreadCount(folder.id) > 0"
title="{{ Navigation.getFolderUnreadCount(folder.id) }}">
- {{ Navigation.getFolderUnreadCount(folder.id) | unreadCountFormatter }}
+ {{ Navigation.getFolderUnreadCount(folder.id) |
+ unreadCountFormatter }}
</li>
<li class="app-navigation-entry-utils-menu-button">
<button title="<?php p($l->t('Menu')); ?>"></button>
@@ -81,19 +108,30 @@
<div class="app-navigation-entry-menu">
<ul>
- <li><button ng-click="folder.editing=true"
+ <li>
+ <button ng-click="folder.editing=true"
class="icon-rename"
- title="<?php p($l->t('Rename folder')); ?>"></button></li>
- <li><button ng-click="Navigation.reversiblyDeleteFolder(folder)"
+ title="<?php p($l->t('Rename folder')); ?>">
+ </button>
+ </li>
+ <li>
+ <button ng-click="Navigation.reversiblyDeleteFolder(folder)"
class="icon-delete"
- title="<?php p($l->t('Delete folder')); ?>"></button></li>
- <li ng-show="Navigation.getFolderUnreadCount(folder.id) > 0"><button class="icon-checkmark"
+ title="<?php p($l->t('Delete folder')); ?>">
+ </button>
+ </li>
+ <li ng-show="Navigation.getFolderUnreadCount(folder.id) > 0">
+ <button class="icon-checkmark"
ng-click="Navigation.markFolderRead(folder.id)"
- title="<?php p($l->t('Read all')); ?>"></button></li>
+ title="<?php p($l->t('Read all')); ?>">
+ </button>
+ </li>
</ul>
</div>
<ul ng-hide="folder.error || folder.deleted">
- <?php print_unescaped($this->inc('part.navigation.feed', ['folderId' => 'folder.id'])); ?>
+ <?php print_unescaped(
+ $this->inc('part.navigation.feed', ['folderId' => 'folder.id'])
+ ); ?>
</ul>
<div class="error-message" ng-show="folder.error">
diff --git a/templates/part.navigation.unreadfeed.php b/templates/part.navigation.unreadfeed.php
index fc62427cd..8eae37eed 100644
--- a/templates/part.navigation.unreadfeed.php
+++ b/templates/part.navigation.unreadfeed.php
@@ -19,7 +19,11 @@
title="{{ Navigation.getUnreadCount() }}">
{{ Navigation.getUnreadCount() | unreadCountFormatter }}
</li>
- <li class="app-navigation-entry-utils-menu-button"><button ng-click="optionsId = (optionsId == 'all' ? -1 : 'all')"></button></li>
+ <li class="app-navigation-entry-utils-menu-button">
+ <button
+ ng-click="optionsId = (optionsId == 'all' ? -1 : 'all')">
+ </button>
+ </li>
</ul>
</div>
diff --git a/templates/part.settings.php b/templates/part.settings.php
index 890eb0d2b..00b7b79aa 100644
--- a/templates/part.settings.php
+++ b/templates/part.settings.php
@@ -13,28 +13,34 @@
<p ng-click="Settings.toggleSetting('compact')">
<label for="compact">
- <input type="checkbox" ng-checked="Settings.getSetting('compact')" name="compact">
+ <input type="checkbox" ng-checked="Settings.getSetting('compact')"
+ name="compact">
<?php p($l->t('Compact view')); ?>
</label>
</p>
<p ng-click="Settings.toggleSetting('showAll')">
<label for="showAll">
- <input type="checkbox" ng-checked="Settings.getSetting('showAll')" name="showAll">
+ <input type="checkbox" ng-checked="Settings.getSetting('showAll')"
+ name="showAll">
<?php p($l->t('Show all articles')); ?>
</label>
</p>
<p ng-click="Settings.toggleSetting('oldestFirst')">
<label for="oldestFirst">
- <input type="checkbox" ng-checked="Settings.getSetting('oldestFirst')" name="oldestFirst">
+ <input type="checkbox"
+ ng-checked="Settings.getSetting('oldestFirst')"
+ name="oldestFirst">
<?php p($l->t('Reverse ordering')); ?>
</label>
</p>
<p ng-click="Settings.toggleSetting('preventReadOnScroll')">
<label for="preventReadOnScroll">
- <input type="checkbox" ng-checked="Settings.getSetting('preventReadOnScroll')" name="preventReadOnScroll">
+ <input type="checkbox"
+ ng-checked="Settings.getSetting('preventReadOnScroll')"
+ name="preventReadOnScroll">
<?php p($l->t('Disable mark read through scrolling')); ?>
</label>
</p>
@@ -51,7 +57,8 @@
class="icon-upload svg button-icon-label"
news-trigger-click="#opml-upload"
ng-class="{'entry-loading': Settings.isOPMLImporting}"
- ng-disabled="Settings.isOPMLImporting || Settings.isArticlesImporting">
+ ng-disabled=
+ "Settings.isOPMLImporting || Settings.isArticlesImporting">
</button>
<a title="<?php p($l->t('Export')); ?>"
@@ -69,7 +76,9 @@
</button>
<p class="error" ng-show="Settings.opmlImportError">
- <?php p($l->t('Error when importing: file does not contain valid OPML')); ?>
+ <?php p(
+ $l->t('Error when importing: file does not contain valid OPML')
+ ); ?>
</p>
@@ -84,11 +93,13 @@
<button title="<?php p($l->t('Import')); ?>"
class="icon-upload svg button-icon-label"
ng-class="{'entry-loading': Settings.isArticlesImporting}"
- ng-disabled="Settings.isOPMLImporting || Settings.isArticlesImporting"
+ ng-disabled=
+ "Settings.isOPMLImporting || Settings.isArticlesImporting"
news-trigger-click="#article-upload">
</button>
- <a title="<?php p($l->t('Export')); ?>" class="button icon-download svg button-icon-label"
+ <a title="<?php p($l->t('Export')); ?>"
+ class="button icon-download svg button-icon-label"
href="<?php p(\OCP\Util::linkToRoute('news.export.articles')); ?>"
target="_blank"
ng-hide="App.isFirstRun()">
@@ -101,7 +112,9 @@
</button>
<p class="error" ng-show="Settings.articleImportError">
- <?php p($l->t('Error when importing: file does not contain valid JSON')); ?>
+ <?php p(
+ $l->t('Error when importing: file does not contain valid JSON')
+ ); ?>
</p>
</div>
diff --git a/tests/classloader.php b/tests/classloader.php
index c660057df..7992b1b23 100644
--- a/tests/classloader.php
+++ b/tests/classloader.php
@@ -14,20 +14,25 @@
require_once __DIR__ . '/../3rdparty/ZendXml/vendor/autoload.php';
require_once __DIR__ . '/../3rdparty/simplepie/autoloader.php';
require_once __DIR__ . '/../3rdparty/Net_URL2/Net/URL2.php';
-require_once __DIR__ . '/../../../tests/lib/appframework/db/mappertestutility.php';
+require_once
+ __DIR__ . '/../../../tests/lib/appframework/db/mappertestutility.php';
// to execute without owncloud, we need to create our own classloader
spl_autoload_register(function ($className){
if (strpos($className, 'OCA\\') === 0) {
- $path = strtolower(str_replace('\\', '/', substr($className, 3)) . '.php');
+ $path = strtolower(
+ str_replace('\\', '/', substr($className, 3)) . '.php'
+ );
$relPath = __DIR__ . '/../..' . $path;
if(file_exists($relPath)){
require_once $relPath;
}
} else if(strpos($className, 'OCP\\') === 0) {
- $path = strtolower(str_replace('\\', '/', substr($className, 3)) . '.php');
+ $path = strtolower(
+ str_replace('\\', '/', substr($className, 3)) . '.php'
+ );
$relPath = __DIR__ . '/../../../lib/public' . $path;
if(file_exists($relPath)){
diff --git a/tests/unit/articleenhancer/GlobalArticleEnhancerTest.php b/tests/unit/articleenhancer/GlobalArticleEnhancerTest.php
index 3add03eb5..79647a882 100644
--- a/tests/unit/articleenhancer/GlobalArticleEnhancerTest.php
+++ b/tests/unit/articleenhancer/GlobalArticleEnhancerTest.php
@@ -26,8 +26,12 @@ class GlobalArticleEnhancerTest extends \PHPUnit_Framework_TestCase {
public function testNoReplaceYoutubeAutoplay() {
- $body = '<iframe width="728" height="410" src="//www.youtube.com/embed/autoplay=1/AWE6UpXQoGU" frameborder="0" allowfullscreen=""></iframe>';
- $expected = '<div><iframe width="728" height="410" src="//www.youtube.com/embed/autoplay=1/AWE6UpXQoGU" frameborder="0" allowfullscreen=""></iframe></div>';
+ $body = '<iframe width="728" height="410" ' .
+ 'src="//www.youtube.com/embed/autoplay=1/AWE6UpXQoGU" ' .
+ 'frameborder="0" allowfullscreen=""></iframe>';
+ $expected = '<div><iframe width="728" height="410" ' .
+ 'src="//www.youtube.com/embed/autoplay=1/AWE6UpXQoGU" ' .
+ 'frameborder="0" allowfullscreen=""></iframe></div>';
$item = new Item();
$item->setBody($body);
@@ -37,8 +41,14 @@ class GlobalArticleEnhancerTest extends \PHPUnit_Framework_TestCase {
public function testReplaceYoutubeAutoplay() {
- $body = 'test <iframe width="728" height="410" src="//www.youtube.com/embed/AWE6UpXQoGU?tst=1&autoplay=1&abc=1" frameborder="0" allowfullscreen=""></iframe>';
- $expected = '<div>test <iframe width="728" height="410" src="//www.youtube.com/embed/AWE6UpXQoGU?tst=1&amp;autoplay=0&amp;abc=1" frameborder="0" allowfullscreen=""></iframe></div>';
+ $body = 'test <iframe width="728" height="410" ' .
+ 'src="//www.youtube.com/embed' .
+ '/AWE6UpXQoGU?tst=1&autoplay=1&abc=1" frameborder="0" ' .
+ 'allowfullscreen=""></iframe>';
+ $expected = '<div>test <iframe width="728" height="410" ' .
+ 'src="//www.youtube.com/embed' .
+ '/AWE6UpXQoGU?tst=1&amp;autoplay=0&amp;abc=1" frameborder="0" ' .
+ 'allowfullscreen=""></iframe></div>';
$item = new Item();
$item->setBody($body);
diff --git a/tests/unit/articleenhancer/XPathArticleEnhancerTest.php b/tests/unit/articleenhancer/XPathArticleEnhancerTest.php
index 0d4130e9e..00c4e7cb0 100644
--- a/tests/unit/articleenhancer/XPathArticleEnhancerTest.php
+++ b/tests/unit/articleenhancer/XPathArticleEnhancerTest.php
@@ -30,7 +30,8 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase {
protected function setUp() {
$this->timeout = 30;
- $this->fileFactory = $this->getMockBuilder('\OCA\News\Utility\SimplePieAPIFactory')
+ $this->fileFactory = $this
+ ->getMockBuilder('\OCA\News\Utility\SimplePieAPIFactory')
->disableOriginalConstructor()
->getMock();
$this->proxyHost = 'test';
@@ -56,7 +57,8 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase {
$this->testEnhancer = new XPathArticleEnhancer(
$this->fileFactory,
[
- '/explosm.net\/comics/' => '//*[@id=\'maincontent\']/div[2]/div/span',
+ '/explosm.net\/comics/' =>
+ '//*[@id=\'maincontent\']/div[2]/div/span',
'/explosm.net\/shorts/' => '//*[@id=\'maincontent\']/div/div',
'/explosm.net\/all/' => '//body/*',
'/themerepublic.net/' => '//*[@class=\'post hentry\']'
@@ -259,8 +261,12 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase {
$result = $this->testEnhancer->enhance($item);
$this->assertEquals('<div>' .
- '<a target="_blank" href="https://www.explosm.net/a/relative/url.html?a=1#b">link</a>' .
- '<a target="_blank" href="https://www.explosm.net/all/b/relative/url.html">link2</a>' .
+ '<a target="_blank" ' .
+ 'href="https://www.explosm.net/a/relative/url.html?a=1#b">' .
+ 'link</a>' .
+ '<a target="_blank" ' .
+ 'href="https://www.explosm.net/all/b/relative/url.html">' .
+ 'link2</a>' .
'<img src="https://www.explosm.net/another/relative/link.jpg">' .
'</div>', $result->getBody());
}
@@ -288,7 +294,9 @@ class XPathArticleEnhancerTest extends \PHPUnit_Framework_TestCase {
$result = $this->testEnhancer->enhance($item);
$this->assertEquals(
- '<div><img src="https://username:secret@www.explosm.net/all/relative/url.png?a=1&amp;b=2"></div>',
+ '<div><img src="' .
+ 'https://username:secret@www.explosm.net' .
+ '/all/relative/url.png?a=1&amp;b=2"></div>',
$result->getBody());
}
diff --git a/tests/unit/config/ConfigTest.php b/tests/unit/config/ConfigTest.php
index 6a2b07c71..2032c2169 100644
--- a/tests/unit/config/ConfigTest.php
+++ b/tests/unit/config/ConfigTest.php
@@ -32,7 +32,9 @@ class ConfigTest extends \PHPUnit_Framework_TestCase {
'file_exists'
]);
$this->loggerParams = ['hi'];
- $this->config = new Config($this->fileSystem, $this->logger, $this->loggerParams);
+ $this->config = new Config(
+ $this->fileSystem, $this->logger, $this->loggerParams
+ );
$this->configPath = 'config.json';
}
@@ -55,7 +57,9 @@ class ConfigTest extends \PHPUnit_Framework_TestCase {
$this->fileSystem->expects($this->once())
->method('file_get_contents')
->with($this->equalTo($this->configPath))
- ->will($this->returnValue("autoPurgeCount = 3\nuseCronUpdates = true"));
+ ->will($this->returnValue(
+ 'autoPurgeCount = 3' . "\n" . 'useCronUpdates = true')
+ );
$this->config->read($this->configPath);
@@ -68,7 +72,7 @@ class ConfigTest extends \PHPUnit_Framework_TestCase {
$this->fileSystem->expects($this->once())
->method('file_get_contents')
->with($this->equalTo($this->configPath))
- ->will($this->returnValue("autoPurgeMinimumInterval = 59"));
+ ->will($this->returnValue('autoPurgeMinimumInterval = 59'));
$this->config->read($this->configPath);
@@ -81,7 +85,9 @@ class ConfigTest extends \PHPUnit_Framework_TestCase {
$this->fileSystem->expects($this->once())
->method('file_get_contents')
->with($this->equalTo($this->configPath))
- ->will($this->returnValue("autoPurgeCount = 3\nuseCronUpdates = false"));
+ ->will($this->returnValue(
+ 'autoPurgeCount = 3' . "\n" . 'useCronUpdates = false')
+ );
$this->config->read($this->configPath);
@@ -120,20 +126,20 @@ class ConfigTest extends \PHPUnit_Framework_TestCase {
public function testWrite () {
- $json = "autoPurgeMinimumInterval = 60\n" .
- "autoPurgeCount = 3\n" .
- "simplePieCacheDuration = 1800\n" .
- "feedFetcherTimeout = 60\n" .
- "useCronUpdates = true\n" .
- "proxyHost = yo man\n" .
- "proxyPort = 12\n" .
- "proxyUser = this is a test\n".
- "proxyPassword = se";
+ $json = 'autoPurgeMinimumInterval = 60' . "\n" .
+ 'autoPurgeCount = 3' . "\n" .
+ 'simplePieCacheDuration = 1800' . "\n" .
+ 'feedFetcherTimeout = 60' . "\n" .
+ 'useCronUpdates = true' . "\n" .
+ 'proxyHost = yo man' . "\n" .
+ 'proxyPort = 12' . "\n" .
+ 'proxyUser = this is a test' . "\n".
+ 'proxyPassword = se';
$this->config->setAutoPurgeCount(3);
- $this->config->setProxyHost("yo man");
+ $this->config->setProxyHost('yo man');
$this->config->setProxyPort(12);
- $this->config->setProxyUser("this is a test");
- $this->config->setProxyPassword("se");
+ $this->config->setProxyUser('this is a test');
+ $this->config->setProxyPassword('se');
$this->fileSystem->expects($this->once())
->method('file_put_contents')
@@ -157,15 +163,15 @@ class ConfigTest extends \PHPUnit_Framework_TestCase {
$this->config->setUseCronUpdates(false);
- $json = "autoPurgeMinimumInterval = 60\n" .
- "autoPurgeCount = 200\n" .
- "simplePieCacheDuration = 1800\n" .
- "feedFetcherTimeout = 60\n" .
- "useCronUpdates = false\n" .
- "proxyHost = \n" .
- "proxyPort = 8080\n" .
- "proxyUser = \n" .
- "proxyPassword = ";
+ $json = 'autoPurgeMinimumInterval = 60' . "\n" .
+ 'autoPurgeCount = 200' . "\n" .
+ 'simplePieCacheDuration = 1800' . "\n" .
+ 'feedFetcherTimeout = 60' . "\n" .
+ 'useCronUpdates = false' . "\n" .
+ 'proxyHost = ' . "\n" .
+ 'proxyPort = 8080' . "\n" .
+ 'proxyUser = ' . "\n" .
+ 'proxyPassword = ';
$this->fileSystem->expects($this->once())
->method('file_put_contents')
@@ -177,8 +183,8 @@ class ConfigTest extends \PHPUnit_Framework_TestCase {
public function testEncodesUserAndPasswordInHTTPBasicAuth() {
- $this->config->setProxyUser("this is a test");
- $this->config->setProxyPassword("se");
+ $this->config->setProxyUser('this is a test');
+ $this->config->setProxyPassword('se');
$this->assertEquals('this is a test:se', $this->config->getProxyAuth());
}
diff --git a/tests/unit/controller/ExportControllerTest.php b/tests/unit/controller/ExportControllerTest.php
index 29760e6f4..635209041 100644
--- a/tests/unit/controller/ExportControllerTest.php
+++ b/tests/unit/controller/ExportControllerTest.php
@@ -113,7 +113,10 @@ class ExportControllerTest extends \PHPUnit_Framework_TestCase {
$return = $this->controller->articles();
$headers = $return->getHeaders();
- $this->assertEquals('attachment; filename="articles.json"', $headers ['Content-Disposition']);
+ $this->assertEquals(
+ 'attachment; filename="articles.json"',
+ $headers ['Content-Disposition']
+ );
$this->assertEquals('[{"guid":null,"url":null,"title":null,' .
'"author":null,"pubDate":null,"body":null,"enclosureMime":null,' .
diff --git a/tests/unit/controller/FeedApiControllerTest.php b/tests/unit/controller/FeedApiControllerTest.php
index d14782856..c73f49288 100644
--- a/tests/unit/controller/FeedApiControllerTest.php
+++ b/tests/unit/controller/FeedApiControllerTest.php
@@ -135,7 +135,9 @@ class FeedApiControllerTest extends \PHPUnit_Framework_TestCase {
public function testDeleteDoesNotExist() {
$this->feedService->expects($this->once())
->method('delete')
- ->will($this->throwException(new ServiceNotFoundException($this->msg)));
+ ->will($this->throwException(
+ new ServiceNotFoundException($this->msg))
+ );
$response = $this->feedAPI->delete(2);
@@ -203,7 +205,9 @@ class FeedApiControllerTest extends \PHPUnit_Framework_TestCase {
->with($this->equalTo($this->user), $this->equalTo(false));
$this->feedService->expects($this->once())
->method('create')
- ->will($this->throwException(new ServiceConflictException($this->msg)));
+ ->will(
+ $this->throwException(new ServiceConflictException($this->msg))
+ );
$response = $this->feedAPI->create('ho', 3);
@@ -216,7 +220,9 @@ class FeedApiControllerTest extends \PHPUnit_Framework_TestCase {
public function testCreateError() {
$this->feedService->expects($this->once())
->method('create')
- ->will($this->throwException(new ServiceNotFoundException($this->msg)));
+ ->will(
+ $this->throwException(new ServiceNotFoundException($this->msg))
+ );
$response = $this->feedAPI->create('ho', 3);
@@ -253,7 +259,9 @@ class FeedApiControllerTest extends \PHPUnit_Framework_TestCase {
public function testMoveDoesNotExist() {
$this->feedService->expects($this->once())
->method('move')
- ->will($this->throwException(new ServiceNotFoundException($this->msg)));
+ ->will(
+ $this->throwException(new ServiceNotFoundException($this->msg))
+ );
$response = $this->feedAPI->move(3, 4);
diff --git a/tests/unit/controller/FeedControllerTest.php b/tests/unit/controller/FeedControllerTest.php
index 34b0a847b..e7f19a2b8 100644
--- a/tests/unit/controller/FeedControllerTest.php
+++ b/tests/unit/controller/FeedControllerTest.php
@@ -43,13 +43,16 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase {
'\OCP\IConfig')
->disableOriginalConstructor()
->getMock();
- $this->itemService = $this->getMockBuilder('\OCA\News\Service\ItemService')
+ $this->itemService = $this
+ ->getMockBuilder('\OCA\News\Service\ItemService')
->disableOriginalConstructor()
->getMock();
- $this->feedService = $this->getMockBuilder('\OCA\News\Service\FeedService')
+ $this->feedService = $this
+ ->getMockBuilder('\OCA\News\Service\FeedService')
->disableOriginalConstructor()
->getMock();
- $this->folderService = $this->getMockBuilder('\OCA\News\Service\FolderService')
+ $this->folderService = $this
+ ->getMockBuilder('\OCA\News\Service\FolderService')
->disableOriginalConstructor()
->getMock();
$this->request = $this->getMockBuilder(
@@ -276,7 +279,9 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase {
$params = json_decode($response->render(), true);
$this->assertEquals($msg, $params['message']);
- $this->assertEquals($response->getStatus(), Http::STATUS_UNPROCESSABLE_ENTITY);
+ $this->assertEquals(
+ $response->getStatus(), Http::STATUS_UNPROCESSABLE_ENTITY
+ );
}
@@ -427,7 +432,7 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase {
$this->feedService->expects($this->once())
->method('importArticles')
- ->with($this->equalTo(array('json')),
+ ->with($this->equalTo(['json']),
$this->equalTo($this->user))
->will($this->returnValue($feed));
@@ -436,7 +441,7 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase {
->with($this->equalTo($this->user))
->will($this->returnValue(3));
- $response = $this->controller->import(array('json'));
+ $response = $this->controller->import(['json']);
$this->assertEquals($expected, $response);
}
@@ -445,7 +450,7 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase {
public function testImportCreatesNoAdditionalFeed() {
$this->feedService->expects($this->once())
->method('importArticles')
- ->with($this->equalTo(array('json')),
+ ->with($this->equalTo(['json']),
$this->equalTo($this->user))
->will($this->returnValue(null));
@@ -454,7 +459,7 @@ class FeedControllerTest extends \PHPUnit_Framework_TestCase {
->with($this->equalTo($this->user))
->will($this->returnValue(3));
- $response = $this->controller->import(array('json'));
+ $response = $this->controller->import(['json']);
$this->assertEquals(['starred' => 3], $response);
}
diff --git a/tests/unit/controller/FolderApiControllerTest.php b/tests/unit/controller/FolderApiControllerTest.php
index c0371661a..550cd298c 100644
--- a/tests/unit/controller/FolderApiControllerTest.php
+++ b/tests/unit/controller/FolderApiControllerTest.php
@@ -130,7 +130,9 @@ class FolderApiControllerTest extends \PHPUnit_Framework_TestCase {
$data = $response->getData();
$this->assertEquals($msg, $data['message']);
- $this->assertEquals(Http::STATUS_UNPROCESSABLE_ENTITY, $response->getStatus());
+ $this->assertEquals(
+ Http::STATUS_UNPROCESSABLE_ENTITY, $response->getStatus()
+ );
}
@@ -149,7 +151,11 @@ class FolderApiControllerTest extends \PHPUnit_Framework_TestCase {
$this->folderService->expects($this->once())
->method('delete')
- ->will($this->throwException(new ServiceNotFoundException($this->msg)));
+ ->will(
+ $this->throwException(
+ new ServiceNotFoundException($this->msg)
+ )
+ );
$response = $this->folderAPI->delete($folderId);
@@ -178,7 +184,11 @@ class FolderApiControllerTest extends \PHPUnit_Framework_TestCase {
$this->folderService->expects($this->once())
->method('rename')
- ->will($this->throwException(new ServiceNotFoundException($this->msg)));
+ ->will(
+ $this->throwException(
+ new ServiceNotFoundException($this->msg)
+ )
+ );
$response = $this->folderAPI->update($folderId, $folderName);
@@ -194,7 +204,11 @@ class FolderApiControllerTest extends \PHPUnit_Framework_TestCase {
$this->folderService->expects($this->once())
->method('rename')
- ->will($this->throwException(new ServiceConflictException($this->msg)));
+ ->will(
+ $this->throwException(
+ new ServiceConflictException($this->msg)
+ )
+ );
$response = $this->folderAPI->update($folderId, $folderName);
@@ -210,13 +224,19 @@ class FolderApiControllerTest extends \PHPUnit_Framework_TestCase {
$this->folderService->expects($this->once())
->method('rename')
- ->will($this->throwException(new ServiceValidationException($this->msg)));
+ ->will(
+ $this->throwException(
+ new ServiceValidationException($this->msg)
+ )
+ );
$response = $this->folderAPI->update($folderId, $folderName);
$data = $response->getData();
$this->assertEquals($this->msg, $data['message']);
- $this->assertEquals(Http::STATUS_UNPROCESSABLE_ENTITY, $response->getStatus());
+ $this->assertEquals(
+ Http::STATUS_UNPROCESSABLE_ENTITY, $response->getStatus()
+ );
}
diff --git a/tests/unit/controller/FolderControllerTest.php b/tests/unit/controller/FolderControllerTest.php
index b06c97c79..5a5daff3d 100644
--- a/tests/unit/controller/FolderControllerTest.php
+++ b/tests/unit/controller/FolderControllerTest.php
@@ -91,7 +91,9 @@ class FolderControllerTest extends \PHPUnit_Framework_TestCase {
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);
@@ -144,7 +146,8 @@ 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']);
}
@@ -217,7 +220,8 @@ class FolderControllerTest extends \PHPUnit_Framework_TestCase {
$response = $this->controller->rename('tech', 4);
$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']);
}
@@ -285,7 +289,9 @@ class FolderControllerTest extends \PHPUnit_Framework_TestCase {
public function testRestoreDoesNotExist(){
$this->folderService->expects($this->once())
->method('unmarkDeleted')
- ->will($this->throwException(new ServiceNotFoundException($this->msg)));
+ ->will(
+ $this->throwException(new ServiceNotFoundException($this->msg))
+ );
$response = $this->controller->restore(5);
diff --git a/tests/unit/controller/ItemApiControllerTest.php b/tests/unit/controller/ItemApiControllerTest.php
index 12b9d3225..8ab35010a 100644
--- a/tests/unit/controller/ItemApiControllerTest.php
+++ b/tests/unit/controller/ItemApiControllerTest.php
@@ -135,7 +135,9 @@ class ItemApiControllerTest extends \PHPUnit_Framework_TestCase {
public function testReadDoesNotExist() {
$this->itemService->expects($this->once())
->method('read')
- ->will($this->throwException(new ServiceNotFoundException($this->msg)));
+ ->will($this->throwException(
+ new ServiceNotFoundException($this->msg))
+ );
$response = $this->itemAPI->read(2);
@@ -161,7 +163,9 @@ class ItemApiControllerTest extends \PHPUnit_Framework_TestCase {
public function testUnreadDoesNotExist() {
$this->itemService->expects($this->once())
->method('read')
- ->will($this->throwException(new ServiceNotFoundException($this->msg)));
+ ->will($this->throwException(
+ new ServiceNotFoundException($this->msg))
+ );
$response = $this->itemAPI->unread(2);
@@ -188,7 +192,9 @@ class ItemApiControllerTest extends \PHPUnit_Framework_TestCase {
public function testStarDoesNotExist() {
$this->itemService->expects($this->once())
->method('star')
- ->will($this->throwException(new ServiceNotFoundException($this->msg)));
+ ->will($this->throwException(
+ new ServiceNotFoundException($this->msg))
+ );
$response = $this->itemAPI->star(2, 'test');
@@ -215,7 +221,9 @@ class ItemApiControllerTest extends \PHPUnit_Framework_TestCase {
public function testUnstarDoesNotExist() {
$this->itemService->expects($this->once())
->method('star')
- ->will($this->throwException(new ServiceNotFoundException($this->msg)));
+ ->will($this->throwException(
+ new ServiceNotFoundException($this->msg))
+ );
$response = $this->itemAPI->unstar(2, 'test');
diff --git a/tests/unit/controller/ItemControllerTest.php b/tests/unit/controller/ItemControllerTest.php
index fd0904ef7..88e49c690 100644
--- a/tests/unit/controller/ItemControllerTest.php
+++ b/tests/unit/controller/ItemControllerTest.php
@@ -134,7 +134,7 @@ class ItemControllerTest extends \PHPUnit_Framework_TestCase {
$this->itemService->expects($this->once())
->method('star')
- ->will($this->throwException(new ServiceNotFoundException($msg)));;
+ ->will($this->throwException(new ServiceNotFoundException($msg)));
$response = $this->controller->star(4, 'test', false);
$params = json_decode($response->render(), true);
diff --git a/tests/unit/controller/PageControllerTest.php b/tests/unit/controller/PageControllerTest.php
index 60ae8c66b..48af6860f 100644
--- a/tests/unit/controller/PageControllerTest.php
+++ b/tests/unit/controller/PageControllerTest.php
@@ -159,9 +159,13 @@ class PageControllerTest extends \PHPUnit_Framework_TestCase {
$result = $this->controller->manifest();
$this->assertEquals($this->configData['name'], $result['name']);
$this->assertEquals('web', $result['type']);
- $this->assertEquals($this->configData['description'], $result['description']);
+ $this->assertEquals(
+ $this->configData['description'], $result['description']
+ );
$this->assertEquals('de-DE', $result['default_locale']);
- $this->assertEquals($this->configData['homepage'], $result['developer']['url']);
+ $this->assertEquals(
+ $this->configData['homepage'], $result['developer']['url']
+ );
$this->assertEquals('john, test', $result['developer']['name']);
}
diff --git a/tests/unit/controller/UtilityApiControllerTest.php b/tests/unit/controller/UtilityApiControllerTest.php
index efff559d8..f4219fddf 100644
--- a/tests/unit/controller/UtilityApiControllerTest.php
+++ b/tests/unit/controller/UtilityApiControllerTest.php
@@ -36,8 +36,9 @@ class UtilityApiControllerTest extends \PHPUnit_Framework_TestCase {
'\OCA\News\Utility\Updater')
->disableOriginalConstructor()
->getMock();
- $this->newsAPI = new UtilityApiController($this->appName, $this->request,
- $this->updater, $this->settings);
+ $this->newsAPI = new UtilityApiController(
+ $this->appName, $this->request, $this->updater, $this->settings
+ );
}
diff --git a/tests/unit/db/FeedMapperTest.php b/tests/unit/db/FeedMapperTest.php
index a1a570b87..9bbce1ab0 100644
--- a/tests/unit/db/FeedMapperTest.php
+++ b/tests/unit/db/FeedMapperTest.php
@@ -47,10 +47,12 @@ class FeedMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
StatusFlag::UNREAD . ' ' .
'WHERE `feeds`.`id` = ? ' .
'AND `feeds`.`user_id` = ? ' .
- 'GROUP BY `feeds`.`id`, `feeds`.`user_id`, `feeds`.`url_hash`,'.
- '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'.
- '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'.
- '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`';
+ 'GROUP BY `feeds`.`id`, `feeds`.`user_id`, ' .
+ '`feeds`.`url_hash`, '.
+ '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`, '.
+ '`feeds`.`favicon_link`, `feeds`.`added`, ' .
+ '`feeds`.`articles_per_update`, `feeds`.`folder_id`, ' .
+ '`feeds`.`prevent_update`, `feeds`.`deleted_at`';
$params = [$id, $userId];
$this->setMapperResult($sql, $params, $rows);
@@ -71,14 +73,18 @@ class FeedMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
StatusFlag::UNREAD . ' ' .
'WHERE `feeds`.`id` = ? ' .
'AND `feeds`.`user_id` = ? ' .
- 'GROUP BY `feeds`.`id`, `feeds`.`user_id`, `feeds`.`url_hash`,'.
- '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'.
- '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'.
- '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`';
+ 'GROUP BY `feeds`.`id`, `feeds`.`user_id`, ' .
+ '`feeds`.`url_hash`, '.
+ '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`, '.
+ '`feeds`.`favicon_link`, `feeds`.`added`, ' .
+ '`feeds`.`articles_per_update`, `feeds`.`folder_id`, ' .
+ '`feeds`.`prevent_update`, `feeds`.`deleted_at`';
$params = [$id, $userId];
$this->setMapperResult($sql, $params);
- $this->setExpectedException('\OCP\AppFramework\Db\DoesNotExistException');
+ $this->setExpectedException(
+ '\OCP\AppFramework\Db\DoesNotExistException'
+ );
$this->mapper->find($id, $userId);
}
@@ -98,14 +104,18 @@ class FeedMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
StatusFlag::UNREAD . ' ' .
'WHERE `feeds`.`id` = ? ' .
'AND `feeds`.`user_id` = ? ' .
- 'GROUP BY `feeds`.`id`, `feeds`.`user_id`, `feeds`.`url_hash`,'.
- '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'.
- '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'.
- '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`';
+ 'GROUP BY `feeds`.`id`, `feeds`.`user_id`, ' .
+ '`feeds`.`url_hash`, '.
+ '`feeds`.`url`, `feeds`.`title`, `feeds`.`link`, '.
+ '`feeds`.`favicon_link`, `feeds`.`added`, ' .
+ '`feeds`.`articles_per_update`, `feeds`.`folder_id`, ' .
+ '`feeds`.`prevent_update`, `feeds`.`deleted_at`';
$params = [$id, $userId];
$this->setMapperResult($sql, $params, $rows);
- $this->setExpectedException('\OCP\AppFramework\Db\MultipleObjectsReturnedException');
+ $this->setExpectedException(
+ '\OCP\AppFramework\Db\MultipleObjectsReturnedException'
+ );
$this->mapper->find($id, $userId);
}
@@ -121,10 +131,6 @@ class FeedMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
'ON `feeds`.`folder_id` = `folders`.`id` ' .
'LEFT JOIN `*PREFIX*news_items` `items` ' .
'ON `feeds`.`id` = `items`.`feed_id` ' .
- // WARNING: this is a desperate attempt at making this query work
- // because prepared statements dont work. This is a possible
- // SQL INJECTION RISK WHEN MODIFIED WITHOUT THOUGHT.
- // think twice when changing this
'AND (`items`.`status` & ' . StatusFlag::UNREAD . ') = ' .
StatusFlag::UNREAD . ' ' .
'WHERE (`feeds`.`folder_id` = 0 ' .
@@ -133,8 +139,9 @@ class FeedMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
'AND `feeds`.`deleted_at` = 0 ' .
'GROUP BY `feeds`.`id`, `feeds`.`user_id`, `feeds`.`url_hash`,'.
'`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'.
- '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'.
- '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`';
+ '`feeds`.`favicon_link`, `feeds`.`added`, ' .
+ '`feeds`.`articles_per_update`, `feeds`.`folder_id`, ' .
+ '`feeds`.`prevent_update`, `feeds`.`deleted_at`';
$this->setMapperResult($sql, [], $rows);
@@ -155,10 +162,6 @@ class FeedMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
'ON `feeds`.`folder_id` = `folders`.`id` ' .
'LEFT JOIN `*PREFIX*news_items` `items` ' .
'ON `feeds`.`id` = `items`.`feed_id` ' .
- // WARNING: this is a desperate attempt at making this query work
- // because prepared statements dont work. This is a possible
- // SQL INJECTION RISK WHEN MODIFIED WITHOUT THOUGHT.
- // think twice when changing this
'AND (`items`.`status` & ' . StatusFlag::UNREAD . ') = ' .
StatusFlag::UNREAD . ' ' .
'WHERE `feeds`.`user_id` = ? ' .
@@ -168,8 +171,9 @@ class FeedMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
'AND `feeds`.`deleted_at` = 0 ' .
'GROUP BY `feeds`.`id`, `feeds`.`user_id`, `feeds`.`url_hash`,'.
'`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'.
- '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'.
- '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`';
+ '`feeds`.`favicon_link`, `feeds`.`added`, ' .
+ '`feeds`.`articles_per_update`, `feeds`.`folder_id`, ' .
+ '`feeds`.`prevent_update`, `feeds`.`deleted_at`';
$this->setMapperResult($sql, [$userId], $rows);
$result = $this->mapper->findAllFromUser($userId);
@@ -190,8 +194,9 @@ class FeedMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
'AND `feeds`.`user_id` = ? ' .
'GROUP BY `feeds`.`id`, `feeds`.`user_id`, `feeds`.`url_hash`,'.
'`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'.
- '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'.
- '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`';
+ '`feeds`.`favicon_link`, `feeds`.`added`, ' .
+ '`feeds`.`articles_per_update`, `feeds`.`folder_id`, ' .
+ '`feeds`.`prevent_update`, `feeds`.`deleted_at`';
$this->setMapperResult($sql, [$urlHash, $this->user], $row);
$result = $this->mapper->findByUrlHash($urlHash, $this->user);
@@ -211,11 +216,14 @@ class FeedMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
'AND `feeds`.`user_id` = ? ' .
'GROUP BY `feeds`.`id`, `feeds`.`user_id`, `feeds`.`url_hash`,'.
'`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'.
- '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'.
- '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`';
+ '`feeds`.`favicon_link`, `feeds`.`added`, ' .
+ '`feeds`.`articles_per_update`, `feeds`.`folder_id`, ' .
+ '`feeds`.`prevent_update`, `feeds`.`deleted_at`';
$this->setMapperResult($sql, [$urlHash, $this->user]);
- $this->setExpectedException('\OCP\AppFramework\Db\DoesNotExistException');
+ $this->setExpectedException(
+ '\OCP\AppFramework\Db\DoesNotExistException'
+ );
$this->mapper->findByUrlHash($urlHash, $this->user);
}
@@ -236,11 +244,14 @@ class FeedMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
'AND `feeds`.`user_id` = ? ' .
'GROUP BY `feeds`.`id`, `feeds`.`user_id`, `feeds`.`url_hash`,'.
'`feeds`.`url`, `feeds`.`title`, `feeds`.`link`,'.
- '`feeds`.`favicon_link`, `feeds`.`added`, `feeds`.`articles_per_update`,'.
- '`feeds`.`folder_id`, `feeds`.`prevent_update`, `feeds`.`deleted_at`';
+ '`feeds`.`favicon_link`, `feeds`.`added`, ' .
+ '`feeds`.`articles_per_update`, `feeds`.`folder_id`, ' .
+ '`feeds`.`prevent_update`, `feeds`.`deleted_at`';
$this->setMapperResult($sql, [$urlHash, $this->user], $rows);
- $this->setExpectedException('\OCP\AppFramework\Db\MultipleObjectsReturnedException');
+ $this->setExpectedException(
+ '\OCP\AppFramework\Db\MultipleObjectsReturnedException'
+ );
$this->mapper->findByUrlHash($urlHash, $this->user);
}
diff --git a/tests/unit/db/FolderMapperTest.php b/tests/unit/db/FolderMapperTest.php
index 1078d205f..87f9e617c 100644
--- a/tests/unit/db/FolderMapperTest.php
+++ b/tests/unit/db/FolderMapperTest.php
@@ -63,7 +63,9 @@ class FolderMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
$this->setMapperResult($sql, [$id, $userId]);
- $this->setExpectedException('\OCP\AppFramework\Db\DoesNotExistException');
+ $this->setExpectedException(
+ '\OCP\AppFramework\Db\DoesNotExistException'
+ );
$this->folderMapper->find($id, $userId);
}
@@ -78,7 +80,9 @@ class FolderMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
$this->setMapperResult($sql, [$id, $userId], $rows);
- $this->setExpectedException('\OCP\AppFramework\Db\MultipleObjectsReturnedException');
+ $this->setExpectedException(
+ '\OCP\AppFramework\Db\MultipleObjectsReturnedException'
+ );
$this->folderMapper->find($id, $userId);
}
@@ -156,7 +160,9 @@ class FolderMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
'AND `deleted_at` < ? ' .
'AND `user_id` = ?';
$this->setMapperResult($sql, [$deleteOlderThan, $this->user], $rows);
- $result = $this->folderMapper->getToDelete($deleteOlderThan, $this->user);
+ $result = $this->folderMapper->getToDelete(
+ $deleteOlderThan, $this->user
+ );
$this->assertEquals($this->folders, $result);
}
diff --git a/tests/unit/db/ItemMapperTest.php b/tests/unit/db/ItemMapperTest.php
index 46ab2165a..2f6b68c1c 100644
--- a/tests/unit/db/ItemMapperTest.php
+++ b/tests/unit/db/ItemMapperTest.php
@@ -35,23 +35,23 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
$item1 = new Item();
$item2 = new Item();
- $this->items = array(
+ $this->items = [
$item1,
$item2
- );
+ ];
$this->userId = 'john';
$this->id = 3;
$this->folderId = 2;
- $this->row = array(
- array('id' => $this->items[0]->getId()),
- );
+ $this->row = [
+ ['id' => $this->items[0]->getId()],
+ ];
- $this->rows = array(
- array('id' => $this->items[0]->getId()),
- array('id' => $this->items[1]->getId())
- );
+ $this->rows = [
+ ['id' => $this->items[0]->getId()],
+ ['id' => $this->items[1]->getId()]
+ ];
$this->user = 'john';
$this->limit = 10;
@@ -98,7 +98,9 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
public function testFind(){
$sql = $this->makeSelectQuery('AND `items`.`id` = ? ');
- $this->setMapperResult($sql, array($this->userId, $this->id), $this->row);
+ $this->setMapperResult(
+ $sql, [$this->userId, $this->id], $this->row
+ );
$result = $this->mapper->find($this->id, $this->userId);
$this->assertEquals($this->items[0], $result);
@@ -107,9 +109,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
public function testGetStarredCount(){
$userId = 'john';
- $row = array(
- array('size' => 9)
- );
+ $row = [['size' => 9]];
$sql = 'SELECT COUNT(*) AS size FROM `*PREFIX*news_items` `items` '.
'JOIN `*PREFIX*news_feeds` `feeds` ' .
'ON `feeds`.`id` = `items`.`feed_id` '.
@@ -122,7 +122,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
'WHERE `feeds`.`folder_id` = 0 ' .
'OR `folders`.`deleted_at` = 0';
- $this->setMapperResult($sql, array($userId), $row);
+ $this->setMapperResult($sql, [$userId], $row);
$result = $this->mapper->starredCount($userId);
$this->assertEquals($row[0]['size'], $result);
@@ -138,7 +138,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
'WHERE `user_id` = ? ' .
') '.
'AND `id` <= ?';
- $params = array(~StatusFlag::UNREAD, $this->updatedSince, $this->user, 3);
+ $params = [~StatusFlag::UNREAD, $this->updatedSince, $this->user, 3];
$this->setMapperResult($sql, $params);
$this->mapper->readAll(3, $this->updatedSince, $this->user);
}
@@ -154,7 +154,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
'AND `user_id` = ? ' .
') '.
'AND `id` <= ?';
- $params = array(~StatusFlag::UNREAD, $this->updatedSince, 3, $this->user, 6);
+ $params = [~StatusFlag::UNREAD, $this->updatedSince, 3, $this->user, 6];
$this->setMapperResult($sql, $params);
$this->mapper->readFolder(3, 6, $this->updatedSince, $this->user);
}
@@ -170,8 +170,9 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
'SELECT * FROM `*PREFIX*news_feeds` ' .
'WHERE `user_id` = ? ' .
'AND `id` = ? ) ';
- $params = array(~StatusFlag::UNREAD, $this->updatedSince, 3, 6,
- $this->user, 3);
+ $params = [
+ ~StatusFlag::UNREAD, $this->updatedSince, 3, 6, $this->user, 3
+ ];
$this->setMapperResult($sql, $params);
$this->mapper->readFeed(3, 6, $this->updatedSince, $this->user);
}
@@ -180,7 +181,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
public function testFindAllNew(){
$sql = 'AND `items`.`last_modified` >= ? ';
$sql = $this->makeSelectQueryStatus($sql, $this->status);
- $params = array($this->user, $this->updatedSince);
+ $params = [$this->user, $this->updatedSince];
$this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAllNew($this->updatedSince,
@@ -195,10 +196,10 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
'AND `items`.`last_modified` >= ? ';
$sql = $this->makeSelectQueryStatus($sql, $this->status);
- $params = array($this->user, $this->id, $this->updatedSince);
+ $params = [$this->user, $this->id, $this->updatedSince];
$this->setMapperResult($sql, $params, $this->rows);
- $result = $this->mapper->findAllNewFolder($this->id, $this->updatedSince,
- $this->status, $this->user);
+ $result = $this->mapper->findAllNewFolder($this->id,
+ $this->updatedSince, $this->status, $this->user);
$this->assertEquals($this->items, $result);
}
@@ -208,7 +209,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
$sql = 'AND `items`.`feed_id` = ? ' .
'AND `items`.`last_modified` >= ? ';
$sql = $this->makeSelectQueryStatus($sql, $this->status);
- $params = array($this->user, $this->id, $this->updatedSince);
+ $params = [$this->user, $this->id, $this->updatedSince];
$this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAllNewFeed($this->id, $this->updatedSince,
@@ -222,7 +223,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
$status = StatusFlag::UNREAD | StatusFlag::STARRED;
$sql = 'AND ((`items`.`status` & ' . $status . ') > 0) ';
$sql = $this->makeSelectQuery($sql);
- $params = array($this->user);
+ $params = [$this->user];
$this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAllUnreadOrStarred($this->user);
@@ -234,7 +235,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
$sql = 'AND `items`.`feed_id` = ? ' .
'AND `items`.`id` < ? ';
$sql = $this->makeSelectQueryStatus($sql, $this->status);
- $params = array($this->user, $this->id, $this->offset);
+ $params = [$this->user, $this->id, $this->offset];
$this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAllFeed($this->id, $this->limit,
$this->offset, $this->status, false, $this->user);
@@ -247,7 +248,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
$sql = 'AND `items`.`feed_id` = ? ' .
'AND `items`.`id` > ? ';
$sql = $this->makeSelectQueryStatus($sql, $this->status, true);
- $params = array($this->user, $this->id, $this->offset);
+ $params = [$this->user, $this->id, $this->offset];
$this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAllFeed($this->id, $this->limit,
$this->offset, $this->status, true, $this->user);
@@ -259,7 +260,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
public function testFindAllFeedOffsetZero(){
$sql = 'AND `items`.`feed_id` = ? ';
$sql = $this->makeSelectQueryStatus($sql, $this->status);
- $params = array($this->user, $this->id);
+ $params = [$this->user, $this->id];
$this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAllFeed($this->id, $this->limit,
0, $this->status, false, $this->user);
@@ -272,8 +273,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
$sql = 'AND `feeds`.`folder_id` = ? ' .
'AND `items`.`id` < ? ';
$sql = $this->makeSelectQueryStatus($sql, $this->status);
- $params = array($this->user, $this->id,
- $this->offset);
+ $params = [$this->user, $this->id, $this->offset];
$this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAllFolder($this->id, $this->limit,
$this->offset, $this->status, false, $this->user);
@@ -286,8 +286,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
$sql = 'AND `feeds`.`folder_id` = ? ' .
'AND `items`.`id` > ? ';
$sql = $this->makeSelectQueryStatus($sql, $this->status, true);
- $params = array($this->user, $this->id,
- $this->offset);
+ $params = [$this->user, $this->id, $this->offset];
$this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAllFolder($this->id, $this->limit,
$this->offset, $this->status, true, $this->user);
@@ -299,7 +298,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
public function testFindAllFolderOffsetZero(){
$sql = 'AND `feeds`.`folder_id` = ? ';
$sql = $this->makeSelectQueryStatus($sql, $this->status);
- $params = array($this->user, $this->id);
+ $params = [$this->user, $this->id];
$this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAllFolder($this->id, $this->limit,
0, $this->status, false, $this->user);
@@ -311,7 +310,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
public function testFindAll(){
$sql = 'AND `items`.`id` < ? ';
$sql = $this->makeSelectQueryStatus($sql, $this->status);
- $params = array($this->user, $this->offset);
+ $params = [$this->user, $this->offset];
$this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAll($this->limit,
$this->offset, $this->status, false, $this->user);
@@ -323,7 +322,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
public function testFindAllOldestFirst(){
$sql = 'AND `items`.`id` > ? ';
$sql = $this->makeSelectQueryStatus($sql, $this->status, true);
- $params = array($this->user, $this->offset);
+ $params = [$this->user, $this->offset];
$this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAll($this->limit,
$this->offset, $this->status, true, $this->user);
@@ -334,7 +333,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
public function testFindAllOffsetZero(){
$sql = $this->makeSelectQueryStatus('', $this->status);
- $params = array($this->user);
+ $params = [$this->user];
$this->setMapperResult($sql, $params, $this->rows);
$result = $this->mapper->findAll($this->limit,
0, $this->status, false, $this->user);
@@ -352,14 +351,15 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
'AND `items`.`guid_hash` = ? ' .
'AND `feeds`.`id` = ? ');
- $this->setMapperResult($sql, array($this->userId, $hash, $feedId), $this->row);
+ $this->setMapperResult(
+ $sql, [$this->userId, $hash, $feedId], $this->row);
$result = $this->mapper->findByGuidHash($hash, $feedId, $this->userId);
$this->assertEquals($this->items[0], $result);
}
- public function testDeleteReadOlderThanThresholdDoesNotDeleteBelowThreshold(){
+ public function testDeleteReadOlderThanThresholdDoesNotDelete(){
$status = StatusFlag::STARRED | StatusFlag::UNREAD;
$sql = 'SELECT COUNT(*) - `feeds`.`articles_per_update` AS `size`, ' .
'`items`.`feed_id` AS `feed_id` ' .
@@ -371,8 +371,8 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
'HAVING COUNT(*) > ?';
$threshold = 10;
- $rows = array(array('feed_id' => 30, 'size' => 9));
- $params = array($status, $threshold);
+ $rows = [['feed_id' => 30, 'size' => 9]];
+ $params = [$status, $threshold];
$this->setMapperResult($sql, $params, $rows);
$this->mapper->deleteReadOlderThanThreshold($threshold);
@@ -393,18 +393,18 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
'WHERE NOT ((`items`.`status` & ?) > 0) ' .
'GROUP BY `items`.`feed_id`, `feeds`.`articles_per_update` ' .
'HAVING COUNT(*) > ?';
- $params1 = array($status, $threshold);
+ $params1 = [$status, $threshold];
- $row = array('feed_id' => 30, 'size' => 11);
+ $row = ['feed_id' => 30, 'size' => 11];
$sql2 = 'DELETE FROM `*PREFIX*news_items` ' .
'WHERE NOT ((`status` & ?) > 0) ' .
'AND `feed_id` = ? ' .
'ORDER BY `id` ASC';
- $params2 = array($status, 30);
+ $params2 = [$status, 30];
- $this->setMapperResult($sql1, $params1, array($row));
+ $this->setMapperResult($sql1, $params1, [$row]);
$this->setMapperResult($sql2, $params2);
$this->mapper->deleteReadOlderThanThreshold($threshold);
@@ -412,12 +412,13 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
public function testGetNewestItem() {
- $sql = 'SELECT MAX(`items`.`id`) AS `max_id` FROM `*PREFIX*news_items` `items` '.
+ $sql = 'SELECT MAX(`items`.`id`) AS `max_id` ' .
+ 'FROM `*PREFIX*news_items` `items` '.
'JOIN `*PREFIX*news_feeds` `feeds` ' .
'ON `feeds`.`id` = `items`.`feed_id` '.
'AND `feeds`.`user_id` = ?';
- $params = array($this->user);
- $rows = array(array('max_id' => 3));
+ $params = [$this->user];
+ $rows = [['max_id' => 3]];
$this->setMapperResult($sql, $params, $rows);
@@ -427,15 +428,18 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
public function testGetNewestItemIdNotFound() {
- $sql = 'SELECT MAX(`items`.`id`) AS `max_id` FROM `*PREFIX*news_items` `items` '.
+ $sql = 'SELECT MAX(`items`.`id`) AS `max_id` ' .
+ 'FROM `*PREFIX*news_items` `items` '.
'JOIN `*PREFIX*news_feeds` `feeds` ' .
'ON `feeds`.`id` = `items`.`feed_id` '.
'AND `feeds`.`user_id` = ?';
- $params = array($this->user);
- $rows = array();
+ $params = [$this->user];
+ $rows = [];
$this->setMapperResult($sql, $params, $rows);
- $this->setExpectedException('\OCP\AppFramework\Db\DoesNotExistException');
+ $this->setExpectedException(
+ '\OCP\AppFramework\Db\DoesNotExistException'
+ );
$this->mapper->getNewestItemId($this->user);
}
@@ -449,7 +453,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
'WHERE `feeds`.`user_id` = ?' .
')';
- $this->setMapperResult($sql, array($userId));
+ $this->setMapperResult($sql, [$userId]);
$this->mapper->deleteUser($userId);
}
diff --git a/tests/unit/db/MapperFactoryTest.php b/tests/unit/db/MapperFactoryTest.php
index 3ebc0ce17..b5aa76dc0 100644
--- a/tests/unit/db/MapperFactoryTest.php
+++ b/tests/unit/db/MapperFactoryTest.php
@@ -43,7 +43,8 @@ class MapperFactoryTest extends \PHPUnit_Framework_TestCase {
public function testGetItemMapperPostgres() {
$factory = new MapperFactory('pgsql', $this->db);
- $this->assertTrue($factory->getItemMapper() instanceof \OCA\News\Db\Postgres\ItemMapper);
+ $this->assertTrue($factory->getItemMapper()
+ instanceof \OCA\News\Db\Postgres\ItemMapper);
}
diff --git a/tests/unit/db/postgres/ItemMapperTest.php b/tests/unit/db/postgres/ItemMapperTest.php
index 04550695d..473641522 100644
--- a/tests/unit/db/postgres/ItemMapperTest.php
+++ b/tests/unit/db/postgres/ItemMapperTest.php
@@ -62,7 +62,7 @@ class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
}
- public function testDeleteReadOlderThanThresholdDoesNotDeleteBelowThreshold(){
+ public function testDeleteReadOlderThanThresholdDoesntDelete(){
$status = StatusFlag::STARRED | StatusFlag::UNREAD;
$sql = 'SELECT COUNT(*) - `feeds`.`articles_per_update` AS `size`, ' .
'`items`.`feed_id` AS `feed_id` ' .
diff --git a/tests/unit/fetcher/FeedFetcherTest.php b/tests/unit/fetcher/FeedFetcherTest.php
index 6a0cec4dc..2d31fb18a 100644
--- a/tests/unit/fetcher/FeedFetcherTest.php
+++ b/tests/unit/fetcher/FeedFetcherTest.php
@@ -136,7 +136,8 @@ class FeedFetcherTest extends \PHPUnit_Framework_TestCase {
$this->title = 'my&amp;lt;&apos; title';
$this->guid = 'hey guid here';
$this->body = 'let the bodies hit the floor <a href="test">test</a>';
- $this->body2 = 'let the bodies hit the floor <a target="_blank" href="test">test</a>';
+ $this->body2 = 'let the bodies hit the floor ' .
+ '<a target="_blank" href="test">test</a>';
$this->pub = 23111;
$this->author = '&lt;boogieman';
$this->enclosureLink = 'http://enclosure.you';
@@ -232,7 +233,8 @@ class FeedFetcherTest extends \PHPUnit_Framework_TestCase {
}
- private function createItem($author=false, $enclosureType=null, $noPubDate=false) {
+ private function createItem($author=false, $enclosureType=null,
+ $noPubDate=false) {
$this->expectItem('get_permalink', $this->permalink);
$this->expectItem('get_title', $this->title);
$this->expectItem('get_id', $this->guid);
diff --git a/tests/unit/http/TextDownloadResponseTest.php b/tests/unit/http/TextDownloadResponseTest.php
index d78464e68..73622291a 100644
--- a/tests/unit/http/TextDownloadResponseTest.php
+++ b/tests/unit/http/TextDownloadResponseTest.php
@@ -19,7 +19,9 @@ class TextDownloadResponseTest extends \PHPUnit_Framework_TestCase {
protected function setUp() {
- $this->response = new TextDownloadResponse('sometext', 'file', 'content');
+ $this->response = new TextDownloadResponse(
+ 'sometext', 'file', 'content'
+ );
}
diff --git a/tests/unit/service/FeedServiceTest.php b/tests/unit/service/FeedServiceTest.php
index f7c804ec5..104413788 100644
--- a/tests/unit/service/FeedServiceTest.php
+++ b/tests/unit/service/FeedServiceTest.php
@@ -55,16 +55,20 @@ class FeedServiceTest extends \PHPUnit_Framework_TestCase {
$this->l10n = $this->getMockBuilder('\OCP\IL10N')
->disableOriginalConstructor()
->getMock();
- $this->feedMapper = $this->getMockBuilder('\OCA\News\Db\FeedMapper')
+ $this->feedMapper = $this
+ ->getMockBuilder('\OCA\News\Db\FeedMapper')
->disableOriginalConstructor()
->getMock();
- $this->fetcher = $this->getMockBuilder('\OCA\News\Fetcher\Fetcher')
+ $this->fetcher = $this
+ ->getMockBuilder('\OCA\News\Fetcher\Fetcher')
->disableOriginalConstructor()
->getMock();
- $this->itemMapper = $this->getMockBuilder('\OCA\News\Db\ItemMapper')
+ $this->itemMapper = $this
+ ->getMockBuilder('\OCA\News\Db\ItemMapper')
->disableOriginalConstructor()
->getMock();
- $this->enhancer = $this->getMockBuilder('\OCA\News\ArticleEnhancer\Enhancer')
+ $this->enhancer = $this
+ ->getMockBuilder('\OCA\News\ArticleEnhancer\Enhancer')
->disableOriginalConstructor()
->getMock();
$this->purifier = $this->getMock('purifier', ['purify']);
@@ -78,7 +82,8 @@ class FeedServiceTest extends \PHPUnit_Framework_TestCase {
$this->feedService = new FeedService($this->feedMapper,
$this->fetcher, $this->itemMapper, $this->logger, $this->l10n,
- $timeFactory, $config, $this->enhancer, $this->purifier, $this->loggerParams);
+ $timeFactory, $config, $this->enhancer, $this->purifier,
+ $this->loggerParams);
$this->user = 'jack';
}
@@ -103,7 +108,9 @@ class FeedServiceTest extends \PHPUnit_Framework_TestCase {
->method('fetch')
->with($this->equalTo($url))
->will($this->throwException($ex));
- $this->setExpectedException('\OCA\News\Service\ServiceNotFoundException');
+ $this->setExpectedException(
+ '\OCA\News\Service\ServiceNotFoundException'
+ );
$this->feedService->create($url, 1, $this->user);
}
@@ -127,7 +134,10 @@ class FeedServiceTest extends \PHPUnit_Framework_TestCase {
$this->feedMapper->expects($this->once())
->method('findByUrlHash')
- ->with($this->equalTo($createdFeed->getUrlHash()), $this->equalTo($this->user))
+ ->with(
+ $this->equalTo($createdFeed->getUrlHash()),
+ $this->equalTo($this->user)
+ )
->will($this->throwException($ex));
$this->fetcher->expects($this->once())
->method('fetch')
@@ -369,7 +379,9 @@ class FeedServiceTest extends \PHPUnit_Framework_TestCase {
$this->equalTo($this->user))
->will($this->throwException($ex));
- $this->setExpectedException('\OCA\News\Service\ServiceNotFoundException');
+ $this->setExpectedException(
+ '\OCA\News\Service\ServiceNotFoundException'
+ );
$this->feedService->update($feed->getId(), $this->user);
}
@@ -412,7 +424,9 @@ class FeedServiceTest extends \PHPUnit_Framework_TestCase {
$this->equalTo($this->user))
->will($this->throwException($ex));
- $this->setExpectedException('\OCA\News\Service\ServiceNotFoundException');
+ $this->setExpectedException(
+ '\OCA\News\Service\ServiceNotFoundException'
+ );
$this->feedService->update($feed->getId(), $this->user);
}
@@ -565,7 +579,8 @@ class FeedServiceTest extends \PHPUnit_Framework_TestCase {
$json = $item->toExport(['feed3' => $feed]);
$json2 = $json;
- $json2['feedLink'] = 'http://test.com'; // believe it or not this copies stuff :D
+ // believe it or not this copies stuff :D
+ $json2['feedLink'] = 'http://test.com';
$items = [$json, $json2];
diff --git a/tests/unit/service/FolderServiceTest.php b/tests/unit/service/FolderServiceTest.php
index 53fb737b7..927cd1229 100644
--- a/tests/unit/service/FolderServiceTest.php
+++ b/tests/unit/service/FolderServiceTest.php
@@ -95,7 +95,9 @@ class FolderServiceTest extends \PHPUnit_Framework_TestCase {
->with($this->equalTo($folderName))
->will($this->returnValue($rows));
- $this->setExpectedException('\OCA\News\Service\ServiceConflictException');
+ $this->setExpectedException(
+ '\OCA\News\Service\ServiceConflictException'
+ );
$this->folderService->create($folderName, 'john', 3);
}
@@ -108,7 +110,9 @@ class FolderServiceTest extends \PHPUnit_Framework_TestCase {
->with($this->equalTo($folderName))
->will($this->returnValue([]));
- $this->setExpectedException('\OCA\News\Service\ServiceValidationException');
+ $this->setExpectedException(
+ '\OCA\News\Service\ServiceValidationException'
+ );
$this->folderService->create($folderName, 'john', 3);
}
@@ -162,7 +166,9 @@ class FolderServiceTest extends \PHPUnit_Framework_TestCase {
->with($this->equalTo($folderName))
->will($this->returnValue($rows));
- $this->setExpectedException('\OCA\News\Service\ServiceConflictException');
+ $this->setExpectedException(
+ '\OCA\News\Service\ServiceConflictException'
+ );
$this->folderService->rename(3, $folderName, 'john');
}
@@ -175,7 +181,9 @@ class FolderServiceTest extends \PHPUnit_Framework_TestCase {
->with($this->equalTo($folderName))
->will($this->returnValue([]));
- $this->setExpectedException('\OCA\News\Service\ServiceValidationException');
+ $this->setExpectedException(
+ '\OCA\News\Service\ServiceValidationException'
+ );
$this->folderService->rename(3, $folderName, 'john');
}
diff --git a/tests/unit/service/ItemServiceTest.php b/tests/unit/service/ItemServiceTest.php
index b9f23fee6..4f5672e20 100644
--- a/tests/unit/service/ItemServiceTest.php
+++ b/tests/unit/service/ItemServiceTest.php
@@ -301,7 +301,9 @@ class ItemServiceTest extends \PHPUnit_Framework_TestCase {
public function testStarDoesNotExist(){
- $this->setExpectedException('\OCA\News\Service\ServiceNotFoundException');
+ $this->setExpectedException(
+ '\OCA\News\Service\ServiceNotFoundException'
+ );
$this->mapper->expects($this->once())
->method('findByGuidHash')
->will($this->throwException(new DoesNotExistException('')));
@@ -377,9 +379,13 @@ class ItemServiceTest extends \PHPUnit_Framework_TestCase {
$this->mapper->expects($this->once())
->method('getNewestItemId')
->with($this->equalTo($this->user))
- ->will($this->throwException(new DoesNotExistException('There are no items')));
+ ->will($this->throwException(
+ new DoesNotExistException('There are no items'))
+ );
- $this->setExpectedException('\OCA\News\Service\ServiceNotFoundException');
+ $this->setExpectedException(
+ '\OCA\News\Service\ServiceNotFoundException'
+ );
$this->itemService->getNewestItemId($this->user);
}
diff --git a/tests/unit/service/ServiceTest.php b/tests/unit/service/ServiceTest.php
index 473141cd3..07f2d9452 100644
--- a/tests/unit/service/ServiceTest.php
+++ b/tests/unit/service/ServiceTest.php
@@ -75,7 +75,9 @@ class ServiceTest extends \PHPUnit_Framework_TestCase {
->method('find')
->will($this->throwException($ex));
- $this->setExpectedException('\OCA\News\Service\ServiceNotFoundException');
+ $this->setExpectedException(
+ '\OCA\News\Service\ServiceNotFoundException'
+ );
$this->newsService->find(1, '');
}
@@ -87,7 +89,9 @@ class ServiceTest extends \PHPUnit_Framework_TestCase {
->method('find')
->will($this->throwException($ex));
- $this->setExpectedException('\OCA\News\Service\ServiceNotFoundException');
+ $this->setExpectedException(
+ '\OCA\News\Service\ServiceNotFoundException'
+ );
$this->newsService->find(1, '');
}
diff --git a/tests/unit/utility/FaviconFetcherTest.php b/tests/unit/utility/FaviconFetcherTest.php
index e73510a13..4ee823636 100644
--- a/tests/unit/utility/FaviconFetcherTest.php
+++ b/tests/unit/utility/FaviconFetcherTest.php
@@ -94,7 +94,8 @@ class FaviconFetcherTest extends \PHPUnit_Framework_TestCase {
$favicon = $this->fetcher->fetch($url);
- $this->assertEquals('http://google.com/owncloud/core/img/favicon.png', $favicon);
+ $this->assertEquals('http://google.com/owncloud/core/img/favicon.png',
+ $favicon);
}
@@ -163,7 +164,8 @@ class FaviconFetcherTest extends \PHPUnit_Framework_TestCase {
$favicon = $this->fetcher->fetch($url);
- $this->assertEquals('http://google.com/owncloud/core/img/favicon.png', $favicon);
+ $this->assertEquals('http://google.com/owncloud/core/img/favicon.png',
+ $favicon);
}
diff --git a/tests/unit/utility/OPMLExporterTest.php b/tests/unit/utility/OPMLExporterTest.php
index 5d6f849fb..416d476a8 100644
--- a/tests/unit/utility/OPMLExporterTest.php
+++ b/tests/unit/utility/OPMLExporterTest.php
@@ -69,10 +69,14 @@ class OPMLExporterTest extends \PHPUnit_Framework_TestCase {
$elems = $xpath->query('/opml/body/outline');
$this->assertEquals(2, $elems->length);
- $this->assertEquals($this->folder1->getName(), $this->getAttribute($elems->item(0), 'title'));
- $this->assertEquals($this->folder1->getName(), $this->getAttribute($elems->item(0), 'text'));
- $this->assertEquals($this->folder2->getName(), $this->getAttribute($elems->item(1), 'title'));
- $this->assertEquals($this->folder2->getName(), $this->getAttribute($elems->item(1), 'text'));
+ $this->assertEquals($this->folder1->getName(),
+ $this->getAttribute($elems->item(0), 'title'));
+ $this->assertEquals($this->folder1->getName(),
+ $this->getAttribute($elems->item(0), 'text'));
+ $this->assertEquals($this->folder2->getName(),
+ $this->getAttribute($elems->item(1), 'title'));
+ $this->assertEquals($this->folder2->getName(),
+ $this->getAttribute($elems->item(1), 'text'));
}
@@ -82,10 +86,14 @@ class OPMLExporterTest extends \PHPUnit_Framework_TestCase {
$elems = $xpath->query('//outline');
$this->assertEquals(1, $elems->length);
- $this->assertEquals($this->feed1->getTitle(), $this->getAttribute($elems->item(0), 'title'));
- $this->assertEquals($this->feed1->getTitle(), $this->getAttribute($elems->item(0), 'text'));
- $this->assertEquals($this->feed1->getUrl(), $this->getAttribute($elems->item(0), 'xmlUrl'));
- $this->assertEquals('', $this->getAttribute($elems->item(0), 'htmlUrl'));
+ $this->assertEquals($this->feed1->getTitle(),
+ $this->getAttribute($elems->item(0), 'title'));
+ $this->assertEquals($this->feed1->getTitle(),
+ $this->getAttribute($elems->item(0), 'text'));
+ $this->assertEquals($this->feed1->getUrl(),
+ $this->getAttribute($elems->item(0), 'xmlUrl'));
+ $this->assertEquals('',
+ $this->getAttribute($elems->item(0), 'htmlUrl'));
}
@@ -100,10 +108,15 @@ class OPMLExporterTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals(3, $elems->length);
- $this->assertEquals($this->folder1->getName(), $this->getAttribute($elems->item(0), 'title'));
- $this->assertEquals($this->folder2->getName(), $this->getAttribute($elems->item(1), 'text'));
- $this->assertEquals($this->feed1->getUrl(), $this->getAttribute($elems->item(2), 'xmlUrl'));
- $this->assertEquals($this->feed2->getLink(), $this->getAttribute($elems->item(1)->childNodes->item(0), 'htmlUrl'));
+ $this->assertEquals($this->folder1->getName(),
+ $this->getAttribute($elems->item(0), 'title'));
+ $this->assertEquals($this->folder2->getName(),
+ $this->getAttribute($elems->item(1), 'text'));
+ $this->assertEquals($this->feed1->getUrl(),
+ $this->getAttribute($elems->item(2), 'xmlUrl'));
+ $this->assertEquals($this->feed2->getLink(),
+ $this->getAttribute($elems->item(1)->childNodes->item(0), 'htmlUrl')
+ );
}