From 4490422601824d920de5f9d6e3df0897dec0b414 Mon Sep 17 00:00:00 2001 From: Bernhard Posselt Date: Mon, 1 Sep 2014 11:15:08 +0200 Subject: fix tests --- appinfo/application.php | 41 ++++++++++----------------- config/appconfig.php | 46 +++++++++++-------------------- templates/part.feed.unread.php | 2 +- templates/part.listfeed.php | 2 +- templates/part.listfolder.php | 2 +- tests/classloader.php | 2 +- tests/unit/config/AppConfigTest.php | 33 +--------------------- tests/unit/db/FeedMapperTest.php | 2 +- tests/unit/db/FolderMapperTest.php | 30 ++++++++++---------- tests/unit/db/ItemMapperTest.php | 2 +- tests/unit/db/postgres/ItemMapperTest.php | 6 ++-- 11 files changed, 56 insertions(+), 112 deletions(-) diff --git a/appinfo/application.php b/appinfo/application.php index e9e9c8bde..a353884cb 100644 --- a/appinfo/application.php +++ b/appinfo/application.php @@ -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'), diff --git a/config/appconfig.php b/config/appconfig.php index e2cc01aec..5292d35a7 100644 --- a/config/appconfig.php +++ b/config/appconfig.php @@ -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 */ diff --git a/templates/part.feed.unread.php b/templates/part.feed.unread.php index 275c36dd6..979824d1c 100644 --- a/templates/part.feed.unread.php +++ b/templates/part.feed.unread.php @@ -2,7 +2,7 @@ active: Navigation.isSubscriptionsActive(), unread: Navigation.getUnreadCount() > 0 }" - class="has-counter"> + class="has-counter has-menu"> t('Unread articles'))?> diff --git a/templates/part.listfeed.php b/templates/part.listfeed.php index f3e2695d5..e0d00d093 100644 --- a/templates/part.listfeed.php +++ b/templates/part.listfeed.php @@ -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, diff --git a/templates/part.listfolder.php b/templates/part.listfolder.php index 91d2995ef..8f97dfa9d 100644 --- a/templates/part.listfolder.php +++ b/templates/part.listfolder.php @@ -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>