зеркало из https://github.com/nextcloud/news.git
fix tests
This commit is contained in:
Родитель
e76ba69f66
Коммит
4490422601
|
@ -74,7 +74,7 @@ class Application extends App {
|
|||
*/
|
||||
$container->registerService('PageController', function($c) {
|
||||
return new PageController(
|
||||
$c->query('AppName'),
|
||||
$c->query('AppName'),
|
||||
$c->query('Request'),
|
||||
$c->query('CoreConfig'),
|
||||
$c->query('L10N'),
|
||||
|
@ -84,7 +84,7 @@ class Application extends App {
|
|||
|
||||
$container->registerService('FolderController', function($c) {
|
||||
return new FolderController(
|
||||
$c->query('AppName'),
|
||||
$c->query('AppName'),
|
||||
$c->query('Request'),
|
||||
$c->query('FolderService'),
|
||||
$c->query('FeedService'),
|
||||
|
@ -95,7 +95,7 @@ class Application extends App {
|
|||
|
||||
$container->registerService('FeedController', function($c) {
|
||||
return new FeedController(
|
||||
$c->query('AppName'),
|
||||
$c->query('AppName'),
|
||||
$c->query('Request'),
|
||||
$c->query('FolderService'),
|
||||
$c->query('FeedService'),
|
||||
|
@ -107,7 +107,7 @@ class Application extends App {
|
|||
|
||||
$container->registerService('ItemController', function($c) {
|
||||
return new ItemController(
|
||||
$c->query('AppName'),
|
||||
$c->query('AppName'),
|
||||
$c->query('Request'),
|
||||
$c->query('FeedService'),
|
||||
$c->query('ItemService'),
|
||||
|
@ -118,7 +118,7 @@ class Application extends App {
|
|||
|
||||
$container->registerService('ExportController', function($c) {
|
||||
return new ExportController(
|
||||
$c->query('AppName'),
|
||||
$c->query('AppName'),
|
||||
$c->query('Request'),
|
||||
$c->query('FolderService'),
|
||||
$c->query('FeedService'),
|
||||
|
@ -130,8 +130,8 @@ class Application extends App {
|
|||
|
||||
$container->registerService('UtilityApiController', function($c) {
|
||||
return new UtilityApiController(
|
||||
$c->query('AppName'),
|
||||
$c->query('Request'),
|
||||
$c->query('AppName'),
|
||||
$c->query('Request'),
|
||||
$c->query('Updater'),
|
||||
$c->query('CoreConfig')
|
||||
);
|
||||
|
@ -139,7 +139,7 @@ class Application extends App {
|
|||
|
||||
$container->registerService('FolderApiController', function($c) {
|
||||
return new FolderApiController(
|
||||
$c->query('AppName'),
|
||||
$c->query('AppName'),
|
||||
$c->query('Request'),
|
||||
$c->query('FolderService'),
|
||||
$c->query('ItemService'),
|
||||
|
@ -149,7 +149,7 @@ class Application extends App {
|
|||
|
||||
$container->registerService('FeedApiController', function($c) {
|
||||
return new FeedApiController(
|
||||
$c->query('AppName'),
|
||||
$c->query('AppName'),
|
||||
$c->query('Request'),
|
||||
$c->query('FeedService'),
|
||||
$c->query('ItemService'),
|
||||
|
@ -161,7 +161,7 @@ class Application extends App {
|
|||
|
||||
$container->registerService('ItemApiController', function($c) {
|
||||
return new ItemApiController(
|
||||
$c->query('AppName'),
|
||||
$c->query('AppName'),
|
||||
$c->query('Request'),
|
||||
$c->query('ItemService'),
|
||||
$c->query('UserId')
|
||||
|
@ -211,7 +211,7 @@ class Application extends App {
|
|||
*/
|
||||
$container->registerService('MapperFactory', function($c) {
|
||||
return new MapperFactory(
|
||||
$c->query('DatabaseType'),
|
||||
$c->query('DatabaseType'),
|
||||
$c->query('Db')
|
||||
);
|
||||
});
|
||||
|
@ -239,16 +239,6 @@ class Application extends App {
|
|||
* App config parser
|
||||
*/
|
||||
$container->registerService('AppConfig', function($c) {
|
||||
// not performant but well :/
|
||||
// $config = $c->query('ServerContainer')->getAppConfig(); oc7 only
|
||||
$installedApps = \OC_Appconfig::getApps();
|
||||
$apps = [];
|
||||
foreach($installedApps as $app) {
|
||||
$apps[] = [
|
||||
$app => \OC_Appconfig::getValue($app, 'installed_version', '0')
|
||||
];
|
||||
}
|
||||
|
||||
// order extensions in name => version
|
||||
$loadedExtensions = get_loaded_extensions();
|
||||
$extensions = [];
|
||||
|
@ -262,7 +252,6 @@ class Application extends App {
|
|||
$c->query('ServerContainer')->getURLGenerator(),
|
||||
phpversion(),
|
||||
implode('.', Util::getVersion()),
|
||||
$apps,
|
||||
$extensions,
|
||||
$c->query('DatabaseType')
|
||||
);
|
||||
|
@ -270,7 +259,7 @@ class Application extends App {
|
|||
|
||||
/**
|
||||
* Core
|
||||
*/
|
||||
*/
|
||||
$container->registerService('L10N', function($c) {
|
||||
return $c->query('ServerContainer')->getL10N($c->query('AppName'));
|
||||
});
|
||||
|
@ -314,7 +303,7 @@ class Application extends App {
|
|||
|
||||
$container->registerService('Config', function($c) {
|
||||
$config = new Config(
|
||||
$c->query('ConfigView'),
|
||||
$c->query('ConfigView'),
|
||||
$c->query('Logger'),
|
||||
$c->query('LoggerParameters')
|
||||
);
|
||||
|
@ -345,7 +334,7 @@ class Application extends App {
|
|||
$config->set('Cache.SerializerPath', $directory);
|
||||
$config->set('HTML.SafeIframe', true);
|
||||
$config->set('URI.SafeIframeRegexp',
|
||||
'%^(?:https?:)?//(' .
|
||||
'%^(?:https?:)?//(' .
|
||||
'www.youtube(?:-nocookie)?.com/embed/|' .
|
||||
'player.vimeo.com/video/)%'); //allow YouTube and Vimeo
|
||||
return new \HTMLPurifier($config);
|
||||
|
@ -358,7 +347,7 @@ class Application extends App {
|
|||
$xpathEnhancerConfig = file_get_contents(
|
||||
__DIR__ . '/../articleenhancer/xpathenhancers.json'
|
||||
);
|
||||
|
||||
|
||||
foreach(json_decode($xpathEnhancerConfig, true) as $feed => $config) {
|
||||
$articleEnhancer = new XPathArticleEnhancer(
|
||||
$c->query('SimplePieAPIFactory'),
|
||||
|
|
|
@ -28,7 +28,6 @@ class AppConfig {
|
|||
private $urlGenerator;
|
||||
private $phpVersion;
|
||||
private $ownCloudVersion;
|
||||
private $installedApps;
|
||||
private $installedExtensions;
|
||||
private $databaseType;
|
||||
private $l10n;
|
||||
|
@ -43,7 +42,6 @@ class AppConfig {
|
|||
IURLGenerator $urlGenerator,
|
||||
$phpVersion,
|
||||
$ownCloudVersion,
|
||||
$installedApps,
|
||||
$installedExtensions,
|
||||
$databaseType) {
|
||||
$this->navigationManager = $navigationManager;
|
||||
|
@ -51,7 +49,6 @@ class AppConfig {
|
|||
$this->urlGenerator = $urlGenerator;
|
||||
$this->ownCloudVersion = $ownCloudVersion;
|
||||
$this->phpVersion = $phpVersion;
|
||||
$this->installedApps = $installedApps;
|
||||
$this->installedExtensions = $installedExtensions;
|
||||
$this->databaseType = $databaseType;
|
||||
$this->config = [];
|
||||
|
@ -85,7 +82,7 @@ class AppConfig {
|
|||
foreach($defaults as $key => $value) {
|
||||
if(!array_key_exists($key, $nav)) {
|
||||
$nav[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +96,7 @@ class AppConfig {
|
|||
if($key !== null) {
|
||||
return $this->config[$key];
|
||||
} else {
|
||||
return $this->config;
|
||||
return $this->config;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -111,7 +108,7 @@ class AppConfig {
|
|||
// if key is missing, don't create a navigation
|
||||
if(array_key_exists('navigation', $this->config)) {
|
||||
$nav =& $this->config['navigation'];
|
||||
|
||||
|
||||
$navConfig = [
|
||||
'id' => $nav['id'],
|
||||
'order' => $nav['order']
|
||||
|
@ -119,7 +116,7 @@ class AppConfig {
|
|||
|
||||
$navConfig['name'] = $this->l10n->t($nav['name']);
|
||||
$navConfig['href'] = $this->urlGenerator->linkToRoute($nav['route']);
|
||||
$navConfig['icon'] = $this->urlGenerator->imagePath($nav['id'],
|
||||
$navConfig['icon'] = $this->urlGenerator->imagePath($nav['id'],
|
||||
$nav['icon']);
|
||||
|
||||
$this->navigationManager->add($navConfig);
|
||||
|
@ -132,7 +129,7 @@ class AppConfig {
|
|||
* Registers all jobs in the config
|
||||
*/
|
||||
public function registerBackgroundJobs() {
|
||||
// FIXME: this is temporarily static because core jobs are not public
|
||||
// FIXME: this is temporarily static because core jobs are not public
|
||||
// yet, therefore legacy code
|
||||
foreach ($this->config['jobs'] as $job) {
|
||||
Backgroundjob::addRegularTask($job, 'run');
|
||||
|
@ -144,7 +141,7 @@ class AppConfig {
|
|||
* Registers all hooks in the config
|
||||
*/
|
||||
public function registerHooks() {
|
||||
// FIXME: this is temporarily static because core emitters are not future
|
||||
// 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);
|
||||
|
@ -168,14 +165,14 @@ class AppConfig {
|
|||
if(array_key_exists('databases', $this->config)) {
|
||||
if(!in_array($this->databaseType, $this->config['databases'])) {
|
||||
$msg .= 'Database ' . $this->databaseType . ' not supported.' .
|
||||
'App is only compatible with ' .
|
||||
'App is only compatible with ' .
|
||||
implode(', ', $this->config['databases']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// test dependencies
|
||||
if(array_key_exists('dependencies', $this->config)) {
|
||||
|
||||
|
||||
$deps = $this->config['dependencies'];
|
||||
|
||||
if(array_key_exists('php', $deps)) {
|
||||
|
@ -184,25 +181,14 @@ class AppConfig {
|
|||
}
|
||||
|
||||
if(array_key_exists('owncloud', $deps)) {
|
||||
$msg .= $this->requireVersion($this->ownCloudVersion,
|
||||
$msg .= $this->requireVersion($this->ownCloudVersion,
|
||||
$deps['owncloud'], 'ownCloud');
|
||||
}
|
||||
|
||||
if(array_key_exists('apps', $deps)) {
|
||||
foreach ($deps['apps'] as $app => $versions) {
|
||||
if(array_key_exists($app, $this->installedApps)) {
|
||||
$msg .= $this->requireVersion($this->installedApps[$app],
|
||||
$versions, 'App ' . $app);
|
||||
} else {
|
||||
$msg .= 'ownCloud app ' . $app . ' required but not installed';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists('libs', $deps)) {
|
||||
foreach ($deps['libs'] as $lib => $versions) {
|
||||
if(array_key_exists($lib, $this->installedExtensions)) {
|
||||
$msg .= $this->requireVersion($this->installedExtensions[$lib],
|
||||
$msg .= $this->requireVersion($this->installedExtensions[$lib],
|
||||
$versions, 'PHP extension ' . $lib);
|
||||
} else {
|
||||
$msg .= 'PHP extension ' . $lib . ' required but not installed';
|
||||
|
@ -220,9 +206,9 @@ class AppConfig {
|
|||
/**
|
||||
* Compares a version with a version requirement string
|
||||
* @param string $actual the actual version that is there
|
||||
* @param string $required a version requirement in the form of
|
||||
* @param string $required a version requirement in the form of
|
||||
* <=5.3,>4.5 versions are separated with a comma
|
||||
* @param string $versionType a description of the string that is prepended
|
||||
* @param string $versionType a description of the string that is prepended
|
||||
* to the error message
|
||||
* @return string an error message if the version is not met,
|
||||
* empty string if ok
|
||||
|
@ -236,8 +222,8 @@ class AppConfig {
|
|||
continue;
|
||||
}
|
||||
if(!version_compare($actual, $version['version'], $version['operator'])) {
|
||||
return $versionType . ' Version not satisfied: ' . $version['operator'] .
|
||||
$version['version'] . ' required but found ' . $actual . '\n';
|
||||
return $versionType . ' Version not satisfied: ' . $version['operator'] .
|
||||
$version['version'] . ' required but found ' . $actual . '\n';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -247,7 +233,7 @@ class AppConfig {
|
|||
|
||||
/**
|
||||
* Versions can be separated by a comma so split them
|
||||
* @param string $versions a version requirement in the form of
|
||||
* @param string $versions a version requirement in the form of
|
||||
* <=5.3,>4.5 versions are separated with a comma
|
||||
* @return array of arrays with key=version value=operator
|
||||
*/
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
active: Navigation.isSubscriptionsActive(),
|
||||
unread: Navigation.getUnreadCount() > 0
|
||||
}"
|
||||
class="has-counter">
|
||||
class="has-counter has-menu">
|
||||
|
||||
<a class="icon-rss" ng-href="#/items/" ng-if="!Navigation.isShowAll()">
|
||||
<?php p($l->t('Unread articles'))?>
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|| Navigation.isFeedActive(feed.id)
|
||||
|| !feed.id"
|
||||
data-id="{{ feed.id }}"
|
||||
class="feed has-counter"
|
||||
class="feed has-counter has-menu"
|
||||
news-draggable="{
|
||||
stack: '> li',
|
||||
zIndex: 1000,
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|| Navigation.isFolderActive(folder.id)
|
||||
|| Navigation.subFeedActive(folder.id)
|
||||
|| !folder.id"
|
||||
class="folder has-counter"
|
||||
class="folder has-counter has-menu"
|
||||
data-id="{{ folder.id }}"
|
||||
news-droppable>
|
||||
<button class="collapse"
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
*/
|
||||
|
||||
require_once __DIR__ . '/../3rdparty/simplepie/autoloader.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){
|
||||
|
|
|
@ -32,12 +32,11 @@ class AppConfigTest extends \PHPUnit_Framework_TestCase {
|
|||
->getMock();
|
||||
$phpVersion = '5.3';
|
||||
$ownCloudVersion = '6.0.3';
|
||||
$installedApps = ['contacts' => '5.3', 'calendar' => '2.3'];
|
||||
$installedExtensions = ['curl' => '4.3'];
|
||||
$databaseType = 'oracle';
|
||||
|
||||
$this->config = new AppConfig($this->nav, $this->l10n,
|
||||
$this->url, $phpVersion, $ownCloudVersion, $installedApps,
|
||||
$this->url, $phpVersion, $ownCloudVersion,
|
||||
$installedExtensions, $databaseType);
|
||||
}
|
||||
|
||||
|
@ -157,22 +156,6 @@ class AppConfigTest extends \PHPUnit_Framework_TestCase {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @expectedException \OCA\News\Config\DependencyException
|
||||
*/
|
||||
public function testAppVersion() {
|
||||
$this->config->loadConfig([
|
||||
'dependencies' => [
|
||||
'apps' => [
|
||||
'contacts' => '5.3',
|
||||
'calendar' => '>2.3'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$this->config->testDependencies();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @expectedException \OCA\News\Config\DependencyException
|
||||
*/
|
||||
|
@ -203,20 +186,6 @@ class AppConfigTest extends \PHPUnit_Framework_TestCase {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* @expectedException \OCA\News\Config\DependencyException
|
||||
*/
|
||||
public function testAppsExistence() {
|
||||
$this->config->loadConfig([
|
||||
'dependencies' => [
|
||||
'apps' => [
|
||||
'news' => '>=4.3,<=4.3'
|
||||
]
|
||||
]
|
||||
]);
|
||||
$this->config->testDependencies();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @expectedException \OCA\News\Config\DependencyException
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
namespace OCA\News\Db;
|
||||
|
||||
|
||||
class FeedMapperTest extends \OCP\AppFramework\Db\MapperTestUtility {
|
||||
class FeedMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
|
||||
|
||||
private $mapper;
|
||||
private $feeds;
|
||||
|
|
|
@ -14,12 +14,12 @@
|
|||
namespace OCA\News\Db;
|
||||
|
||||
|
||||
class FolderMapperTest extends \OCP\AppFramework\Db\MapperTestUtility {
|
||||
class FolderMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
|
||||
|
||||
private $folderMapper;
|
||||
private $folders;
|
||||
private $user;
|
||||
|
||||
|
||||
protected function setUp(){
|
||||
parent::setUp();
|
||||
|
||||
|
@ -45,12 +45,12 @@ class FolderMapperTest extends \OCP\AppFramework\Db\MapperTestUtility {
|
|||
$sql = 'SELECT * FROM `*PREFIX*news_folders` ' .
|
||||
'WHERE `id` = ? ' .
|
||||
'AND `user_id` = ?';
|
||||
|
||||
|
||||
$this->setMapperResult($sql, [$id, $userId], $rows);
|
||||
|
||||
|
||||
$result = $this->folderMapper->find($id, $userId);
|
||||
$this->assertEquals($this->folders[0], $result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -60,13 +60,13 @@ class FolderMapperTest extends \OCP\AppFramework\Db\MapperTestUtility {
|
|||
$sql = 'SELECT * FROM `*PREFIX*news_folders` ' .
|
||||
'WHERE `id` = ? ' .
|
||||
'AND `user_id` = ?';
|
||||
|
||||
|
||||
$this->setMapperResult($sql, [$id, $userId]);
|
||||
|
||||
|
||||
$this->setExpectedException('\OCP\AppFramework\Db\DoesNotExistException');
|
||||
$this->folderMapper->find($id, $userId);
|
||||
$this->folderMapper->find($id, $userId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function testFindMoreThanOneResultFound(){
|
||||
$userId = 'john';
|
||||
|
@ -75,9 +75,9 @@ class FolderMapperTest extends \OCP\AppFramework\Db\MapperTestUtility {
|
|||
$sql = 'SELECT * FROM `*PREFIX*news_folders` ' .
|
||||
'WHERE `id` = ? ' .
|
||||
'AND `user_id` = ?';
|
||||
|
||||
|
||||
$this->setMapperResult($sql, [$id, $userId], $rows);
|
||||
|
||||
|
||||
$this->setExpectedException('\OCP\AppFramework\Db\MultipleObjectsReturnedException');
|
||||
$this->folderMapper->find($id, $userId);
|
||||
}
|
||||
|
@ -90,9 +90,9 @@ class FolderMapperTest extends \OCP\AppFramework\Db\MapperTestUtility {
|
|||
$sql = 'SELECT * FROM `*PREFIX*news_folders` ' .
|
||||
'WHERE `user_id` = ? ' .
|
||||
'AND `deleted_at` = 0';
|
||||
|
||||
|
||||
$this->setMapperResult($sql, [$userId], $rows);
|
||||
|
||||
|
||||
$result = $this->folderMapper->findAllFromUser($userId);
|
||||
$this->assertEquals($this->folders, $result);
|
||||
}
|
||||
|
@ -105,9 +105,9 @@ class FolderMapperTest extends \OCP\AppFramework\Db\MapperTestUtility {
|
|||
$sql = 'SELECT * FROM `*PREFIX*news_folders` ' .
|
||||
'WHERE `name` = ? ' .
|
||||
'AND `user_id` = ?';
|
||||
|
||||
|
||||
$this->setMapperResult($sql, [$folderName, $userId], $rows);
|
||||
|
||||
|
||||
$result = $this->folderMapper->findByName($folderName, $userId);
|
||||
$this->assertEquals($this->folders, $result);
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
namespace OCA\News\Db;
|
||||
|
||||
|
||||
class ItemMapperTest extends \OCP\AppFramework\Db\MapperTestUtility {
|
||||
class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
|
||||
|
||||
private $mapper;
|
||||
private $items;
|
||||
|
|
|
@ -17,7 +17,7 @@ use \OCA\News\Db\Item;
|
|||
use \OCA\News\Db\StatusFlag;
|
||||
|
||||
|
||||
class ItemMapperTest extends \OCP\AppFramework\Db\MapperTestUtility {
|
||||
class ItemMapperTest extends \Test\AppFramework\Db\MapperTestUtility {
|
||||
|
||||
private $mapper;
|
||||
private $items;
|
||||
|
@ -65,7 +65,7 @@ class ItemMapperTest extends \OCP\AppFramework\Db\MapperTestUtility {
|
|||
public function testDeleteReadOlderThanThresholdDoesNotDeleteBelowThreshold(){
|
||||
$status = StatusFlag::STARRED | StatusFlag::UNREAD;
|
||||
$sql = 'SELECT COUNT(*) - `feeds`.`articles_per_update` AS `size`, ' .
|
||||
'`items`.`feed_id` AS `feed_id` ' .
|
||||
'`items`.`feed_id` AS `feed_id` ' .
|
||||
'FROM `*PREFIX*news_items` `items` ' .
|
||||
'JOIN `*PREFIX*news_feeds` `feeds` ' .
|
||||
'ON `feeds`.`id` = `items`.`feed_id` ' .
|
||||
|
@ -89,7 +89,7 @@ class ItemMapperTest extends \OCP\AppFramework\Db\MapperTestUtility {
|
|||
$status = StatusFlag::STARRED | StatusFlag::UNREAD;
|
||||
|
||||
$sql1 = 'SELECT COUNT(*) - `feeds`.`articles_per_update` AS `size`, ' .
|
||||
'`items`.`feed_id` AS `feed_id` ' .
|
||||
'`items`.`feed_id` AS `feed_id` ' .
|
||||
'FROM `*PREFIX*news_items` `items` ' .
|
||||
'JOIN `*PREFIX*news_feeds` `feeds` ' .
|
||||
'ON `feeds`.`id` = `items`.`feed_id` ' .
|
||||
|
|
Загрузка…
Ссылка в новой задаче