From 8632f68324dc63bddd692e5e9f79beaca500035d Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Thu, 24 Jan 2013 01:13:33 +0100 Subject: [PATCH 1/7] Fix unit tests, bump to version 3.8.0 alpha 3 --- lib/Alchemy/Phrasea/Core/Configuration.php | 26 +- .../ApplicationSpecification.php | 35 +- .../Configuration/SpecificationInterface.php | 3 +- lib/Alchemy/Phrasea/Core/Version.php | 2 +- lib/classes/patch/3803.php | 75 +- lib/classes/patch/3804.php | 84 +++ lib/conf.d/config.yml | 72 ++ lib/conf.d/connexions.yml | 19 + lib/conf.d/services.yml | 215 ++++++ .../Tests/Phrasea/Application/ApiAbstract.php | 22 +- .../Core/Configuration/ConfigurationTest.php | 387 ---------- .../Configuration/confTestFiles/config.yml | 69 -- .../Configuration/confTestFiles/test.json | 12 - .../Tests/Phrasea/Core/ConfigurationTest.php | 702 ++++++++++++++++++ .../BorderManagerServiceProviderTest.php | 7 +- .../Core/Provider/FTPServiceProviderTest.php | 20 + .../ConfigurationPanelAbstractTest.php | 2 + 17 files changed, 1213 insertions(+), 539 deletions(-) create mode 100644 lib/classes/patch/3804.php create mode 100644 lib/conf.d/config.yml create mode 100644 lib/conf.d/connexions.yml create mode 100644 lib/conf.d/services.yml delete mode 100644 tests/Alchemy/Tests/Phrasea/Core/Configuration/ConfigurationTest.php delete mode 100644 tests/Alchemy/Tests/Phrasea/Core/Configuration/confTestFiles/config.yml delete mode 100644 tests/Alchemy/Tests/Phrasea/Core/Configuration/confTestFiles/test.json create mode 100644 tests/Alchemy/Tests/Phrasea/Core/ConfigurationTest.php create mode 100644 tests/Alchemy/Tests/Phrasea/Core/Provider/FTPServiceProviderTest.php diff --git a/lib/Alchemy/Phrasea/Core/Configuration.php b/lib/Alchemy/Phrasea/Core/Configuration.php index 25017506f4..8087a40a43 100644 --- a/lib/Alchemy/Phrasea/Core/Configuration.php +++ b/lib/Alchemy/Phrasea/Core/Configuration.php @@ -14,6 +14,7 @@ namespace Alchemy\Phrasea\Core; use Alchemy\Phrasea\Core\Configuration\ApplicationSpecification; use Alchemy\Phrasea\Core\Configuration\SpecificationInterface; use Alchemy\Phrasea\Exception\InvalidArgumentException; +use Alchemy\Phrasea\Exception\RuntimeException; use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag; /** @@ -65,7 +66,13 @@ class Configuration if ($specifications->isSetup()) { $configurations = $this->specifications->getConfigurations(); - $environment = $environment ? : $configurations[self::KEYWORD_ENV]; + if (!$environment) { + if (isset($configurations[self::KEYWORD_ENV])) { + $environment = $configurations[self::KEYWORD_ENV]; + } else { + throw new RuntimeException('No configuration environment provided'); + } + } } else { $environment = null; } @@ -85,6 +92,11 @@ class Configuration return $this->configuration->has($name); } + public function getSpecifications() + { + return $this->specifications; + } + /** * Return the current used environnement * @@ -109,7 +121,7 @@ class Configuration $configurations = $this->specifications->getConfigurations(); if ( ! isset($configurations[$this->environment])) { - throw new \Exception('Requested environnment is not available'); + throw new InvalidArgumentException('Requested environnment is not available'); } $this->configuration = new ParameterBag($configurations[$this->environment]); @@ -201,6 +213,11 @@ class Configuration return $this->specifications->setServices($services); } + public function resetServices($name = null) + { + return $this->specifications->resetServices($name); + } + public function setBinaries($binaries) { return $this->specifications->setBinaries($binaries); @@ -231,11 +248,6 @@ class Configuration return $this->specifications->getConnexions(); } - public function getSelectedEnvironnment() - { - return $this->selectedEnvironnment; - } - /** * Return the connexion parameters as configuration parameter object * diff --git a/lib/Alchemy/Phrasea/Core/Configuration/ApplicationSpecification.php b/lib/Alchemy/Phrasea/Core/Configuration/ApplicationSpecification.php index 091e332ee6..67165973df 100644 --- a/lib/Alchemy/Phrasea/Core/Configuration/ApplicationSpecification.php +++ b/lib/Alchemy/Phrasea/Core/Configuration/ApplicationSpecification.php @@ -13,20 +13,15 @@ namespace Alchemy\Phrasea\Core\Configuration; use Symfony\Component\HttpFoundation\File\File as SymfonyFile; use Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException; +use Symfony\Component\Yaml\Yaml; -/** - * Precise some informations about phraseanet configuration mechanism - * - * @license http://opensource.org/licenses/gpl-3.0 GPLv3 - * @link www.phraseanet.com - */ class ApplicationSpecification implements SpecificationInterface { protected $parser; public function __construct() { - $this->parser = new \Symfony\Component\Yaml\Yaml(); + $this->parser = new Yaml(); } public function setConfigurations($configurations) @@ -43,6 +38,26 @@ class ApplicationSpecification implements SpecificationInterface ); } + public function resetServices($name = null) + { + $services = $this->getServices(); + + if (!$name) { + $newServices = $services; + } else { + $newServices = $services; + $legacyServices = $this->parser->parse( + file_get_contents($this->getRealRootPath() . "/conf.d/services.yml") + ); + if (!isset($legacyServices[$name])) { + throw new InvalidArgumentException(sprintf('%s is not a valid service name')); + } + $newServices[$name] = $legacyServices[$name]; + } + + return $this->setServices($newServices); + } + public function setServices($services) { return file_put_contents( @@ -108,17 +123,17 @@ class ApplicationSpecification implements SpecificationInterface $this->delete(); copy( - $this->getRealRootPath() . "/config/connexions.sample.yml" + $this->getRealRootPath() . "/conf.d/connexions.yml" , $this->getConnexionsPathFile() ); copy( - $this->getRealRootPath() . "/config/services.sample.yml" + $this->getRealRootPath() . "/conf.d/services.yml" , $this->getServicesPathFile() ); copy( - $this->getRealRootPath() . "/config/config.sample.yml" + $this->getRealRootPath() . "/conf.d/config.yml" , $this->getConfigurationsPathFile() ); diff --git a/lib/Alchemy/Phrasea/Core/Configuration/SpecificationInterface.php b/lib/Alchemy/Phrasea/Core/Configuration/SpecificationInterface.php index af8ae36e2c..fb3ca9be47 100644 --- a/lib/Alchemy/Phrasea/Core/Configuration/SpecificationInterface.php +++ b/lib/Alchemy/Phrasea/Core/Configuration/SpecificationInterface.php @@ -19,13 +19,14 @@ namespace Alchemy\Phrasea\Core\Configuration; */ interface SpecificationInterface { - public function setConfigurations($configurations); public function setConnexions($connexions); public function setServices($services); + public function resetServices($name = null); + public function setBinaries($binaries); public function getConfigurations(); diff --git a/lib/Alchemy/Phrasea/Core/Version.php b/lib/Alchemy/Phrasea/Core/Version.php index 4ec4043b30..5910286f00 100644 --- a/lib/Alchemy/Phrasea/Core/Version.php +++ b/lib/Alchemy/Phrasea/Core/Version.php @@ -18,7 +18,7 @@ namespace Alchemy\Phrasea\Core; */ class Version { - protected static $number = '3.8.0.a2'; + protected static $number = '3.8.0.a3'; protected static $name = 'Carnosaurus'; public static function getNumber() diff --git a/lib/classes/patch/3803.php b/lib/classes/patch/3803.php index 123f09460e..e345a80ade 100644 --- a/lib/classes/patch/3803.php +++ b/lib/classes/patch/3803.php @@ -59,50 +59,53 @@ class patch_3803 implements patchInterface */ public function apply(base $appbox, Application $app) { - $searchEngine = $app['phraseanet.registry']->get('GV_sphinx') ? 'sphinx-search' : 'phrasea'; + $searchEngine = $app['phraseanet.registry']->get('GV_sphinx') ? 'sphinxsearch' : 'phrasea'; - $app['phraseanet.registry']->set('GV_search_engine', $searchEngine, \registry::TYPE_ENUM); + $confs = $app['phraseanet.configuration']->getConfigurations(); - $phraseaConfiguration = null; - $phraseaConfigFile = __DIR__ . '/../../../config/phrasea-engine.json'; - - if (file_exists($phraseaConfigFile)) { - $phraseaConfiguration = json_decode(file_get_contents($phraseaConfigFile), true); - } - if (!is_array($phraseaConfiguration)) { - $phraseaConfiguration = array(); + foreach ($confs as $env => $conf) { + if (in_array($env, array('environment', 'key'))) { + continue; + } + if (!isset($conf['search-engine'])) { + $confs[$env]['search-engine'] = $searchEngine; + } } - if ($app['phraseanet.registry']->get('GV_phrasea_sort')) { - $phraseaConfiguration['default_sort'] = $app['phraseanet.registry']->get('GV_phrasea_sort'); - } - - file_put_contents($phraseaConfigFile, $phraseaConfiguration); - - $sphinxConfiguration = null; - $sphinxConfigFile = __DIR__ . '/../../../config/sphinx-search.json'; + $app['phraseanet.configuration']->setConfigurations($confs); - if (file_exists($sphinxConfigFile)) { - $sphinxConfiguration = json_decode(file_get_contents($sphinxConfigFile), true); - } - if (!is_array($sphinxConfiguration)) { - $sphinxConfiguration = array(); + $services = $app['phraseanet.configuration']->getServices(); + + if (!isset($services['SearchEngine'])) { + $app['phraseanet.configuration']->resetServices('SearchEngine'); } - if ($app['phraseanet.registry']->get('GV_sphinx_rt_port')) { - $sphinxConfiguration['rt_port'] = $app['phraseanet.registry']->get('GV_sphinx_rt_port'); + if (!$app['phraseanet.registry']->get('GV_sphinx')) { + $phraseaConfiguration = $app['phraseanet.SE']->getConfigurationPanel()->getConfiguration(); + + if ($app['phraseanet.registry']->get('GV_phrasea_sort')) { + $phraseaConfiguration['default_sort'] = $app['phraseanet.registry']->get('GV_phrasea_sort'); + } + + $app['phraseanet.SE']->getConfigurationPanel()->saveConfiguration($phraseaConfiguration); + } else { + $sphinxConfiguration = $app['phraseanet.SE']->getConfigurationPanel()->getConfiguration(); + + if ($app['phraseanet.registry']->get('GV_sphinx_rt_port')) { + $sphinxConfiguration['rt_port'] = $app['phraseanet.registry']->get('GV_sphinx_rt_port'); + } + if ($app['phraseanet.registry']->get('GV_sphinx_rt_host')) { + $sphinxConfiguration['rt_host'] = $app['phraseanet.registry']->get('GV_sphinx_rt_host'); + } + if ($app['phraseanet.registry']->get('GV_sphinx_port')) { + $sphinxConfiguration['port'] = $app['phraseanet.registry']->get('GV_sphinx_port'); + } + if ($app['phraseanet.registry']->get('GV_sphinx_host')) { + $sphinxConfiguration['host'] = $app['phraseanet.registry']->get('GV_sphinx_host'); + } + + $app['phraseanet.SE']->getConfigurationPanel()->saveConfiguration($sphinxConfiguration); } - if ($app['phraseanet.registry']->get('GV_sphinx_rt_host')) { - $sphinxConfiguration['rt_host'] = $app['phraseanet.registry']->get('GV_sphinx_rt_host'); - } - if ($app['phraseanet.registry']->get('GV_sphinx_port')) { - $sphinxConfiguration['port'] = $app['phraseanet.registry']->get('GV_sphinx_port'); - } - if ($app['phraseanet.registry']->get('GV_sphinx_host')) { - $sphinxConfiguration['host'] = $app['phraseanet.registry']->get('GV_sphinx_host'); - } - - file_put_contents($sphinxConfigFile, $sphinxConfiguration); return; } diff --git a/lib/classes/patch/3804.php b/lib/classes/patch/3804.php new file mode 100644 index 0000000000..820f2c034b --- /dev/null +++ b/lib/classes/patch/3804.php @@ -0,0 +1,84 @@ +release; + } + + public function require_all_upgrades() + { + return false; + } + + /** + * + * @return Array + */ + public function concern() + { + return $this->concern; + } + + /** + * @param base $appbox + */ + public function apply(base $appbox, Application $app) + { + try { + $confs = $app['phraseanet.configuration']->getConfigurations(); + + foreach ($confs as $env => $conf) { + if (in_array($env, array('environment', 'key'))) { + continue; + } + if (!isset($conf['task-manager'])) { + $confs[$env]['task-manager'] = 'task_manager'; + } + } + + $app['phraseanet.configuration']->setConfigurations($confs); + + $services = $app['phraseanet.configuration']->getServices(); + + if (!isset($services['TaskManager'])) { + $app['phraseanet.configuration']->resetServices('TaskManager'); + } + + return true; + } catch (\Exception $e) { + throw $e; + } + + return false; + } +} + diff --git a/lib/conf.d/config.yml b/lib/conf.d/config.yml new file mode 100644 index 0000000000..589e80ebf0 --- /dev/null +++ b/lib/conf.d/config.yml @@ -0,0 +1,72 @@ +#Here's the main configuration file which is loaded when phraseanet bootstraps + +#Declare which environment will be used by the application + +environment : prod +key : null + +#Declare all your environment configurations + +################# +# DEVELOPPEMENT # +################# +dev: + #Phraseanet refers to phraseanet app specific configuration + phraseanet: + servername: 'http://sub.domain.tld/' + maintenance: false + debug: true + display_errors: true + + #Assign your phraseanet application connection + #Connections are defined in connexions.yml configuration file + database: main_connexion + + #Assign your template engine service & ORM service + #Services are defined in service.yml configuration file + template_engine: twig_debug + orm: doctrine_dev + cache: array_cache + opcodecache: array_cache + border-manager: border_manager + search-engine: phrasea + task-manager: task_manager + +############## +# PRODUCTION # +############## +prod: + phraseanet: + servername: 'http://sub.domain.tld/' + maintenance: false + debug: false + display_errors: false + database: main_connexion + + template_engine: twig + orm: doctrine_prod + cache: array_cache + opcodecache: array_cache + border-manager: border_manager + search-engine: phrasea + task-manager: task_manager + +############## +# TEST # +############## +test: + phraseanet: + servername: 'http://sub.domain.tld/' + maintenance: false + debug: true + display_errors: true + database: main_connexion + + template_engine: twig_debug + orm: doctrine_test + cache: array_cache + opcodecache: array_cache + border-manager: border_manager + search-engine: phrasea + task-manager: task_manager + diff --git a/lib/conf.d/connexions.yml b/lib/conf.d/connexions.yml new file mode 100644 index 0000000000..420770688a --- /dev/null +++ b/lib/conf.d/connexions.yml @@ -0,0 +1,19 @@ +#Here you can define many connexions configurations +#Please refer to Doctrine documentation abstraction layer for database connection configuration +#DBAL connection : http://www.doctrine-project.org/docs/dbal/2.1/en/reference/configuration.html + +#Define a connexion to MYSQL database named main_connexion +main_connexion: + host: + port: + user: + password: + dbname: + driver: pdo_mysql + charset: UTF8 + +#Define a connexion to a SQLite database named test_connexion +test_connexion: + driver: pdo_sqlite + path: '/tmp/db.sqlite' + charset: UTF8 diff --git a/lib/conf.d/services.yml b/lib/conf.d/services.yml new file mode 100644 index 0000000000..ebb7b27eb5 --- /dev/null +++ b/lib/conf.d/services.yml @@ -0,0 +1,215 @@ +#base service file +Orm: + #Doctrine developement service options + #Service name + doctrine_dev: + type: Orm\Doctrine + options: + #Set automatically propers values for debug + #Query & result caches are setted to Array cache + #Auto-generating Proxy Classes is setted to false + debug: true + #Assign a connexion from connexions.yml to the DataBase Abstraction Layer + dbal: main_connexion + #Available cache driver [memcached, apc, array] + #Query cache : is used to cache the transformation of a DQL query to its SQL counterpart + #Result cache : is used to cache the results of your queries + #Metadata cache : is used to cache entity class metadatas + #If No cache is provided all cache are setted to default_cache which is an array cache type + cache: + query: + service: Cache\array_cache + result: + service: Cache\array_cache + metadata: + service: Cache\array_cache + # Assign a service to log doctrine queries + log: + service: Log\query_logger + + # Doctrine test service options + doctrine_test: + type: Orm\Doctrine + options: + debug: true + #Doctrine use a different connection configuration base to run tests + dbal: test_connexion + cache: + query: + service: Cache\array_cache + result: + service: Cache\array_cache + metadata: + service: Cache\array_cache + log: + service: Log\query_logger + + # Doctrine production service options + doctrine_prod: + type: Orm\Doctrine + options: + debug: false + dbal: main_connexion + cache: + query: + service: Cache\array_cache + result: + service: Cache\array_cache + metadata: + service: Cache\array_cache + +TemplateEngine: + #Define a template engine service + #Only Twig is avalaible as a template engine service + #see http://twig.sensiolabs.org/ + + #Define the service name first + twig: + #Template engine type + type: TemplateEngine\Twig + options: + #When set to true, the generated templates have a __toString() method that you can use to display the generated nodes + debug: false + #The charset used by the templates + charset: utf-8 + #Twig will silently ignore invalid variables (variables and or attributes/methods that do not exist) + #And replace them with a null value. When set to true, Twig throws an exception instead (default to false) + strict_variables: false + autoescape: true + #Optimize the node tree before compilation + optimizer: true + + twig_debug: + type: TemplateEngine\Twig + options: + debug: true + charset: utf-8 + strict_variables: true + autoescape: true + optimizer: true + + +Log: + # Define a Log service + # This one is defined to handle the logs of doctrine queries + # Only Monolog is available as a logger service + # Please Notice that for doctrine ONLY a echo logger service is available, see below + # Monolog logger use the PHP Monolog library to handle logs using differents handlers + query_logger: + type: Log\Doctrine\Monolog + options: + #You can precise the output format + #This option is only available when log are used to log doctrine queries + #Available output [vdump, json, yaml] + # vdump : output logs in a var_dump formatted style + # json : output logs in json + # yml : output logs yml + output: json + #Name used for the Monolog channel + channel: query-logger + #Define how the logs will be handled + #Avalaibale Handler are [rotate, stream] + #Rotate handler is used to stores logs to files that are rotated every day + #And a limited number of files are kept by defining the max_day value + #Stream handler is used to stores logs in a single local file + handler: rotate + max_day: 2 + #Name of the file where logs are written + filename: doctrine-query.log + + # Define a phpecho log service for Doctrine + # phpecho logger logs doctrine queries to the standard output using echo/var_dump + # Notice that phpecho logger do not have options + sql_logger: + type: Log\Doctrine\Phpecho + +Cache: + #Define cache services + #There are Four different cache type available [array, xcache, apc, memcache] + #Only a memcache service can take option to define port & host for the memcache server + array_cache: + type: Cache\ArrayCache + + memcache_cache: + type: Cache\MemcacheCache + options: + host: localhost + port: 11211 + + apc_cache: + type: Cache\ApcCache + + xcache_cache: + type: Cache\XcacheCache + + wincache_cache: + type: Cache\WinCacheCache + +Border: + #Define Border service + #The border service handles checks validation constraints against incoming files + border_manager: + type: Border\BorderManager + options: + #Enable validation on incoming files + enabled: true + checkers: + #Check for duplicated file based on their sha256 check sum + - + type: Checker\Sha256 + enabled: true + #Check for duplicated file based on their UUID + - + type: Checker\UUID + enabled: true + #Check colorspace (if applicable) + - + type: Checker\Colorspace + enabled: false + options: + colorspaces: [cmyk, grayscale, rgb] + #Check file dimension (if applicable) + - + type: Checker\Dimension + enabled: false + options: + width: 80 + height: 160 + #Check file extension + #set to false to enable all file extensions + - + type: Checker\Extension + enabled: false + options: + extensions: [jpg, jpeg, bmp, tif, gif, png, pdf, doc, odt, mpg, mpeg, mov, avi, xls, flv, mp3, mp2] + #Check filename + - + type: Checker\Filename + enabled: false + options: + sensitive: true + #Check media type + #Set to false to enable all mediatype + - + type: Checker\MediaType + enabled: false + options: + mediatypes: [Audio, Document, Flash, Image, Video] +SearchEngine: + phrasea: + type: SearchEngine\PhraseaEngine + sphinxsearch: + type: SearchEngine\SphinxSearch + options: + host: localhost + port: 9306 + rt_host: localhost + rt_port: 9308 +TaskManager: + task_manager: + type: TaskManager\TaskManager + options: + # set the threshold for sending task logs to syslog or by mail + # values : task_abstract::[LOG_DEBUG | LOG_INFO | LOG_WARNING | LOG_ERROR | LOG_CRITICAL | LOG_ALERT] + syslog_level: task_abstract::LOG_ERROR + maillog_level: task_abstract::LOG_ERROR diff --git a/tests/Alchemy/Tests/Phrasea/Application/ApiAbstract.php b/tests/Alchemy/Tests/Phrasea/Application/ApiAbstract.php index f5a4c703d3..373b304216 100644 --- a/tests/Alchemy/Tests/Phrasea/Application/ApiAbstract.php +++ b/tests/Alchemy/Tests/Phrasea/Application/ApiAbstract.php @@ -237,8 +237,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->evaluateMeta200($content); $response = $content['response']; - $task_manager = new \task_manager(self::$DI['app']); - $tasks = $task_manager->getTasks(); + $tasks = self::$DI['app']['task-manager']->getTasks(); $this->assertEquals(count($tasks), count($response['tasks'])); foreach ($response['tasks'] as $task) { @@ -326,8 +325,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract */ public function testGetMonitorTaskById() { - $task_manager = new \task_manager(self::$DI['app']); - $tasks = $task_manager->getTasks(); + $tasks = self::$DI['app']['task-manager']->getTasks(); if (null === self::$adminToken) { $this->markTestSkipped('there is no user with admin rights'); @@ -359,8 +357,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract */ public function testPostMonitorTaskById() { - $task_manager = new \task_manager(self::$DI['app']); - $tasks = $task_manager->getTasks(); + $tasks = self::$DI['app']['task-manager']->getTasks(); if (null === self::$adminToken) { $this->markTestSkipped('there is no user with admin rights'); @@ -415,8 +412,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->markTestSkipped('there is no user with admin rights'); } - $task_manager = new \task_manager(self::$DI['app']); - $tasks = $task_manager->getTasks(); + $tasks = self::$DI['app']['task-manager']->getTasks(); if (!count($tasks)) { $this->markTestSkipped('no tasks created for the current instance'); @@ -437,8 +433,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->assertArrayHasKey('task', $content['response']); $this->evaluateGoodTask($content['response']['task']); - $task_manager->getTasks(true); - $task = $task_manager->getTask($idTask); + $task = self::$DI['app']['task-manager']->getTask($idTask); $this->assertContains($task->getState(), array(\task_abstract::STATE_TOSTART, \task_abstract::STATE_STARTED)); } @@ -448,9 +443,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract */ public function testPostMonitorStopTask() { - $task_manager = new \task_manager(self::$DI['app']); - - $tasks = $task_manager->getTasks(); + $tasks = self::$DI['app']['task-manager']->getTasks(); if (null === self::$adminToken) { $this->markTestSkipped('there is no user with admin rights'); @@ -475,8 +468,7 @@ abstract class ApiAbstract extends \PhraseanetWebTestCaseAbstract $this->assertArrayHasKey('task', $content['response']); $this->evaluateGoodTask($content['response']['task']); - $task_manager->getTasks(true); - $task = $task_manager->getTask($idTask); + $task = self::$DI['app']['task-manager']->getTask($idTask); $this->assertContains($task->getState(), array(\task_abstract::STATE_TOSTOP, \task_abstract::STATE_STOPPED)); } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Configuration/ConfigurationTest.php b/tests/Alchemy/Tests/Phrasea/Core/Configuration/ConfigurationTest.php deleted file mode 100644 index b6fda1a3a8..0000000000 --- a/tests/Alchemy/Tests/Phrasea/Core/Configuration/ConfigurationTest.php +++ /dev/null @@ -1,387 +0,0 @@ -markTestSkipped('To rewrite'); - parent::setUp(); - - $this->stubNotInstalled = $this->getMock( - '\Alchemy\Phrasea\Core\Configuration\Application' - , array('getConfigurationsFile') - ); - - $this->stubNotInstalled->expects($this->any()) - ->method('getConfigurationsFile') - ->will( - $this->throwException(new Exception) - ); - - $this->stubExperience = $this->getMock( - '\Alchemy\Phrasea\Core\Configuration\Application' - , array('getConfigurationsFile') - ); - - $this->stubExperience->expects($this->any()) - ->method('getConfigurationsFile') - ->will( - $this->returnValue( - new \SplFileObject(__DIR__ . '/confTestFiles/config.yml') - ) - ); - - $handler = new Configuration\Handler($this->stubNotInstalled); - $this->confNotInstalled = new PhraseaCore\Configuration($handler); - - - $handler = new Configuration\Handler($this->stubExperience); - $this->object = new PhraseaCore\Configuration($handler); - - - touch(__DIR__ . "/confTestFiles/yamlWriteTest.yml"); - - $this->stubConfTest = $this->getMock( - '\Alchemy\Phrasea\Core\Configuration\Application' - , array('getConfigurationPathName') - ); - - $file = new \SplFileObject(__DIR__ . "/confTestFiles/yamlWriteTest.yml"); - - $this->stubConfTest->expects($this->any()) - ->method('getConfigurationPathName') - ->will( - $this->returnValue($file->getPathname()) - ); - } - - public function testGetEnvironment() - { - $this->assertEquals("dev", $this->object->getEnvironnement()); - $this->assertEquals(null, $this->confNotInstalled->getEnvironnement()); - } - - public function testSetEnvironment() - { - $this->object->setEnvironnement("test"); - $this->assertEquals("test", $this->object->getEnvironnement()); - $this->confNotInstalled->setEnvironnement("prod"); - $this->assertEquals("prod", $this->confNotInstalled->getEnvironnement()); - - try { - $this->object->setEnvironnement("unknow"); - $this->fail("should raise exception"); - } catch (\Exception $e) { - - } - } - - public function testIsDebug() - { - $this->object->setEnvironnement("test"); - $this->assertTrue($this->object->isDebug()); - $this->object->setEnvironnement("dev"); - $this->assertTrue($this->object->isDebug()); - $this->object->setEnvironnement("prod"); - $this->assertFalse($this->object->isDebug()); - $this->object->setEnvironnement("no_debug"); - $this->assertFalse($this->object->isDebug()); - } - - public function testIsMaintened() - { - $this->object->setEnvironnement("test"); - $this->assertFalse($this->object->isMaintained()); - $this->object->setEnvironnement("dev"); - $this->assertFalse($this->object->isMaintained()); - $this->object->setEnvironnement("prod"); - $this->assertFalse($this->object->isMaintained()); - $this->object->setEnvironnement("no_maintenance"); - $this->assertFalse($this->object->isMaintained()); - } - - public function testIsDisplayingErrors() - { - $this->object->setEnvironnement("test"); - $this->assertTrue($this->object->isDisplayingErrors()); - $this->object->setEnvironnement("dev"); - $this->assertTrue($this->object->isDisplayingErrors()); - $this->object->setEnvironnement("prod"); - $this->assertFalse($this->object->isDisplayingErrors()); - $this->object->setEnvironnement("no_display_errors"); - $this->assertFalse($this->object->isDisplayingErrors()); - } - - public function testGetPhraseanet() - { - $this->object->setEnvironnement("test"); - $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $this->object->getPhraseanet()); - $this->object->setEnvironnement("dev"); - $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $this->object->getPhraseanet()); - $this->object->setEnvironnement("prod"); - $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $this->object->getPhraseanet()); - $this->object->setEnvironnement("missing_phraseanet"); - try { - $this->object->getPhraseanet(); - $this->fail("should raise an exeception"); - } catch (\Exception $e) { - - } - } - - public function testGetConfiguration() - { - $config = $this->object->getConfiguration(); - $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $config); - $this->assertNotEmpty($config->all()); - $config = $this->confNotInstalled->getConfiguration(); - $this->assertEmpty($config->all()); - } - - public function testGetConnexions() - { - $connexions = $this->object->getConnexions(); - $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $connexions); - $this->assertGreaterThan(0, sizeof($connexions->all())); - } - - public function testGetConnexion() - { - $connexion = $this->object->getConnexion(); - $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $connexion); - $this->assertGreaterThan(0, sizeof($connexion->all())); - } - - public function testGetConnexionException() - { - try { - $this->object->getConnexion('unknow_connexion'); - $this->fail('should raise an exception'); - } catch (\Exception $e) { - - } - } - - public function testGetFile() - { - $this->assertInstanceOf("\SplFileObject", $this->object->getFile()); - } - - public function testGetFileExeption() - { - try { - $this->assertInstanceOf("\SplFileObject", $this->confNotInstalled->getFile()); - $this->fail("should raise an excpetion"); - } catch (\Exception $e) { - - } - } - - public function testAll() - { - $all = $this->object->all(); - $this->assertTrue(is_array($all)); - $this->assertArrayHasKey("test", $all); - $this->assertArrayHasKey("dev", $all); - $this->assertArrayHasKey("prod", $all); - $this->assertArrayHasKey("environment", $all); - } - - public function testGetServices() - { - $services = $this->object->getServices(); - $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $services); - $this->assertGreaterThan(0, sizeof($services->all())); - } - - public function testGetService() - { - $services = $this->object->getService('TemplateEngine\Twig'); - $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $services); - $this->assertGreaterThan(0, sizeof($services->all())); - } - - public function testGetServiceException() - { - try { - $this->object->getService('unknow_service'); - $this->fail('should raise an exception'); - } catch (\Exception $e) { - - } - } - - public function testWrite() - { - $handler = new Configuration\Handler($this->stubConfTest); - - $configuration = new PhraseaCore\Configuration($handler); - - $arrayToBeWritten = array( - 'hello' => 'world' - , 'key' => array( - 'keyone' => 'valueone' - , 'keytwo' => 'valuetwo' - ) - ); - - $configuration->write($arrayToBeWritten, 0, true); - - $all = $configuration->all(); - - $this->assertArrayHasKey("hello", $all); - $this->assertArrayHasKey("key", $all); - $this->assertTrue(is_array($all["key"])); - } - - public function testWriteException() - { - $handler = new Configuration\Handler($this->stubConfTest); - - $configuration = new PhraseaCore\Configuration($handler); - - $arrayToBeWritten = array( - 'hello' => 'world' - , 'key' => array( - 'keyone' => 'valueone' - , 'keytwo' => 'valuetwo' - ) - ); - - try { - $configuration->write($arrayToBeWritten); - $this->fail("should raise an exception"); - } catch (\exception $e) { - - } - } - - public function testDelete() - { - $handler = new Configuration\Handler($this->stubConfTest); - - $configuration = new PhraseaCore\Configuration($handler); - - $configuration->delete(); - - $this->assertFileNotExists($file->getPathname()); - } - - public function testDeleteException() - { - $handler = new Configuration\Handler($this->stubConfTest); - - $configuration = new PhraseaCore\Configuration($handler); - - try { - $configuration->delete(); - $this->fail("should raise an exception"); - } catch (\Exception $e) { - - } - - $this->assertFileExists($file->getPathname()); - - unlink(__DIR__ . "/confTestFiles/yamlWriteTest.yml"); - } - - public function testGetTemplating() - { - try { - $templating = $this->object->getTemplating(); - } catch (\Exception $e) { - $this->fail("not template_engine provided"); - } - $this->assertTrue(is_string($templating)); - } - - public function testGetOrm() - { - try { - $orm = $this->object->getOrm(); - } catch (\Exception $e) { - $this->fail("not template_engine provided"); - } - $this->assertTrue(is_string($orm)); - } - - public function testGetServiceFile() - { - $this->assertInstanceOf("\SplFileObject", $this->object->getServiceFile()); - } - - public function testGetConnexionFile() - { - $this->assertInstanceOf("\SplFileObject", $this->object->getConnexionFile()); - } - - public function testRefresh() - { - $this->confNotInstalled->refresh(); - $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $this->confNotInstalled->getConfiguration()); - - $handler = new Configuration\Handler($this->stubConfTest); - - $configuration = new PhraseaCore\Configuration($handler); - - $newScope = array("prod" => array('key' => 'value', 'key2' => 'value2')); - - //append new conf - $configuration->write($newScope, FILE_APPEND); - - try { - $configuration->getConfiguration(); //it is not loaded - $this->fail("should raise an exception"); - } catch (\Exception $e) { - - } - - $configuration->refresh(); //reload conf - $prod = $configuration->getConfiguration(); - $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag", $prod); - - unlink(__DIR__ . "/confTestFiles/yamlWriteTest.yml"); - } -} - diff --git a/tests/Alchemy/Tests/Phrasea/Core/Configuration/confTestFiles/config.yml b/tests/Alchemy/Tests/Phrasea/Core/Configuration/confTestFiles/config.yml deleted file mode 100644 index c9e7870da4..0000000000 --- a/tests/Alchemy/Tests/Phrasea/Core/Configuration/confTestFiles/config.yml +++ /dev/null @@ -1,69 +0,0 @@ -environment: dev -dev: - phraseanet: - servername: 'http://dev.phrasea.net/' - maintenance: false - debug: true - display_errors: true - database: main_connexion - template_engine: twig_debug - orm: doctrine_dev - cache: array_cache -prod: - phraseanet: - servername: 'http://dev.phrasea.net/' - maintenance: false - debug: false - display_errors: false - database: main_connexion - template_engine: twig - orm: doctrine_prod - cache: apc_cache -test: - phraseanet: - servername: 'http://dev.phrasea.net/' - maintenance: false - debug: true - display_errors: true - database: main_connexion - template_engine: twig_debug - orm: doctrine_test - cache: array_cache - -no_debug: - phraseanet: - servername: 'http://dev.phrasea.net/' - maintenance: false - ##debug: true - display_errors: true - database: main_connexion - template_engine: twig_debug - orm: doctrine_test - cache: array_cache - -no_maintenance: - phraseanet: - servername: 'http://dev.phrasea.net/' - ##maintenance: false - debug: true - display_errors: true - database: main_connexion - template_engine: twig_debug - orm: doctrine_test - cache: array_cache - -no_display_errors: - phraseanet: - servername: 'http://dev.phrasea.net/' - maintenance: false - debug: true - ##display_errors: true - database: main_connexion - template_engine: twig_debug - orm: doctrine_test - cache: array_cache - -missing_phraseanet: - template_engine: twig_debug - orm: doctrine_test - cache: array_cache diff --git a/tests/Alchemy/Tests/Phrasea/Core/Configuration/confTestFiles/test.json b/tests/Alchemy/Tests/Phrasea/Core/Configuration/confTestFiles/test.json deleted file mode 100644 index 43133b13c7..0000000000 --- a/tests/Alchemy/Tests/Phrasea/Core/Configuration/confTestFiles/test.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "meta": { - "api_version": "1.0", - "request": "GET /api/v1/feeds/288/content/", - "response_time": "2011-07-27T15:52:04+02:00", - "http_code": 200, - "error_message": null, - "error_details": null, - "charset": "UTF-8" - }, - "response": {} -} \ No newline at end of file diff --git a/tests/Alchemy/Tests/Phrasea/Core/ConfigurationTest.php b/tests/Alchemy/Tests/Phrasea/Core/ConfigurationTest.php new file mode 100644 index 0000000000..36eb937ec9 --- /dev/null +++ b/tests/Alchemy/Tests/Phrasea/Core/ConfigurationTest.php @@ -0,0 +1,702 @@ +getSetupedSpecifications(array('dev' => array())); + + $configuration = Configuration::build($specifications, 'dev'); + + $this->assertEquals('dev', $configuration->getEnvironnement()); + $this->assertEquals($specifications, $configuration->getSpecifications()); + } + + /** + * @test + * @covers Alchemy\Phrasea\Core\Configuration::build + */ + public function buildShouldFailIfTheRequiredEnvironmentDoesNotExist() + { + $specifications = $this->getSetupedSpecifications(array('prod' => array())); + + try { + Configuration::build($specifications, 'dev'); + $this->fail('Should have raised an exception'); + } catch (InvalidArgumentException $e) { + + } + } + + /** + * @test + * @covers Alchemy\Phrasea\Core\Configuration::build + */ + public function environmentShouldBeNullIsTheSpecsAreNotSetup() + { + $specifications = $this->getNotSetupedSpecifications(); + $configuration = Configuration::build($specifications, 'dev'); + + $this->assertNull($configuration->getEnvironnement()); + $this->assertEquals($specifications, $configuration->getSpecifications()); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::get + */ + public function testGet() + { + $specifications = $this->getSetupedSpecifications(array('dev' => array('pif' => 'pouf'))); + $configuration = Configuration::build($specifications, 'dev'); + + $this->assertEquals('pouf', $configuration->get('pif')); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::get + */ + public function testGetOnNonExistentParameterShouldFail() + { + $specifications = $this->getSetupedSpecifications(array('dev' => array('pif' => 'pouf'))); + $configuration = Configuration::build($specifications, 'dev'); + + try { + $configuration->get('paf'); + $this->fail('Should have raised an exception'); + } catch (ParameterNotFoundException $e) { + + } + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::has + */ + public function testHas() + { + $specifications = $this->getSetupedSpecifications(array('dev' => array('pif' => 'pouf'))); + $configuration = Configuration::build($specifications, 'dev'); + + $this->assertTrue($configuration->has('pif')); + $this->assertFalse($configuration->has('paf')); + } + + /** + * @test + * @covers Alchemy\Phrasea\Core\Configuration::build + */ + public function defaultEnvironmentShouldBeTheOneInTheEnvironmentKey() + { + $specifications = $this->getSetupedSpecifications(array('environment' => 'dave', 'dave' => array('pif' => 'pouf'))); + $configuration = Configuration::build($specifications); + + $this->assertEquals('dave', $configuration->getEnvironnement()); + $this->assertEquals($specifications, $configuration->getSpecifications()); + } + + /** + * @test + * @covers Alchemy\Phrasea\Core\Configuration::build + */ + public function anErrorShouldBeThrownIfNoEnvironmentProvided() + { + $specifications = $this->getSetupedSpecifications(array('dave' => array('pif' => 'pouf'))); + + try { + Configuration::build($specifications); + $this->fail('Should have raised an exception'); + } catch (RuntimeException $e) { + + } + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::setEnvironnement + * @covers Alchemy\Phrasea\Core\Configuration::getEnvironnement + */ + public function testSetEnvironnementShouldSetTheEnvironment() + { + $specifications = $this->getSetupedSpecifications(array('dev' => array('pif' => 'pouf'), 'prod' => array('bim' => 'bame'))); + $configuration = Configuration::build($specifications, 'dev'); + + $this->assertEquals('dev', $configuration->getEnvironnement()); + $this->assertTrue($configuration->has('pif')); + $this->assertFalse($configuration->has('bim')); + + $configuration->setEnvironnement('prod'); + $this->assertEquals('prod', $configuration->getEnvironnement()); + $this->assertFalse($configuration->has('pif')); + $this->assertTrue($configuration->has('bim')); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::setEnvironnement + * @covers Alchemy\Phrasea\Core\Configuration::getEnvironnement + */ + public function testSetEnvironnementShouldThrowAnExceptionIfEnvironmentDoesNotExists() + { + $specifications = $this->getSetupedSpecifications(array('dev' => array('pif' => 'pouf'), 'prod' => array('bim' => 'bame'))); + $configuration = Configuration::build($specifications, 'dev'); + + try { + $configuration->setEnvironnement('test'); + $this->fail('Should have raised an exception'); + } catch (InvalidArgumentException $e) { + + } + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::getEnvironnement + * @covers Alchemy\Phrasea\Core\Configuration::setEnvironnement + */ + public function testSetEnvironnementWhenSetupNotReadyShouldAlwaysWork() + { + $specifications = $this->getNotSetupedSpecifications(); + $configuration = Configuration::build($specifications, 'dev'); + + $configuration->setEnvironnement('prout'); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::isDebug + */ + public function testIsDebugIsFalseWhileSetup() + { + $specifications = $this->getNotSetupedSpecifications(); + $configuration = Configuration::build($specifications); + + $this->assertFalse($configuration->isDebug()); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::isDebug + */ + public function testIsDebugIsFalseByDefault() + { + $specifications = $this->getSetupedSpecifications(array('dev' => array())); + $configuration = Configuration::build($specifications, 'dev'); + + $this->assertFalse($configuration->isDebug()); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::isDebug + */ + public function testIsDebug() + { + $specifications = $this->getSetupedSpecifications(array('dev' => array('phraseanet' => array('debug' => true)))); + $configuration = Configuration::build($specifications, 'dev'); + + $this->assertTrue($configuration->isDebug()); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::isMaintained + */ + public function testIsMaintainedIsFalseWhileSetup() + { + $specifications = $this->getNotSetupedSpecifications(); + $configuration = Configuration::build($specifications); + + $this->assertFalse($configuration->isMaintained()); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::isMaintained + */ + public function testIsMaintainedIsFalseByDefault() + { + $specifications = $this->getSetupedSpecifications(array('dev' => array())); + $configuration = Configuration::build($specifications, 'dev'); + + $this->assertFalse($configuration->isMaintained()); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::isMaintained + */ + public function testIsMaintained() + { + $specifications = $this->getSetupedSpecifications(array('dev' => array('phraseanet' => array('maintenance' => true)))); + $configuration = Configuration::build($specifications, 'dev'); + + $this->assertTrue($configuration->isMaintained()); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::isDisplayingErrors + */ + public function testIsDisplayingErrorsIsFalseWhileSetup() + { + $specifications = $this->getNotSetupedSpecifications(); + $configuration = Configuration::build($specifications); + + $this->assertFalse($configuration->isDisplayingErrors()); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::isDisplayingErrors + */ + public function testIsDisplayingErrorsIsFalseByDefault() + { + $specifications = $this->getSetupedSpecifications(array('dev' => array())); + $configuration = Configuration::build($specifications, 'dev'); + + $this->assertFalse($configuration->isDisplayingErrors()); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::isDisplayingErrors + */ + public function testIsDisplayingErrors() + { + $specifications = $this->getSetupedSpecifications(array('dev' => array('phraseanet' => array('display_errors' => true)))); + $configuration = Configuration::build($specifications, 'dev'); + + $this->assertTrue($configuration->isDisplayingErrors()); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::getPhraseanet + */ + public function testGetPhraseanet() + { + $phraseanet = array('display_errors' => true); + + $specifications = $this->getSetupedSpecifications(array('dev' => array('phraseanet' => $phraseanet))); + $configuration = Configuration::build($specifications, 'dev'); + + $this->assertInstanceOf('Symfony\Component\DependencyInjection\ParameterBag\ParameterBag', $configuration->getPhraseanet()); + $this->assertEquals($phraseanet, $configuration->getPhraseanet()->all()); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::initialize + */ + public function testInitialize() + { + $specifications = $this->getNotSetupedSpecifications(); + $specifications->expects($this->once()) + ->method('initialize'); + + $configuration = Configuration::build($specifications); + $configuration->initialize(); + + $this->assertEquals('prod', $configuration->getEnvironnement()); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::delete + */ + public function testDelete() + { + $specifications = $this->getSetupedSpecifications(array('prod' => array())); + $specifications->expects($this->once()) + ->method('delete'); + + $configuration = Configuration::build($specifications, 'prod'); + $configuration->delete(); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::setConfigurations + */ + public function testSetConfigurations() + { + $conf = array('prod' => array('bim' => 'boum')); + + $specifications = $this->getSetupedSpecifications(array('prod' => array())); + $specifications->expects($this->once()) + ->method('setConfigurations') + ->with($this->equalTo($conf)); + + $configuration = Configuration::build($specifications, 'prod'); + $configuration->setConfigurations($conf); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::setServices + */ + public function testSetServices() + { + $services = array('Template' => array()); + + $specifications = $this->getSetupedSpecifications(array('prod' => array())); + $specifications->expects($this->once()) + ->method('setServices') + ->with($this->equalTo($services)); + + $configuration = Configuration::build($specifications, 'prod'); + $configuration->setServices($services); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::resetServices + */ + public function testResetAllServices() + { + $specifications = $this->getSetupedSpecifications(array('prod' => array())); + $specifications->expects($this->once()) + ->method('resetServices') + ->with($this->equalTo(null)); + + $configuration = Configuration::build($specifications, 'prod'); + $configuration->resetServices(); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::resetServices + */ + public function testResetByName() + { + $name = 'coool-service'; + + $specifications = $this->getSetupedSpecifications(array('prod' => array())); + $specifications->expects($this->once()) + ->method('resetServices') + ->with($this->equalTo($name)); + + $configuration = Configuration::build($specifications, 'prod'); + $configuration->resetServices($name); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::setBinaries + */ + public function testSetBinaries() + { + $binaries = array('binarie' => array('php' => '/usr/local/bin/php')); + + $specifications = $this->getSetupedSpecifications(array('prod' => array())); + $specifications->expects($this->once()) + ->method('setBinaries') + ->with($this->equalTo($binaries)); + + $configuration = Configuration::build($specifications, 'prod'); + $configuration->setBinaries($binaries); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::setConnexions + */ + public function testSetConnexions() + { + $connexions = array('main' => array('path' => '/usr/local/db')); + + $specifications = $this->getSetupedSpecifications(array('prod' => array())); + $specifications->expects($this->once()) + ->method('setConnexions') + ->with($this->equalTo($connexions)); + + $configuration = Configuration::build($specifications, 'prod'); + $configuration->setConnexions($connexions); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::getConfigurations + */ + public function testGetConfigurations() + { + $specifications = $this->getNotSetupedSpecifications(); + $specifications->expects($this->once()) + ->method('getConfigurations'); + + $configuration = Configuration::build($specifications, 'prod'); + $configuration->getConfigurations(); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::getServices + */ + public function testGetServices() + { + $specifications = $this->getSetupedSpecifications(array('prod' => array())); + $specifications->expects($this->once()) + ->method('getServices'); + + $configuration = Configuration::build($specifications, 'prod'); + $configuration->getServices(); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::getBinaries + */ + public function testGetBinaries() + { + $specifications = $this->getSetupedSpecifications(array('prod' => array())); + $specifications->expects($this->once()) + ->method('getBinaries'); + + $configuration = Configuration::build($specifications, 'prod'); + $configuration->getBinaries(); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::getConnexions + */ + public function testGetConnexions() + { + $specifications = $this->getSetupedSpecifications(array('prod' => array())); + $specifications->expects($this->once()) + ->method('getConnexions'); + + $configuration = Configuration::build($specifications, 'prod'); + $configuration->getConnexions(); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::getConnexion + */ + public function testGetConnexion() + { + $testConnexion = array('path' => '/tmp/db'); + + $specifications = $this->getSetupedSpecifications(array('prod' => array())); + $specifications->expects($this->once()) + ->method('getConnexions') + ->will($this->returnValue(array('test' => $testConnexion))); + + $configuration = Configuration::build($specifications, 'prod'); + + $conn = $configuration->getConnexion('test'); + + $this->assertInstanceOf('Symfony\Component\DependencyInjection\ParameterBag\ParameterBag', $conn); + $this->assertEquals($testConnexion, $conn->all()); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::getConnexion + */ + public function testGetConnexionThatDoesNotExist() + { + $testConnexion = array('path' => '/tmp/db'); + + $specifications = $this->getSetupedSpecifications(array('prod' => array())); + $specifications->expects($this->once()) + ->method('getConnexions') + ->will($this->returnValue(array('test' => $testConnexion))); + + $configuration = Configuration::build($specifications, 'prod'); + + try { + $configuration->getConnexion('not-exists'); + $this->fail('Should have raised an exception'); + } catch (InvalidArgumentException $e) { + + } + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::getTemplating + */ + public function testGetTemplating() + { + $specifications = $this->getSetupedSpecifications(array( + 'prod' => array('template_engine' => 'ObjectTwig') + )); + + $configuration = Configuration::build($specifications, 'prod'); + $this->assertEquals('TemplateEngine\\ObjectTwig', $configuration->getTemplating()); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::getCache + */ + public function testGetCache() + { + $specifications = $this->getSetupedSpecifications(array( + 'prod' => array('cache' => 'ObjectCache') + )); + + $configuration = Configuration::build($specifications, 'prod'); + $this->assertEquals('Cache\\ObjectCache', $configuration->getCache()); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::getOpcodeCache + */ + public function testGetOpcodeCache() + { + $specifications = $this->getSetupedSpecifications(array( + 'prod' => array('opcodecache' => 'ObjectOpcodeCache') + )); + + $configuration = Configuration::build($specifications, 'prod'); + $this->assertEquals('Cache\\ObjectOpcodeCache', $configuration->getOpcodeCache()); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::getOrm + */ + public function testGetOrm() + { + $specifications = $this->getSetupedSpecifications(array( + 'prod' => array('orm' => 'ObjectORM') + )); + + $configuration = Configuration::build($specifications, 'prod'); + $this->assertEquals('Orm\\ObjectORM', $configuration->getOrm()); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::getSearchEngine + */ + public function testGetSearchEngine() + { + $specifications = $this->getSetupedSpecifications(array( + 'prod' => array('search-engine' => 'ObjectPhrasea') + )); + + $configuration = Configuration::build($specifications, 'prod'); + $this->assertEquals('SearchEngine\\ObjectPhrasea', $configuration->getSearchEngine()); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::getBorder + */ + public function testGetBorder() + { + $specifications = $this->getSetupedSpecifications(array( + 'prod' => array('border-manager' => 'ObjectBorder') + )); + + $configuration = Configuration::build($specifications, 'prod'); + $this->assertEquals('Border\\ObjectBorder', $configuration->getBorder()); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::getTaskManager + */ + public function testGetTaskManager() + { + $specifications = $this->getSetupedSpecifications(array( + 'prod' => array('task-manager' => 'ObjectTask') + )); + + $configuration = Configuration::build($specifications, 'prod'); + $this->assertEquals('TaskManager\\ObjectTask', $configuration->getTaskManager()); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::getService + * @dataProvider provideServices + */ + public function testGetService($services, $name, $expected) + { + $specifications = $this->getSetupedSpecifications(array( + 'prod' => array('task-manager' => 'ObjectTask') + )); + + $specifications->expects($this->once()) + ->method('getServices') + ->will($this->returnValue($services)); + + $configuration = Configuration::build($specifications, 'prod'); + $service = $configuration->getService($name); + + $this->assertInstanceOf('Symfony\Component\DependencyInjection\ParameterBag\ParameterBag', $service); + $this->assertEquals($expected, $service->all()); + } + + /** + * @covers Alchemy\Phrasea\Core\Configuration::getService + * @dataProvider provideFailingServiceData + */ + public function testGetServiceFail($services, $name) + { + $specifications = $this->getSetupedSpecifications(array( + 'prod' => array('task-manager' => 'ObjectTask') + )); + + $specifications->expects($this->once()) + ->method('getServices') + ->will($this->returnValue($services)); + + $configuration = Configuration::build($specifications, 'prod'); + + try { + $configuration->getService($name); + $this->fail('Should have raised an exception'); + } catch (InvalidArgumentException $e) { + + } + } + + public function provideServices() + { + $services = array( + 'servicetld' => array( + 'sub' => array('data'), + 'anothersub' => array('datalevel1' => array( + 'datalevel2' => array('lowleveldata') + )), + ), + 'anothertop' => array('pif' => 'paf') + ); + + return array( + array($services, 'servicetld\\sub', array('data')), + array($services, 'servicetld\\anothersub\\datalevel1', array('datalevel2' => array('lowleveldata'))), + array($services, 'anothertop', array('pif' => 'paf')), + ); + } + + public function provideFailingServiceData() + { + $services = array( + 'servicetld' => array( + 'sub' => array('data'), + 'anothersub' => array('datalevel1' => array( + 'datalevel2' => array('lowleveldata') + )), + ), + 'anothertop' => array('pif' => 'paf') + ); + + return array( + array($services, 'servicetld\\sub\\data'), + array($services, 'servicetld\\data'), + array($services, 'servicetld\\anothersub\\datalevel2'), + array($services, 'anotherothertop'), + ); + } + + private function getNotSetupedSpecifications() + { + $specifications = $this->getMock('Alchemy\Phrasea\Core\Configuration\SpecificationInterface'); + + $specifications->expects($this->any()) + ->method('isSetup') + ->will($this->returnValue(false)); + + return $specifications; + } + + private function getSetupedSpecifications($configuration = array()) + { + $specifications = $this->getMock('Alchemy\Phrasea\Core\Configuration\SpecificationInterface'); + + $specifications->expects($this->any()) + ->method('isSetup') + ->will($this->returnValue(true)); + + if ($configuration) { + $specifications->expects($this->any()) + ->method('getConfigurations') + ->will($this->returnValue($configuration)); + } + + return $specifications; + } +} diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/BorderManagerServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/BorderManagerServiceProviderTest.php index 834bc878a8..59cfeda5f9 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/BorderManagerServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/BorderManagerServiceProviderTest.php @@ -10,6 +10,11 @@ class BorderManagerServiceProvidertest extends \PhraseanetPHPUnitAbstract { self::$DI['app']->register(new BorderManagerServiceProvider()); - $this->assertInstanceof('Alchemy\\Phrasea\\Border\\Manager', self::$DI['app']['border-manager']); + $borderManager1 = self::$DI['app']['border-manager']; + $borderManager2 = self::$DI['app']['border-manager']; + + $this->assertInstanceof('Alchemy\\Phrasea\\Border\\Manager', $borderManager1); + + $this->assertEquals($borderManager1, $borderManager2); } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/FTPServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/FTPServiceProviderTest.php new file mode 100644 index 0000000000..5fdd0ae582 --- /dev/null +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/FTPServiceProviderTest.php @@ -0,0 +1,20 @@ +register(new FtpServiceProvider()); + + $ftpclient1 = self::$DI['app']['phraseanet.ftp.client']; + $ftpclient2 = self::$DI['app']['phraseanet.ftp.client']; + $this->assertInstanceof('ftpclient', $ftpclient1); + $this->assertInstanceof('ftpclient', $ftpclient2); + + $this->assertNotEquals($ftpclient1, $ftpclient2); + } +} diff --git a/tests/Alchemy/Tests/Phrasea/SearchEngine/ConfigurationPanelAbstractTest.php b/tests/Alchemy/Tests/Phrasea/SearchEngine/ConfigurationPanelAbstractTest.php index d295bf321d..177441b732 100644 --- a/tests/Alchemy/Tests/Phrasea/SearchEngine/ConfigurationPanelAbstractTest.php +++ b/tests/Alchemy/Tests/Phrasea/SearchEngine/ConfigurationPanelAbstractTest.php @@ -26,6 +26,8 @@ abstract class ConfigurationPanelAbstractTest extends \PhraseanetPHPUnitAuthenti $config = $this->getPanel()->getConfiguration(); $this->assertEquals($data, $config['test']); + unset($config['test']); + $this->getPanel()->saveConfiguration($config); } public function testGetAvailableDateFields() From 9614ff6a11623cc7d52a7511aa965bd24126c633 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Thu, 24 Jan 2013 10:03:14 +0100 Subject: [PATCH 2/7] Add more tests on core provider --- .../BorderManagerServiceProviderTest.php | 20 +++++++--------- .../Provider/BrowserServiceProviderTest.php | 15 ++++++------ .../Provider/CacheServiceProviderTest.php | 19 +++++++-------- .../ConfigurationServiceProviderTest.php | 15 ++++++------ ...ConfigurationTesterServiceProviderTest.php | 15 ++++++------ .../Core/Provider/FTPServiceProviderTest.php | 7 +----- .../Provider/GeonamesServiceProviderTest.php | 15 ++++++------ .../Core/Provider/ORMServiceProviderTest.php | 15 ++++++------ .../SearchEngineServiceProviderTest.php | 18 +++++++-------- .../Core/Provider/ServiceProviderTestCase.php | 23 +++++++++++++++++++ .../TaskManagerServiceProviderTest.php | 18 +++++++-------- .../Provider/UnicodeServiceProviderTest.php | 18 +++++++-------- 12 files changed, 106 insertions(+), 92 deletions(-) create mode 100644 tests/Alchemy/Tests/Phrasea/Core/Provider/ServiceProviderTestCase.php diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/BorderManagerServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/BorderManagerServiceProviderTest.php index 59cfeda5f9..b12e06e370 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/BorderManagerServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/BorderManagerServiceProviderTest.php @@ -2,19 +2,15 @@ namespace Alchemy\Tests\Phrasea\Core\Provider; -use Alchemy\Phrasea\Core\Provider\BorderManagerServiceProvider; - -class BorderManagerServiceProvidertest extends \PhraseanetPHPUnitAbstract +/** + * @covers Alchemy\Phrasea\Core\Provider\BorderManagerServiceProvider + */ +class BorderManagerServiceProvidertest extends ServiceProviderTestCase { - public function testGetInstantiate() + public function provideServiceDescription() { - self::$DI['app']->register(new BorderManagerServiceProvider()); - - $borderManager1 = self::$DI['app']['border-manager']; - $borderManager2 = self::$DI['app']['border-manager']; - - $this->assertInstanceof('Alchemy\\Phrasea\\Border\\Manager', $borderManager1); - - $this->assertEquals($borderManager1, $borderManager2); + return array( + array('Alchemy\Phrasea\Core\Provider\BorderManagerServiceProvider', 'border-manager', 'Alchemy\\Phrasea\\Border\\Manager'), + ); } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/BrowserServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/BrowserServiceProviderTest.php index 46c71cb2cc..9636d5f32e 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/BrowserServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/BrowserServiceProviderTest.php @@ -2,14 +2,15 @@ namespace Alchemy\Tests\Phrasea\Core\Provider; -use Alchemy\Phrasea\Core\Provider\BrowserServiceProvider; - -class BrowserServiceProvidertest extends \PhraseanetPHPUnitAbstract +/** + * @covers Alchemy\Phrasea\Core\Provider\BrowserServiceProvider + */ +class BrowserServiceProvidertest extends ServiceProviderTestCase { - public function testGetInstantiate() + public function provideServiceDescription() { - self::$DI['app']->register(new BrowserServiceProvider()); - - $this->assertInstanceof('Browser', self::$DI['app']['browser']); + return array( + array('Alchemy\Phrasea\Core\Provider\BrowserServiceProvider', 'browser', 'Browser'), + ); } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/CacheServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/CacheServiceProviderTest.php index b385560550..ecc2799ca4 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/CacheServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/CacheServiceProviderTest.php @@ -2,16 +2,17 @@ namespace Alchemy\Tests\Phrasea\Core\Provider; -use Alchemy\Phrasea\Core\Provider\CacheServiceProvider; - -class CacheServiceProvidertest extends \PhraseanetPHPUnitAbstract +/** + * @covers Alchemy\Phrasea\Core\Provider\CacheServiceProvider + */ +class CacheServiceProvidertest extends ServiceProviderTestCase { - public function testGetInstantiate() + public function provideServiceDescription() { - self::$DI['app']->register(new CacheServiceProvider()); - - $this->assertInstanceof('Doctrine\\Common\\Cache\\Cache', self::$DI['app']['cache']); - $this->assertInstanceof('Doctrine\\Common\\Cache\\Cache', self::$DI['app']['opcode-cache']); - $this->assertInstanceof('Alchemy\\Phrasea\\Cache\\Manager', self::$DI['app']['phraseanet.cache-service']); + return array( + array('Alchemy\Phrasea\Core\Provider\CacheServiceProvider', 'cache', 'Doctrine\\Common\\Cache\\Cache'), + array('Alchemy\Phrasea\Core\Provider\CacheServiceProvider', 'opcode-cache', 'Doctrine\\Common\\Cache\\Cache'), + array('Alchemy\Phrasea\Core\Provider\CacheServiceProvider', 'phraseanet.cache-service', 'Alchemy\\Phrasea\\Cache\\Manager'), + ); } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/ConfigurationServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/ConfigurationServiceProviderTest.php index 9bf71f5399..8d7bbfb39a 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/ConfigurationServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/ConfigurationServiceProviderTest.php @@ -2,14 +2,15 @@ namespace Alchemy\Tests\Phrasea\Core\Provider; -use Alchemy\Phrasea\Core\Provider\ConfigurationServiceProvider; - -class ConfigurationServiceProvidertest extends \PhraseanetPHPUnitAbstract +/** + * @covers Alchemy\Phrasea\Core\Provider\ConfigurationServiceProvider + */ +class ConfigurationServiceProvidertest extends ServiceProviderTestCase { - public function testGetInstantiate() + public function provideServiceDescription() { - self::$DI['app']->register(new ConfigurationServiceProvider()); - - $this->assertInstanceof('Alchemy\\Phrasea\\Core\\Configuration', self::$DI['app']['phraseanet.configuration']); + return array( + array('Alchemy\Phrasea\Core\Provider\ConfigurationServiceProvider', 'phraseanet.configuration', 'Alchemy\\Phrasea\\Core\\Configuration'), + ); } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/ConfigurationTesterServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/ConfigurationTesterServiceProviderTest.php index 9788175802..7fce108fe4 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/ConfigurationTesterServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/ConfigurationTesterServiceProviderTest.php @@ -2,14 +2,15 @@ namespace Alchemy\Tests\Phrasea\Core\Provider; -use Alchemy\Phrasea\Core\Provider\ConfigurationTesterServiceProvider; - -class ConfigurationTesterServiceProvidertest extends \PhraseanetPHPUnitAbstract +/** + * @covers Alchemy\Phrasea\Core\Provider\ConfigurationTesterServiceProvider + */ +class ConfigurationTesterServiceProvidertest extends ServiceProviderTestCase { - public function testGetInstantiate() + public function provideServiceDescription() { - self::$DI['app']->register(new ConfigurationTesterServiceProvider()); - - $this->assertInstanceof('Alchemy\\Phrasea\\Setup\\ConfigurationTester', self::$DI['app']['phraseanet.configuration-tester']); + return array( + array('Alchemy\Phrasea\Core\Provider\ConfigurationTesterServiceProvider', 'phraseanet.configuration-tester', 'Alchemy\\Phrasea\\Setup\\ConfigurationTester'), + ); } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/FTPServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/FTPServiceProviderTest.php index 5fdd0ae582..58c8d70669 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/FTPServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/FTPServiceProviderTest.php @@ -10,11 +10,6 @@ class FTPServiceProvidertest extends \PhraseanetPHPUnitAbstract { self::$DI['app']->register(new FtpServiceProvider()); - $ftpclient1 = self::$DI['app']['phraseanet.ftp.client']; - $ftpclient2 = self::$DI['app']['phraseanet.ftp.client']; - $this->assertInstanceof('ftpclient', $ftpclient1); - $this->assertInstanceof('ftpclient', $ftpclient2); - - $this->assertNotEquals($ftpclient1, $ftpclient2); + $this->assertInstanceOf('Closure', self::$DI['app']['phraseanet.ftp.client']); } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/GeonamesServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/GeonamesServiceProviderTest.php index 25fad8bf8a..f8fd54de62 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/GeonamesServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/GeonamesServiceProviderTest.php @@ -2,14 +2,15 @@ namespace Alchemy\Tests\Phrasea\Core\Provider; -use Alchemy\Phrasea\Core\Provider\GeonamesServiceProvider; - -class GeonamesServiceProvidertest extends \PhraseanetPHPUnitAbstract +/** + * @covers Alchemy\Phrasea\Core\Provider\GeonamesServiceProvider + */ +class GeonamesServiceProvidertest extends ServiceProviderTestCase { - public function testGetInstantiate() + public function provideServiceDescription() { - self::$DI['app']->register(new GeonamesServiceProvider()); - - $this->assertInstanceof('geonames', self::$DI['app']['geonames']); + return array( + array('Alchemy\Phrasea\Core\Provider\GeonamesServiceProvider', 'geonames', 'geonames'), + ); } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/ORMServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/ORMServiceProviderTest.php index fc72b1b560..091c349390 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/ORMServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/ORMServiceProviderTest.php @@ -2,14 +2,15 @@ namespace Alchemy\Tests\Phrasea\Core\Provider; -use Alchemy\Phrasea\Core\Provider\ORMServiceProvider; - -class ORMServiceProvidertest extends \PhraseanetPHPUnitAbstract +/** + * @covers Alchemy\Phrasea\Core\Provider\ORMServiceProvider + */ +class ORMServiceProvidertest extends ServiceProviderTestCase { - public function testGetInstantiate() + public function provideServiceDescription() { - self::$DI['app']->register(new ORMServiceProvider()); - - $this->assertInstanceof('Doctrine\\ORM\\EntityManager', self::$DI['app']['EM']); + return array( + array('Alchemy\Phrasea\Core\Provider\ORMServiceProvider', 'EM', 'Doctrine\\ORM\\EntityManager'), + ); } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/SearchEngineServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/SearchEngineServiceProviderTest.php index b3a573a229..78932d60e7 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/SearchEngineServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/SearchEngineServiceProviderTest.php @@ -2,17 +2,15 @@ namespace Alchemy\Tests\Phrasea\Core\Provider; -use Alchemy\Phrasea\Core\Provider\SearchEngineServiceProvider; - -class SearchEngineServiceProvidertest extends \PhraseanetPHPUnitAbstract +/** + * @covers Alchemy\Phrasea\Core\Provider\SearchEngineServiceProvider + */ +class SearchEngineServiceProvidertest extends ServiceProviderTestCase { - /** - * @covers Alchemy\Phrasea\Core\Provider\SearchEngineServiceProvider - */ - public function testGetInstantiate() + public function provideServiceDescription() { - self::$DI['app']->register(new SearchEngineServiceProvider()); - - $this->assertInstanceof('Alchemy\Phrasea\SearchEngine\SearchEngineInterface', self::$DI['app']['phraseanet.SE']); + return array( + array('Alchemy\Phrasea\Core\Provider\SearchEngineServiceProvider', 'phraseanet.SE', 'Alchemy\Phrasea\SearchEngine\SearchEngineInterface'), + ); } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/ServiceProviderTestCase.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/ServiceProviderTestCase.php new file mode 100644 index 0000000000..d3c080e32e --- /dev/null +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/ServiceProviderTestCase.php @@ -0,0 +1,23 @@ +register(new $service()); + + $instance1 = self::$DI['app'][$key]; + $instance2 = self::$DI['app'][$key]; + + $this->assertInstanceof($classname, $instance1); + $this->assertEquals($instance1, $instance2); + } + + abstract public function provideServiceDescription(); +} diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/TaskManagerServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/TaskManagerServiceProviderTest.php index e2208c53dd..203874a88d 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/TaskManagerServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/TaskManagerServiceProviderTest.php @@ -2,17 +2,15 @@ namespace Alchemy\Tests\Phrasea\Core\Provider; -use Alchemy\Phrasea\Core\Provider\TaskManagerServiceProvider; - -class TaskManagerServiceProvidertest extends \PhraseanetPHPUnitAbstract +/** + * @covers Alchemy\Phrasea\Core\Provider\TaskManagerServiceProvider + */ +class TaskManagerServiceProvidertest extends ServiceProviderTestCase { - /** - * @covers Alchemy\Phrasea\Core\Provider\TaskManagerServiceProvider - */ - public function testGetInstantiate() + public function provideServiceDescription() { - self::$DI['app']->register(new TaskManagerServiceProvider()); - - $this->assertInstanceof('task_manager', self::$DI['app']['task-manager']); + return array( + array('Alchemy\Phrasea\Core\Provider\TaskManagerServiceProvider', 'task-manager', '\task_manager'), + ); } } diff --git a/tests/Alchemy/Tests/Phrasea/Core/Provider/UnicodeServiceProviderTest.php b/tests/Alchemy/Tests/Phrasea/Core/Provider/UnicodeServiceProviderTest.php index 7162c60ed4..dff848d312 100644 --- a/tests/Alchemy/Tests/Phrasea/Core/Provider/UnicodeServiceProviderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Core/Provider/UnicodeServiceProviderTest.php @@ -2,17 +2,15 @@ namespace Alchemy\Tests\Phrasea\Core\Provider; -use Alchemy\Phrasea\Core\Provider\UnicodeServiceProvider; - -class UnicodeServiceProvidertest extends \PhraseanetPHPUnitAbstract +/** + * @covers Alchemy\Phrasea\Core\Provider\UnicodeServiceProvider + */ +class UnicodeServiceProvidertest extends ServiceProviderTestCase { - /** - * @covers Alchemy\Phrasea\Core\Provider\UnicodeServiceProvider - */ - public function testGetInstantiate() + public function provideServiceDescription() { - self::$DI['app']->register(new UnicodeServiceProvider()); - - $this->assertInstanceof('unicode', self::$DI['app']['unicode']); + return array( + array('Alchemy\Phrasea\Core\Provider\UnicodeServiceProvider', 'unicode', '\unicode'), + ); } } From 869451f228492787c916c8719d42db596b4347a9 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Thu, 24 Jan 2013 10:42:17 +0100 Subject: [PATCH 3/7] Add patch tests --- lib/classes/patch/3803.php | 2 +- tests/classes/patch/3803Test.php | 161 +++++++++++++++++++++++++++++++ tests/classes/patch/3804Test.php | 60 ++++++++++++ 3 files changed, 222 insertions(+), 1 deletion(-) create mode 100644 tests/classes/patch/3803Test.php create mode 100644 tests/classes/patch/3804Test.php diff --git a/lib/classes/patch/3803.php b/lib/classes/patch/3803.php index e345a80ade..5896394c93 100644 --- a/lib/classes/patch/3803.php +++ b/lib/classes/patch/3803.php @@ -107,7 +107,7 @@ class patch_3803 implements patchInterface $app['phraseanet.SE']->getConfigurationPanel()->saveConfiguration($sphinxConfiguration); } - return; + return true; } } diff --git a/tests/classes/patch/3803Test.php b/tests/classes/patch/3803Test.php new file mode 100644 index 0000000000..46ac15fc63 --- /dev/null +++ b/tests/classes/patch/3803Test.php @@ -0,0 +1,161 @@ +getMockBuilder('appbox') + ->disableOriginalConstructor() + ->getMock(); + + $app = self::$DI['app']; + + $app['phraseanet.registry'] = $this->getMock('registryInterface'); + $app['phraseanet.registry']->expects($this->any()) + ->method('get') + ->will($this->returnCallback(function ($parameter) { + switch ($parameter) { + case 'GV_sphinx': + return true; + case 'GV_sphinx_rt_port': + return 5678; + case 'GV_sphinx_rt_host': + return 'sphinx.rt_host'; + case 'GV_sphinx_host': + return 'sphinx.host'; + case 'GV_sphinx_port': + return 1234; + default: + throw new \InvalidArgumentException(sprintf('%s is missing, test case not ready', $parameter)); + } + })); + + $catchConfiguration = $catchSEConf = null; + + $app['phraseanet.configuration'] = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration') + ->disableOriginalConstructor() + ->getMock(); + $app['phraseanet.configuration']->expects($this->once()) + ->method('getConfigurations') + ->will($this->returnValue(array('environment' => 'prod', 'prod' => array(), 'dev' => array()))); + $app['phraseanet.configuration']->expects($this->once()) + ->method('setConfigurations') + ->will($this->returnCallback(function($configuration) use (&$catchConfiguration) { + $catchConfiguration = $configuration; + })); + + $panel = $this->getMock('Alchemy\Phrasea\SearchEngine\ConfigurationPanelInterface'); + $panel->expects($this->once()) + ->method('saveConfiguration') + ->will($this->returnCallback(function($json) use (&$catchSEConf){ + $catchSEConf = $json; + })); + $panel->expects($this->once()) + ->method('getConfiguration') + ->will($this->returnValue(array())); + + $app['phraseanet.SE'] = $this->getMock('Alchemy\Phrasea\SearchEngine\SearchEngineInterface'); + $app['phraseanet.SE']->expects($this->any()) + ->method('getConfigurationPanel') + ->will($this->returnValue($panel)); + + $this->assertTrue($patch->apply($appbox, $app)); + + $upgrade = 0; + foreach ($catchConfiguration as $env => $conf) { + if (in_array($env, array('environment', 'key'))) { + continue; + } + $this->assertArrayHasKey('search-engine', $conf); + $upgrade++; + } + + $this->assertEquals(2, $upgrade); + $this->assertArrayHasKey('port', $catchSEConf); + $this->assertArrayHasKey('host', $catchSEConf); + $this->assertArrayHasKey('rt_port', $catchSEConf); + $this->assertArrayHasKey('rt_host', $catchSEConf); + $this->assertEquals(5678, $catchSEConf['rt_port']); + $this->assertEquals('sphinx.rt_host', $catchSEConf['rt_host']); + $this->assertEquals(1234, $catchSEConf['port']); + $this->assertEquals('sphinx.host', $catchSEConf['host']); + } + + /** + * @covers patch_3803::apply + */ + public function testApplyInPhraseaEnvironment() + { + $patch = new patch_3803(); + + $appbox = $this->getMockBuilder('appbox') + ->disableOriginalConstructor() + ->getMock(); + + $app = self::$DI['app']; + + $app['phraseanet.registry'] = $this->getMock('registryInterface'); + $app['phraseanet.registry']->expects($this->any()) + ->method('get') + ->will($this->returnCallback(function ($parameter) { + switch ($parameter) { + case 'GV_sphinx': + return false; + case 'GV_phrasea_sort': + return 'custom-sort'; + default: + throw new \InvalidArgumentException(sprintf('%s is missing, test case not ready', $parameter)); + } + })); + + $catchConfiguration = $catchPhraseaConf = null; + + $app['phraseanet.configuration'] = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration') + ->disableOriginalConstructor() + ->getMock(); + $app['phraseanet.configuration']->expects($this->once()) + ->method('getConfigurations') + ->will($this->returnValue(array('environment' => 'prod', 'prod' => array(), 'dev' => array()))); + $app['phraseanet.configuration']->expects($this->once()) + ->method('setConfigurations') + ->will($this->returnCallback(function($configuration) use (&$catchConfiguration) { + $catchConfiguration = $configuration; + })); + + $panel = $this->getMock('Alchemy\Phrasea\SearchEngine\ConfigurationPanelInterface'); + $panel->expects($this->once()) + ->method('saveConfiguration') + ->will($this->returnCallback(function($json) use (&$catchSEConf){ + $catchSEConf = $json; + })); + $panel->expects($this->once()) + ->method('getConfiguration') + ->will($this->returnValue(array())); + + $app['phraseanet.SE'] = $this->getMock('Alchemy\Phrasea\SearchEngine\SearchEngineInterface'); + $app['phraseanet.SE']->expects($this->any()) + ->method('getConfigurationPanel') + ->will($this->returnValue($panel)); + + $this->assertTrue($patch->apply($appbox, $app)); + + $upgrade = 0; + foreach ($catchConfiguration as $env => $conf) { + if (in_array($env, array('environment', 'key'))) { + continue; + } + $this->assertArrayHasKey('search-engine', $conf); + $upgrade++; + } + + $this->assertEquals(2, $upgrade); + + $this->assertArrayHasKey('default_sort', $catchSEConf); + $this->assertEquals('custom-sort', $catchSEConf['default_sort']); + } +} diff --git a/tests/classes/patch/3804Test.php b/tests/classes/patch/3804Test.php new file mode 100644 index 0000000000..ca1b9fa891 --- /dev/null +++ b/tests/classes/patch/3804Test.php @@ -0,0 +1,60 @@ +getMockBuilder('appbox') + ->disableOriginalConstructor() + ->getMock(); + + $catchConfiguration = null; + + $app['phraseanet.configuration'] = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration') + ->disableOriginalConstructor() + ->getMock(); + + $app['phraseanet.configuration']->expects($this->once()) + ->method('getConfigurations') + ->will($this->returnValue(array( + 'environment' => 'prod', + 'prod' => array(), + 'dev' => array() + ))); + $app['phraseanet.configuration']->expects($this->once()) + ->method('setConfigurations') + ->will($this->returnCallback(function($configuration) use (&$catchConfiguration) { + $catchConfiguration = $configuration; + })); + + $app['phraseanet.configuration']->expects($this->once()) + ->method('getServices') + ->will($this->returnValue(array( + 'SearchEngine' => array(), + ))); + + $app['phraseanet.configuration']->expects($this->once()) + ->method('resetServices') + ->with($this->equalTo('TaskManager')); + + $this->assertTrue($patch->apply($appbox, $app)); + + $upgrade = 0; + foreach ($catchConfiguration as $env => $conf) { + if (in_array($env, array('environment', 'key'))) { + continue; + } + $this->assertArrayHasKey('task-manager', $conf); + $upgrade++; + } + + $this->assertEquals(2, $upgrade); + } +} From b4e498cc16a9b0744384b62f55026f82cddb21c8 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Thu, 24 Jan 2013 17:04:13 +0100 Subject: [PATCH 4/7] Disabling default syslog and maillog --- config/services.sample.yml | 4 ++-- lib/conf.d/services.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/services.sample.yml b/config/services.sample.yml index 21fa8680bd..7460cb6e95 100644 --- a/config/services.sample.yml +++ b/config/services.sample.yml @@ -211,5 +211,5 @@ TaskManager: options: # set the threshold for sending task logs to syslog or by mail # values : task_abstract::[LOG_DEBUG | LOG_INFO | LOG_WARNING | LOG_ERROR | LOG_CRITICAL | LOG_ALERT] - syslog_level: task_abstract::LOG_ERROR - maillog_level: task_abstract::LOG_ERROR + #syslog_level: task_abstract::LOG_ERROR + #maillog_level: task_abstract::LOG_ERROR diff --git a/lib/conf.d/services.yml b/lib/conf.d/services.yml index ebb7b27eb5..f5076a8234 100644 --- a/lib/conf.d/services.yml +++ b/lib/conf.d/services.yml @@ -211,5 +211,5 @@ TaskManager: options: # set the threshold for sending task logs to syslog or by mail # values : task_abstract::[LOG_DEBUG | LOG_INFO | LOG_WARNING | LOG_ERROR | LOG_CRITICAL | LOG_ALERT] - syslog_level: task_abstract::LOG_ERROR - maillog_level: task_abstract::LOG_ERROR + #syslog_level: task_abstract::LOG_ERROR + #maillog_level: task_abstract::LOG_ERROR From 6dcdd4e89298b8044be517bd7ad4dbc231f793ed Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Thu, 24 Jan 2013 17:04:41 +0100 Subject: [PATCH 5/7] Update dependencies --- composer.lock | 391 +++++++++++++++++++++++++++----------------------- 1 file changed, 215 insertions(+), 176 deletions(-) diff --git a/composer.lock b/composer.lock index 4bbef73d60..bd92d144f5 100644 --- a/composer.lock +++ b/composer.lock @@ -1,5 +1,5 @@ { - "hash": "a1c888150997e9946a0a84fe7117ff14", + "hash": "180359cee46a1e23cee4943b7feb6d31", "packages": [ { "name": "BadFaith/BadFaith", @@ -14,7 +14,6 @@ }, "time": "2012-07-27 20:10:01", "type": "library", - "installation-source": "source", "autoload": { "psr-0": { "BadFaith": "lib/" @@ -39,14 +38,13 @@ "reference": "89993abd6a02b42e0b765114c34c26c4056762fa", "shasum": "" }, + "time": "2012-04-13 17:43:31", "type": "library", - "installation-source": "source", "autoload": { "psr-0": { "Phlickr_": "./" } - }, - "time": "1334339011" + } }, { "name": "alchemy/ghostscript", @@ -79,7 +77,6 @@ "dev-master": "0.2.x-dev" } }, - "installation-source": "source", "autoload": { "psr-0": { "Ghostscript": "src" @@ -120,14 +117,13 @@ "reference": "5f949209461e8f4c31e8476155188923aafa2ae5", "shasum": "" }, + "time": "2012-03-30 15:47:07", "type": "library", - "installation-source": "source", "autoload": { "classmap": [ "lib/" ] - }, - "time": "1333122427" + } }, { "name": "alchemy/phpmailer", @@ -144,13 +140,12 @@ "shasum": "" }, "type": "library", - "installation-source": "source", "autoload": { "classmap": [ "./" ] }, - "time": "1333125389" + "time": "2012-11-09 10:51:15" }, { "name": "dailymotion/sdk", @@ -168,21 +163,18 @@ }, "time": "2012-10-25 10:52:56", "type": "library", - "installation-source": "source", "autoload": { "classmap": [ "Dailymotion.php" ] }, - "notification-url": "https://packagist.org/downloads/", "description": "Dailymotion PHP SDK", "homepage": "http://dailymotion.com", "keywords": [ "api", "sdk", "dailymotion" - ], - "time": "1350827116" + ] }, { "name": "data-uri/data-uri", @@ -208,7 +200,6 @@ }, "time": "2012-06-01 00:09:00", "type": "library", - "installation-source": "source", "autoload": { "psr-0": { "DataURI": "src" @@ -225,6 +216,68 @@ ], "description": "PHP DataURI component" }, + { + "name": "doctrine/collections", + "version": "v1.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/collections.git", + "reference": "v1.0" + }, + "dist": { + "type": "zip", + "url": "https://github.com/doctrine/collections/archive/v1.0.zip", + "reference": "v1.0", + "shasum": "" + }, + "require": { + "php": ">=5.3.2" + }, + "time": "2013-01-12 16:36:50", + "type": "library", + "autoload": { + "psr-0": { + "Doctrine\\Common\\Collections\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com", + "homepage": "http://www.jwage.com/" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com", + "homepage": "http://www.instaclick.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com", + "homepage": "https://github.com/schmittjoh", + "role": "Developer of wrapped JMSSerializerBundle" + } + ], + "description": "Collections Abstraction library", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "collections", + "iterator", + "array" + ] + }, { "name": "doctrine/common", "version": "2.2.3", @@ -244,7 +297,6 @@ }, "time": "2012-08-29 01:04:14", "type": "library", - "installation-source": "dist", "autoload": { "psr-0": { "Doctrine\\Common": "lib/" @@ -307,9 +359,8 @@ "php": ">=5.3.2", "doctrine/common": ">=2.2.0,<=2.2.99" }, - "time": "2012-04-13 07:56:12", + "time": "2012-04-13 00:56:12", "type": "library", - "installation-source": "dist", "autoload": { "psr-0": { "Doctrine\\DBAL": "lib/" @@ -326,7 +377,8 @@ }, { "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" + "email": "guilhermeblanco@gmail.com", + "homepage": "http://www.instaclick.com" }, { "name": "Roman Borschel", @@ -366,9 +418,8 @@ "doctrine/common": ">=2.2.0,<2.2.99", "doctrine/dbal": ">=2.2.1,<2.2.99" }, - "time": "2012-04-13 08:02:34", + "time": "2012-04-13 01:02:34", "type": "library", - "installation-source": "dist", "autoload": { "psr-0": { "Doctrine\\ORM": "lib/" @@ -385,7 +436,8 @@ }, { "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" + "email": "guilhermeblanco@gmail.com", + "homepage": "http://www.instaclick.com" }, { "name": "Roman Borschel", @@ -425,14 +477,13 @@ "doctrine/orm": ">=2.1", "doctrine/mongodb-odm": "*" }, + "time": "2012-11-15 16:25:16", "type": "library", - "installation-source": "source", "autoload": { "psr-0": { "Gedmo": "lib/" } }, - "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -456,8 +507,7 @@ "nestedset", "sortable", "timestampable" - ], - "time": "1339767845" + ] }, { "name": "grom/silex-service-provider", @@ -480,13 +530,11 @@ }, "time": "2012-06-03 01:27:23", "type": "library", - "installation-source": "source", "autoload": { "psr-0": { "Grom\\Silex": "src" } }, - "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -526,14 +574,13 @@ "require-dev": { "sami/sami": "dev-master" }, + "time": "2012-12-13 18:31:18", "type": "library", - "installation-source": "source", "autoload": { "psr-0": { "Imagine": "lib/" } }, - "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -551,8 +598,7 @@ "image processing", "drawing", "graphics" - ], - "time": "1350920158" + ] }, { "name": "knplabs/knp-snappy", @@ -576,13 +622,11 @@ }, "time": "2012-11-07 09:48:01", "type": "library", - "installation-source": "source", "autoload": { "psr-0": { "Knp\\Snappy": "src/" } }, - "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -612,12 +656,12 @@ "source": { "type": "git", "url": "https://github.com/alchemy-fr/Media-Alchemyst", - "reference": "7e38949ab34f9670c3e6406ed865ccc18b34c362" + "reference": "44c4dd6dcb0fa9145677ccaa41f4d8bf4aa20692" }, "dist": { "type": "zip", - "url": "https://github.com/alchemy-fr/Media-Alchemyst/archive/7e38949ab34f9670c3e6406ed865ccc18b34c362.zip", - "reference": "7e38949ab34f9670c3e6406ed865ccc18b34c362", + "url": "https://github.com/alchemy-fr/Media-Alchemyst/archive/44c4dd6dcb0fa9145677ccaa41f4d8bf4aa20692.zip", + "reference": "44c4dd6dcb0fa9145677ccaa41f4d8bf4aa20692", "shasum": "" }, "require": { @@ -625,26 +669,25 @@ "php-unoconv/php-unoconv": "dev-master", "php-mp4box/php-mp4box": "dev-master", "php": ">=5.3.3", - "symfony/console": ">=2.0,<=2.2", "pimple/pimple": "1.*", - "mediavorus/mediavorus": "0.2.*", "monolog/monolog": "1.*", "alchemy/ghostscript": "0.2.*", "imagine/imagine": ">=0.4", - "php-ffmpeg/php-ffmpeg": "0.2.*" + "php-ffmpeg/php-ffmpeg": "0.2.*", + "mediavorus/mediavorus": ">=0.2, <=0.3", + "symfony/console": ">=2.0,<=2.2.x-dev" }, "require-dev": { "grom/silex-service-provider": "dev-master", "phpexiftool/phpexiftool": "dev-master" }, - "time": "2012-12-17 12:10:42", + "time": "2013-01-14 12:54:21", "type": "library", "extra": { "branch-alias": { "dev-master": "0.2.x-dev" } }, - "installation-source": "source", "autoload": { "psr-0": { "MediaAlchemyst": "src" @@ -674,8 +717,7 @@ "video processing", "video", "audio processing" - ], - "time": "1350650300" + ] }, { "name": "mediavorus/mediavorus", @@ -683,34 +725,40 @@ "source": { "type": "git", "url": "https://github.com/romainneutron/MediaVorus", - "reference": "000bb25ab0c33080c08190910618714e28aa4c84" + "reference": "7d59243fe92d9cd6be744908019128e7fd9ae046" }, "dist": { "type": "zip", - "url": "https://github.com/romainneutron/MediaVorus/archive/000bb25ab0c33080c08190910618714e28aa4c84.zip", - "reference": "000bb25ab0c33080c08190910618714e28aa4c84", + "url": "https://github.com/romainneutron/MediaVorus/archive/7d59243fe92d9cd6be744908019128e7fd9ae046.zip", + "reference": "7d59243fe92d9cd6be744908019128e7fd9ae046", "shasum": "" }, "require": { "phpexiftool/phpexiftool": "dev-master", "php-ffmpeg/php-ffmpeg": "dev-master", "php": ">=5.3.0", - "monolog/monolog": "1.0.*", "symfony/http-foundation": ">2.0,<=2.2", - "symfony/console": ">2.0,<=2.2" + "symfony/console": ">2.0,<=2.2", + "monolog/monolog": "1.*", + "doctrine/collections": ">=1.0,<2.0" }, "require-dev": { "fabpot/php-cs-fixer": "*", - "silex/silex": "1.0.*-dev" + "silex/silex": "1.0.*-dev", + "symfony/yaml": "*", + "jms/serializer": "1.0.x-dev" }, - "time": "2012-12-14 09:20:49", + "suggest": { + "jms/serializer": "To serialize Medias", + "symfony/yaml": "To serialize Medias in Yaml format" + }, + "time": "2013-01-14 13:16:28", "type": "library", "extra": { "branch-alias": { "dev-master": "0.2.x-dev" } }, - "installation-source": "source", "autoload": { "psr-0": { "MediaVorus": "src" @@ -749,9 +797,8 @@ "require": { "php": ">=5.3.0" }, - "time": "2011-10-24 09:39:02", + "time": "2011-10-24 02:39:02", "type": "library", - "installation-source": "dist", "autoload": { "psr-0": { "Monolog": "src/" @@ -781,12 +828,12 @@ "source": { "type": "git", "url": "https://github.com/romainneutron/BadFaith-ServiceProvider", - "reference": "9aaa0819e9596fa295895e5453471032c5d606df" + "reference": "5bc683cea2996fe5fda6f72b1f9c83299a381336" }, "dist": { "type": "zip", - "url": "https://github.com/romainneutron/BadFaith-ServiceProvider/archive/9aaa0819e9596fa295895e5453471032c5d606df.zip", - "reference": "9aaa0819e9596fa295895e5453471032c5d606df", + "url": "https://github.com/romainneutron/BadFaith-ServiceProvider/archive/5bc683cea2996fe5fda6f72b1f9c83299a381336.zip", + "reference": "5bc683cea2996fe5fda6f72b1f9c83299a381336", "shasum": "" }, "require": { @@ -798,9 +845,8 @@ "require-dev": { "fabpot/php-cs-fixer": "master" }, - "time": "2012-11-08 20:54:31", + "time": "2012-12-19 23:40:50", "type": "library", - "installation-source": "source", "autoload": { "psr-0": { "Neutron": "src" @@ -843,13 +889,11 @@ }, "time": "2012-11-08 21:07:08", "type": "library", - "installation-source": "source", "autoload": { "psr-0": { "Neutron": "src" } }, - "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -873,25 +917,25 @@ "source": { "type": "git", "url": "https://github.com/romainneutron/Sphinx-Search-API-PHP-Client", - "reference": "2.0.6" + "reference": "3e30e2ee40f685d4033f52122fb191cf19a4d3fa" }, "dist": { "type": "zip", - "url": "https://github.com/romainneutron/Sphinx-Search-API-PHP-Client/zipball/2.0.6", - "reference": "2.0.6", + "url": "https://github.com/romainneutron/Sphinx-Search-API-PHP-Client/archive/3e30e2ee40f685d4033f52122fb191cf19a4d3fa.zip", + "reference": "3e30e2ee40f685d4033f52122fb191cf19a4d3fa", "shasum": "" }, "require": { "php": ">=4" }, - "time": "1350983112", + "time": "2013-01-23 21:26:40", "type": "library", - "installation-source": "source", "autoload": { "classmap": [ "sphinxapi.php" ] }, + "notification-url": "https://packagist.org/downloads/", "license": [ "GPL" ], @@ -915,12 +959,12 @@ "source": { "type": "git", "url": "https://github.com/alchemy-fr/PHP-FFmpeg", - "reference": "014112a16f31b74e584b1ae7540f4b72960ebd9e" + "reference": "d7bb7bd091c47ae512ab86206607e2febce7ce49" }, "dist": { "type": "zip", - "url": "https://github.com/alchemy-fr/PHP-FFmpeg/archive/014112a16f31b74e584b1ae7540f4b72960ebd9e.zip", - "reference": "014112a16f31b74e584b1ae7540f4b72960ebd9e", + "url": "https://github.com/alchemy-fr/PHP-FFmpeg/archive/d7bb7bd091c47ae512ab86206607e2febce7ce49.zip", + "reference": "d7bb7bd091c47ae512ab86206607e2febce7ce49", "shasum": "" }, "require": { @@ -937,14 +981,13 @@ "suggest": { "php-ffmpeg/extras": "A compilation of common audio & video drivers for PHP-FFMpeg" }, - "time": "2012-12-16 15:58:49", + "time": "2012-12-27 23:01:03", "type": "library", "extra": { "branch-alias": { "dev-master": "0.2.x-dev" } }, - "installation-source": "source", "autoload": { "psr-0": { "FFMpeg": "src" @@ -984,26 +1027,25 @@ "source": { "type": "git", "url": "git://github.com/alchemy-fr/PHP-MP4Box.git", - "reference": "2c272a3f77807771275fb4f2c404071e9c263e19" + "reference": "2e8db20b7ebc53818b3e23c99f4e23c6e2bfc1c4" }, "dist": { "type": "zip", - "url": "https://github.com/alchemy-fr/PHP-MP4Box/archive/2c272a3f77807771275fb4f2c404071e9c263e19.zip", - "reference": "2c272a3f77807771275fb4f2c404071e9c263e19", + "url": "https://github.com/alchemy-fr/PHP-MP4Box/archive/2e8db20b7ebc53818b3e23c99f4e23c6e2bfc1c4.zip", + "reference": "2e8db20b7ebc53818b3e23c99f4e23c6e2bfc1c4", "shasum": "" }, "require": { - "monolog/monolog": "1.0.*", "php": ">=5.3.3", - "symfony/process": ">=2.0,<=2.2" + "symfony/process": ">=2.0,<=2.2", + "monolog/monolog": "1.*" }, "require-dev": { "fabpot/php-cs-fixer": "dev-master", "silex/silex": "dev-master" }, - "time": "2012-10-09 17:40:08", + "time": "2012-12-21 16:56:54", "type": "library", - "installation-source": "source", "autoload": { "psr-0": { "MP4Box": "src" @@ -1033,26 +1075,25 @@ "source": { "type": "git", "url": "https://github.com/alchemy-fr/PHP-Unoconv", - "reference": "dd49df9be9ab649af37674f07393037727077124" + "reference": "0.1.0" }, "dist": { "type": "zip", - "url": "https://github.com/alchemy-fr/PHP-Unoconv/archive/dd49df9be9ab649af37674f07393037727077124.zip", - "reference": "dd49df9be9ab649af37674f07393037727077124", + "url": "https://github.com/alchemy-fr/PHP-Unoconv/archive/0.1.0.zip", + "reference": "0.1.0", "shasum": "" }, "require": { - "monolog/monolog": "1.0.*", "php": ">=5.3.3", - "symfony/process": ">=2.0,<=2.2" + "symfony/process": ">=2.0,<=2.2", + "monolog/monolog": "1.*" }, "require-dev": { "silex/silex": "dev-master", "fabpot/php-cs-fixer": "dev-master" }, - "time": "2012-10-08 16:16:40", + "time": "2012-12-21 16:41:47", "type": "library", - "installation-source": "source", "autoload": { "psr-0": { "Unoconv": "src" @@ -1070,7 +1111,7 @@ }, { "name": "Phraseanet Team", - "email": "info@alchemy.fr", + "email": "support@alchemy.fr", "homepage": "http://www.phraseanet.com/" } ], @@ -1100,15 +1141,13 @@ "sami/sami": "dev-master", "silex/silex": "dev-master" }, - "time": "1349703734", + "time": "2012-10-08 13:42:14", "type": "library", - "installation-source": "source", "autoload": { "psr-0": { "XPDF": "src" } }, - "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -1128,8 +1167,7 @@ "keywords": [ "pdf", "xpdf" - ], - "time": "1349703734" + ] }, { "name": "phpexiftool/exiftool", @@ -1137,20 +1175,19 @@ "source": { "type": "git", "url": "https://github.com/alchemy-fr/exiftool", - "reference": "c68d98b5a00aaf7ae0db7eebddfcde27d948e537" + "reference": "6f833c5fcd94de99a240e9e3f549280051677269" }, "dist": { "type": "zip", - "url": "https://github.com/alchemy-fr/exiftool/archive/c68d98b5a00aaf7ae0db7eebddfcde27d948e537.zip", - "reference": "c68d98b5a00aaf7ae0db7eebddfcde27d948e537", + "url": "https://github.com/alchemy-fr/exiftool/archive/6f833c5fcd94de99a240e9e3f549280051677269.zip", + "reference": "6f833c5fcd94de99a240e9e3f549280051677269", "shasum": "" }, "require": { "phpexiftool/phpexiftool": "*" }, - "time": "2012-08-29 16:01:26", + "time": "2013-01-03 11:16:06", "type": "library", - "installation-source": "source", "notification-url": "https://packagist.org/downloads/", "license": [ "Perl Licensing" @@ -1166,8 +1203,7 @@ "keywords": [ "exiftool", "metadatas" - ], - "time": "1346256086" + ] }, { "name": "phpexiftool/phpexiftool", @@ -1175,32 +1211,32 @@ "source": { "type": "git", "url": "https://github.com/romainneutron/PHPExiftool", - "reference": "c72f9a88a74c1967fb14de62f342048c8311cb9b" + "reference": "a953aa842a555ece591603971751d90fee8620de" }, "dist": { "type": "zip", - "url": "https://github.com/romainneutron/PHPExiftool/archive/c72f9a88a74c1967fb14de62f342048c8311cb9b.zip", - "reference": "c72f9a88a74c1967fb14de62f342048c8311cb9b", + "url": "https://github.com/romainneutron/PHPExiftool/archive/a953aa842a555ece591603971751d90fee8620de.zip", + "reference": "a953aa842a555ece591603971751d90fee8620de", "shasum": "" }, "require": { "php": ">=5.3.3", - "doctrine/common": ">=2.2", - "phpexiftool/exiftool": "dev-master", - "symfony/process": "2.1.*" + "monolog/monolog": "1.*", + "doctrine/common": ">=2.2,<=2.3", + "phpexiftool/exiftool": ">=9.12", + "symfony/process": ">=2.0,<=2.2.x-dev" }, "require-dev": { - "symfony/css-selector": "2.1.*", - "symfony/finder": "2.1.*", - "symfony/console": "2.1.*", - "symfony/dom-crawler": "2.1.*", - "fabpot/php-cs-fixer": "dev-master", - "sami/sami": "dev-master", - "silex/silex": "dev-master" + "fabpot/php-cs-fixer": "*", + "sami/sami": "*", + "silex/silex": "*", + "symfony/css-selector": ">=2.0,<=2.2.x-dev", + "symfony/finder": ">=2.0,<=2.2.x-dev", + "symfony/console": ">=2.0,<=2.2.x-dev", + "symfony/dom-crawler": ">=2.0,<=2.2.x-dev" }, - "time": "2012-09-03 14:06:48", + "time": "2013-01-03 11:53:47", "type": "library", - "installation-source": "source", "autoload": { "psr-0": { "PHPExiftool": "lib" @@ -1221,8 +1257,7 @@ "keywords": [ "metadata", "exiftool" - ], - "time": "1346681208" + ] }, { "name": "pimple/pimple", @@ -1230,24 +1265,24 @@ "source": { "type": "git", "url": "git://github.com/fabpot/Pimple.git", - "reference": "v1.0.1" + "reference": "d58cec632dfdd3305d6b4f2563a5cf2a75b4d978" }, "dist": { "type": "zip", - "url": "https://github.com/fabpot/Pimple/archive/v1.0.1.zip", - "reference": "v1.0.1", + "url": "https://github.com/fabpot/Pimple/archive/d58cec632dfdd3305d6b4f2563a5cf2a75b4d978.zip", + "reference": "d58cec632dfdd3305d6b4f2563a5cf2a75b4d978", "shasum": "" }, "require": { "php": ">=5.3.0" }, + "time": "2013-01-07 10:39:26", "type": "library", "extra": { "branch-alias": { "dev-master": "1.0.x-dev" } }, - "installation-source": "source", "autoload": { "psr-0": { "Pimple": "lib/" @@ -1268,8 +1303,7 @@ "keywords": [ "dependency injection", "container" - ], - "time": "1347278988" + ] }, { "name": "silex/silex", @@ -1277,12 +1311,12 @@ "source": { "type": "git", "url": "git://github.com/fabpot/Silex.git", - "reference": "c2dff3ca9e8ee4e5c9652a366c39eb3b3c91ca53" + "reference": "c1bf812c4a5c335f0d8489ae4ca9e5f42a7d7a24" }, "dist": { "type": "zip", - "url": "https://github.com/fabpot/Silex/archive/c2dff3ca9e8ee4e5c9652a366c39eb3b3c91ca53.zip", - "reference": "c2dff3ca9e8ee4e5c9652a366c39eb3b3c91ca53", + "url": "https://github.com/fabpot/Silex/archive/c1bf812c4a5c335f0d8489ae4ca9e5f42a7d7a24.zip", + "reference": "c1bf812c4a5c335f0d8489ae4ca9e5f42a7d7a24", "shasum": "" }, "require": { @@ -1294,7 +1328,6 @@ "symfony/routing": ">=2.1,<2.3-dev" }, "require-dev": { - "monolog/monolog": ">=1.0.0,<1.2-dev", "twig/twig": ">=1.8.0,<2.0-dev", "swiftmailer/swiftmailer": "4.2.*", "doctrine/dbal": ">=2.2.0,<2.4.0-dev", @@ -1310,21 +1343,22 @@ "symfony/translation": ">=2.1,<2.3-dev", "symfony/twig-bridge": ">=2.1,<2.3-dev", "symfony/validator": ">=2.1,<2.3-dev", - "symfony/serializer": ">=2.1,<2.3-dev" + "symfony/serializer": ">=2.1,<2.3-dev", + "symfony/dom-crawler": ">=2.1,<2.3-dev", + "symfony/options-resolver": ">=2.1,<2.3-dev" }, "suggest": { "symfony/browser-kit": ">=2.1,<2.3-dev", "symfony/css-selector": ">=2.1,<2.3-dev", "symfony/dom-crawler": ">=2.1,<2.3-dev" }, - "time": "2012-12-14 13:15:04", + "time": "2013-01-24 08:46:05", "type": "library", "extra": { "branch-alias": { "dev-master": "1.0.x-dev" } }, - "installation-source": "source", "autoload": { "psr-0": { "Silex": "src/" @@ -1349,8 +1383,7 @@ "homepage": "http://silex.sensiolabs.org", "keywords": [ "microframework" - ], - "time": "1350911324" + ] }, { "name": "swftools/swftools", @@ -1358,27 +1391,26 @@ "source": { "type": "git", "url": "https://github.com/alchemy-fr/PHPSwftools", - "reference": "9b79c0fb1f43a2e84c26e908d54b1ed98091510c" + "reference": "0.1.0" }, "dist": { "type": "zip", - "url": "https://github.com/alchemy-fr/PHPSwftools/archive/9b79c0fb1f43a2e84c26e908d54b1ed98091510c.zip", - "reference": "9b79c0fb1f43a2e84c26e908d54b1ed98091510c", + "url": "https://github.com/alchemy-fr/PHPSwftools/archive/0.1.0.zip", + "reference": "0.1.0", "shasum": "" }, "require": { - "monolog/monolog": "1.0.*", "php": ">=5.3.3", - "symfony/process": ">=2.0,<=2.2" + "symfony/process": ">=2.0,<=2.2", + "monolog/monolog": "1.*" }, "require-dev": { "fabpot/php-cs-fixer": "dev-master", "sami/sami": "dev-master", "silex/silex": "dev-master" }, - "time": "2012-10-08 14:06:53", + "time": "2012-12-21 16:29:27", "type": "library", - "installation-source": "source", "autoload": { "psr-0": { "SwfTools": "src" @@ -1424,14 +1456,13 @@ "require": { "php": ">=5.2.4" }, - "time": "2012-06-17 20:55:34", + "time": "2012-06-17 13:55:34", "type": "library", "extra": { "branch-alias": { "dev-master": "4.1-dev" } }, - "installation-source": "dist", "autoload": { "files": [ "lib/swift_required.php" @@ -1462,12 +1493,12 @@ "source": { "type": "git", "url": "git://github.com/symfony/symfony.git", - "reference": "ad29df5efdc51096f882a7a7bc672d41281770ce" + "reference": "bdc7e91865b4633b01e79ff91aadb58efccfa981" }, "dist": { "type": "zip", - "url": "https://github.com/symfony/symfony/archive/ad29df5efdc51096f882a7a7bc672d41281770ce.zip", - "reference": "ad29df5efdc51096f882a7a7bc672d41281770ce", + "url": "https://github.com/symfony/symfony/archive/bdc7e91865b4633b01e79ff91aadb58efccfa981.zip", + "reference": "bdc7e91865b4633b01e79ff91aadb58efccfa981", "shasum": "" }, "require": { @@ -1514,11 +1545,10 @@ "doctrine/orm": ">=2.2.3,<2.4-dev", "doctrine/data-fixtures": "1.0.*", "propel/propel1": "dev-master", - "monolog/monolog": "1.*" + "monolog/monolog": ">=1.0,<1.3-dev" }, - "time": "2012-12-15 17:28:15", + "time": "2013-01-22 07:14:57", "type": "library", - "installation-source": "source", "autoload": { "psr-0": { "Symfony": "src/", @@ -1550,15 +1580,14 @@ "version": "dev-master", "source": { "type": "git", - "url": "git://tcpdf.git.sourceforge.net/gitroot/tcpdf/tcpdf", - "reference": "f2aa41dd8252ad6321bad88776889b75b127a60c" + "url": "git://git.code.sf.net/p/tcpdf/code", + "reference": "f7d525858a807acb59a21857e78706917ae8dbf7" }, "require": { "php": ">=5.3.0" }, - "time": "2012-09-25 18:17:00", + "time": "2013-01-22 17:33:43", "type": "library", - "installation-source": "source", "autoload": { "classmap": [ "fonts", @@ -1578,6 +1607,7 @@ "unicode_data.php" ] }, + "notification-url": "https://packagist.org/downloads/", "license": [ "LGPLv3" ], @@ -1606,24 +1636,24 @@ "source": { "type": "git", "url": "https://github.com/fabpot/Twig-extensions", - "reference": "d1990ffaca93302709d1306d50ae153adb169f49" + "reference": "5c2d515d4624bdd588226d688173cf0399a4d8cf" }, "dist": { "type": "zip", - "url": "https://github.com/fabpot/Twig-extensions/archive/d1990ffaca93302709d1306d50ae153adb169f49.zip", - "reference": "d1990ffaca93302709d1306d50ae153adb169f49", + "url": "https://github.com/fabpot/Twig-extensions/archive/5c2d515d4624bdd588226d688173cf0399a4d8cf.zip", + "reference": "5c2d515d4624bdd588226d688173cf0399a4d8cf", "shasum": "" }, "require": { "twig/twig": "1.*" }, + "time": "2013-01-04 16:55:05", "type": "library", "extra": { "branch-alias": { "dev-master": "1.0.x-dev" } }, - "installation-source": "source", "autoload": { "psr-0": { "Twig_Extensions_": "lib/" @@ -1645,8 +1675,7 @@ "debug", "i18n", "text" - ], - "time": "1349889206" + ] }, { "name": "twig/twig", @@ -1654,24 +1683,24 @@ "source": { "type": "git", "url": "git://github.com/fabpot/Twig.git", - "reference": "6c01c14fd8f42348a032148ebecb6e034e9e18bd" + "reference": "93c6a8dedc46c73ccdd61342de3d5e761e4412f6" }, "dist": { "type": "zip", - "url": "https://github.com/fabpot/Twig/archive/6c01c14fd8f42348a032148ebecb6e034e9e18bd.zip", - "reference": "6c01c14fd8f42348a032148ebecb6e034e9e18bd", + "url": "https://github.com/fabpot/Twig/archive/93c6a8dedc46c73ccdd61342de3d5e761e4412f6.zip", + "reference": "93c6a8dedc46c73ccdd61342de3d5e761e4412f6", "shasum": "" }, "require": { "php": ">=5.2.4" }, + "time": "2013-01-18 09:58:04", "type": "library", "extra": { "branch-alias": { "dev-master": "1.12-dev" } }, - "installation-source": "source", "autoload": { "psr-0": { "Twig_": "lib/" @@ -1695,8 +1724,7 @@ "homepage": "http://twig.sensiolabs.org", "keywords": [ "templating" - ], - "time": "1350737598" + ] }, { "name": "zend/gdata", @@ -1715,8 +1743,8 @@ "require": { "php": ">5.2.4" }, + "time": "2012-05-04 11:57:49", "type": "library", - "installation-source": "source", "autoload": { "psr-0": { "Zend_": "library" @@ -1736,8 +1764,7 @@ "keywords": [ "zend", "gdata" - ], - "time": "1336132669" + ] } ], "packages-dev": [ @@ -1747,20 +1774,33 @@ "source": { "type": "git", "url": "https://github.com/doctrine/data-fixtures.git", - "reference": "84cd1ca060e06bf5eb7066adb334adea4bf29fe7" + "reference": "50e7e644984f17038224f6fcd02c2b7c20147980" }, "dist": { "type": "zip", - "url": "https://github.com/doctrine/data-fixtures/archive/84cd1ca060e06bf5eb7066adb334adea4bf29fe7.zip", - "reference": "84cd1ca060e06bf5eb7066adb334adea4bf29fe7", + "url": "https://github.com/doctrine/data-fixtures/archive/50e7e644984f17038224f6fcd02c2b7c20147980.zip", + "reference": "50e7e644984f17038224f6fcd02c2b7c20147980", "shasum": "" }, "require": { "php": ">=5.3.2", "doctrine/common": ">=2.2,<2.5-dev" }, + "require-dev": { + "doctrine/orm": ">=2.2,<2.5-dev" + }, + "suggest": { + "doctrine/orm": "For loading ORM fixtures", + "doctrine/mongodb-odm": "For loading MongoDB ODM fixtures", + "doctrine/phpcr-odm": "For loading PHPCR ODM fixtures" + }, + "time": "2013-01-05 13:05:52", "type": "library", - "installation-source": "source", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, "autoload": { "psr-0": { "Doctrine\\Common\\DataFixtures": "lib/" @@ -1781,8 +1821,7 @@ "homepage": "http://www.doctrine-project.org", "keywords": [ "database" - ], - "time": "1350901469" + ] }, { "name": "fabpot/php-cs-fixer", @@ -1790,12 +1829,12 @@ "source": { "type": "git", "url": "https://github.com/fabpot/PHP-CS-Fixer.git", - "reference": "v0.1.0" + "reference": "2377b9ea383ac7939e563c3dd6ee2be9ee2d3183" }, "dist": { "type": "zip", - "url": "https://github.com/fabpot/PHP-CS-Fixer/archive/v0.1.0.zip", - "reference": "v0.1.0", + "url": "https://github.com/fabpot/PHP-CS-Fixer/archive/2377b9ea383ac7939e563c3dd6ee2be9ee2d3183.zip", + "reference": "2377b9ea383ac7939e563c3dd6ee2be9ee2d3183", "shasum": "" }, "require": { @@ -1804,7 +1843,7 @@ "symfony/finder": "2.1.*", "php": ">=5.3.3" }, - "time": "2012-11-20 07:00:21", + "time": "2013-01-04 16:55:35", "bin": [ "php-cs-fixer" ], @@ -1814,12 +1853,12 @@ "dev-master": "0.1.x-dev" } }, - "installation-source": "source", "autoload": { "psr-0": { "Symfony\\CS": "." } }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], From 62a27940b9f017e75979f94b2b8c10f84e2f79c8 Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Thu, 24 Jan 2013 17:04:50 +0100 Subject: [PATCH 6/7] Fix unit tests --- .../ApplicationSpecification.php | 6 +-- lib/Alchemy/Phrasea/Core/Service/Builder.php | 2 +- .../Core/Service/TaskManager/TaskManager.php | 4 +- lib/classes/task/period/archive.php | 2 +- .../Phrasea/Application/OverviewTest.php | 28 ++++-------- .../Controller/Admin/AdminCollectionTest.php | 45 +++++++++++-------- .../Controller/Admin/AdminDashboardTest.php | 6 ++- .../Phrasea/Controller/Admin/DataboxTest.php | 21 ++++++--- .../Controller/Admin/DataboxesTest.php | 3 +- .../Controller/Admin/DescriptionTest.php | 37 ++++++--------- .../Controller/Admin/PublicationTest.php | 6 --- .../Phrasea/Controller/Admin/SetupTest.php | 4 +- .../Controller/Prod/DoDownloadTest.php | 22 +++++---- .../Phrasea/Controller/Prod/ExportTest.php | 10 ++--- .../Controller/Prod/MustacheLoaderTest.php | 11 ++--- .../Phrasea/Controller/Prod/PropertyTest.php | 6 ++- .../Phrasea/Controller/Prod/RecordsTest.php | 3 +- .../Phrasea/Controller/Prod/TooltipTest.php | 9 ++-- .../Phrasea/Controller/Prod/UploadTest.php | 1 - .../Phrasea/Controller/Prod/UsrListsTest.php | 6 +-- .../Phrasea/Controller/Prod/WorkZoneTest.php | 6 +-- .../Phrasea/Controller/Root/AccountTest.php | 8 ++-- .../Controller/Root/DevelopersTest.php | 15 ++++--- .../Phrasea/Controller/Root/LoginTest.php | 6 ++- .../Phrasea/Controller/Root/RSSFeedTest.php | 6 +-- .../Phrasea/Controller/Root/SessionTest.php | 3 +- .../Controller/User/NotificationsTest.php | 9 ++-- .../Controller/User/PreferencesTest.php | 6 ++- tests/classes/PhraseanetPHPUnitAbstract.php | 25 ++++++++--- 29 files changed, 163 insertions(+), 153 deletions(-) diff --git a/lib/Alchemy/Phrasea/Core/Configuration/ApplicationSpecification.php b/lib/Alchemy/Phrasea/Core/Configuration/ApplicationSpecification.php index 67165973df..f5f594d743 100644 --- a/lib/Alchemy/Phrasea/Core/Configuration/ApplicationSpecification.php +++ b/lib/Alchemy/Phrasea/Core/Configuration/ApplicationSpecification.php @@ -123,17 +123,17 @@ class ApplicationSpecification implements SpecificationInterface $this->delete(); copy( - $this->getRealRootPath() . "/conf.d/connexions.yml" + $this->getRealRootPath() . "/lib/conf.d/connexions.yml" , $this->getConnexionsPathFile() ); copy( - $this->getRealRootPath() . "/conf.d/services.yml" + $this->getRealRootPath() . "/lib/conf.d/services.yml" , $this->getServicesPathFile() ); copy( - $this->getRealRootPath() . "/conf.d/config.yml" + $this->getRealRootPath() . "/lib/conf.d/config.yml" , $this->getConfigurationsPathFile() ); diff --git a/lib/Alchemy/Phrasea/Core/Service/Builder.php b/lib/Alchemy/Phrasea/Core/Service/Builder.php index 443caf1da8..a4c973f673 100644 --- a/lib/Alchemy/Phrasea/Core/Service/Builder.php +++ b/lib/Alchemy/Phrasea/Core/Service/Builder.php @@ -31,7 +31,7 @@ class Builder } try { - $options = $configuration->get("options"); + $options = $configuration->get("options") ?: array() ; } catch (\Exception $e) { $options = array(); } diff --git a/lib/Alchemy/Phrasea/Core/Service/TaskManager/TaskManager.php b/lib/Alchemy/Phrasea/Core/Service/TaskManager/TaskManager.php index c90e45822d..611afec042 100644 --- a/lib/Alchemy/Phrasea/Core/Service/TaskManager/TaskManager.php +++ b/lib/Alchemy/Phrasea/Core/Service/TaskManager/TaskManager.php @@ -40,12 +40,12 @@ class TaskManager extends ServiceAbstract $options = $this->getOptions(); $registry = $this->app['phraseanet.registry']; - if (null !== $syslogLevel = constant($options['syslog_level'])) { + if (isset($options['syslog_level']) && null !== $syslogLevel = constant($options['syslog_level'])) { $handler = new SyslogHandler("Phraseanet-Task", "user", $syslogLevel); $logger->pushHandler($handler); } - if (null !== $maillogLevel = constant($options['maillog_level'])) { + if (isset($options['maillog_level']) && null !== $maillogLevel = constant($options['maillog_level'])) { if ('' === $adminMail = trim($registry->get('GV_adminMail'))) { throw new RuntimeException("Admininstrator mail must be set to get log by mail."); } diff --git a/lib/classes/task/period/archive.php b/lib/classes/task/period/archive.php index c367d1a9ee..3eab940a99 100644 --- a/lib/classes/task/period/archive.php +++ b/lib/classes/task/period/archive.php @@ -2089,7 +2089,7 @@ class task_period_archive extends task_abstract $fields = caption_field::get_multi_values($field, $meta->get_separator()); if (!$metadataBag->containsKey($meta->get_name())) { - $values = new \PHPExiftool\Driver\Value\Multi($fields); + $values = $fields; } else { $values = array_merge($metadataBag->get($meta->get_name())->getValue(), $fields); } diff --git a/tests/Alchemy/Tests/Phrasea/Application/OverviewTest.php b/tests/Alchemy/Tests/Phrasea/Application/OverviewTest.php index bc0d67d935..c827e9e2c8 100644 --- a/tests/Alchemy/Tests/Phrasea/Application/OverviewTest.php +++ b/tests/Alchemy/Tests/Phrasea/Application/OverviewTest.php @@ -4,7 +4,6 @@ namespace Alchemy\Tests\Phrasea\Application; use Alchemy\Phrasea\Border\File; use Symfony\Component\HttpFoundation\File\UploadedFile; -use Symfony\Component\HttpKernel\Exception\HttpException; class ApplicationOverviewTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { @@ -20,12 +19,11 @@ class ApplicationOverviewTest extends \PhraseanetWebTestCaseAuthenticatedAbstrac $this->assertEquals(self::$DI['record_1']->get_preview()->get_size(), $response->headers->get('content-length')); } - /** - * @expectedException Symfony\Component\HttpKernel\Exception\NotFoundHttpException - */ function testDatafilesNonExistentSubdef() { - $crawler = self::$DI['client']->request('GET', '/datafiles/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/asubdefthatdoesnotexists/'); + self::$DI['client']->request('GET', '/datafiles/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/asubdefthatdoesnotexists/'); + + $this->assertNotFoundResponse(self::$DI['client']->getResponse()); } function testEtag() @@ -58,25 +56,17 @@ class ApplicationOverviewTest extends \PhraseanetWebTestCaseAuthenticatedAbstrac function testDatafilesRouteNotAuthenticated() { self::$DI['app']->closeAccount(); - try { - $crawler = self::$DI['client']->request('GET', '/datafiles/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/preview/'); - $this->fail('should throw an HttpException'); - } catch (HttpException $e) { - $response = self::$DI['client']->getResponse(); - $this->assertEquals(403, $e->getStatusCode()); - } + self::$DI['client']->request('GET', '/datafiles/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/preview/'); + + $this->assertForbiddenResponse(self::$DI['client']->getResponse()); } function testDatafilesRouteNotAuthenticatedUnknownSubdef() { self::$DI['app']->closeAccount(); - try { - $crawler = self::$DI['client']->request('GET', '/datafiles/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/notfoundreview/'); - $this->fail('should throw an HttpException'); - } catch (HttpException $e) { - $response = self::$DI['client']->getResponse(); - $this->assertEquals(403, $e->getStatusCode()); - } + self::$DI['client']->request('GET', '/datafiles/' . self::$DI['record_1']->get_sbas_id() . '/' . self::$DI['record_1']->get_record_id() . '/notfoundreview/'); + + $this->assertForbiddenResponse(self::$DI['client']->getResponse()); } function testPermalinkAuthenticated() diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/AdminCollectionTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/AdminCollectionTest.php index 551019cdf8..5e45d0c6f5 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/AdminCollectionTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/AdminCollectionTest.php @@ -10,12 +10,6 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract protected $client; public static $createdCollections = array(); - public function setUp() - { - parent::setUp(); - self::$DI['app.use-exception-handler'] = true; - } - public function tearDown() { self::$DI['app']['phraseanet.user'] = self::$DI['user']; @@ -192,7 +186,6 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers Alchemy\Phrasea\Controller\Admin\Bas::enable */ public function testPostEnableUnauthorizedException() @@ -200,6 +193,8 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->setAdmin(false); self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/enable/'); + + $this->assertForbiddenResponse(self::$DI['client']->getResponse()); } /** @@ -232,7 +227,6 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers Alchemy\Phrasea\Controller\Admin\Bas::disabled */ public function testPostDisabledUnauthorizedException() @@ -240,6 +234,8 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->setAdmin(false); self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/disabled/'); + + $this->assertForbiddenResponse(self::$DI['client']->getResponse()); } /** @@ -259,7 +255,6 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers Alchemy\Phrasea\Controller\Admin\Bas::setOrderAdmins */ public function testPostOrderAdminsUnauthorizedException() @@ -267,6 +262,8 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->setAdmin(false); self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/order/admins/'); + + $this->assertForbiddenResponse(self::$DI['client']->getResponse()); } /** @@ -300,7 +297,6 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers Alchemy\Phrasea\Controller\Admin\Bas::setPublicationDisplay */ public function testPostPublicationDisplayUnauthorizedException() @@ -308,6 +304,8 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->setAdmin(false); self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/publication/display/'); + + $this->assertForbiddenResponse(self::$DI['client']->getResponse()); } /** @@ -356,7 +354,6 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers Alchemy\Phrasea\Controller\Admin\Bas::rename */ public function testPostNameUnauthorizedException() @@ -364,6 +361,8 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->setAdmin(false); self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/rename/'); + + $this->assertForbiddenResponse(self::$DI['client']->getResponse()); } /** @@ -509,7 +508,6 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers Alchemy\Phrasea\Controller\Admin\Bas::setMiniLogo */ public function testSetMiniLogoBadRequest() @@ -517,10 +515,11 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->setAdmin(true); self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/picture/mini-logo/'); + + $this->assertBadResponse(self::$DI['client']->getResponse()); } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers Alchemy\Phrasea\Controller\Admin\Bas::setStamp */ public function testSetStampBadRequest() @@ -528,19 +527,21 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->setAdmin(true); self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/picture/stamp-logo/'); + + $this->assertBadResponse(self::$DI['client']->getResponse()); } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers Alchemy\Phrasea\Controller\Admin\Bas::setWatermark */ public function testSetWatermarkBadRequest() { self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/picture/watermark/'); + + $this->assertBadResponse(self::$DI['client']->getResponse()); } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers Alchemy\Phrasea\Controller\Admin\Bas::setBanner */ public function testSetBannerBadRequest() @@ -548,6 +549,8 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->setAdmin(true); self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/picture/banner/'); + + $this->assertBadResponse(self::$DI['client']->getResponse()); } /** @@ -741,7 +744,6 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers Alchemy\Phrasea\Controller\Admin\Bas::getCollection */ public function testGetCollectionUnauthorizedException() @@ -749,10 +751,11 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->setAdmin(false); self::$DI['client']->request('GET', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/'); + + $this->assertForbiddenResponse(self::$DI['client']->getResponse()); } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers Alchemy\Phrasea\Controller\Admin\Bas::getSuggestedValues */ public function testGetSuggestedValuesUnauthorizedException() @@ -760,10 +763,11 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->setAdmin(false); self::$DI['client']->request('GET', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/suggested-values/'); + + $this->assertForbiddenResponse(self::$DI['client']->getResponse()); } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers Alchemy\Phrasea\Controller\Admin\Bas::getDetails */ public function testInformationsDetailsUnauthorizedException() @@ -771,6 +775,8 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->setAdmin(false); self::$DI['client']->request('GET', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/informations/details/'); + + $this->assertForbiddenResponse(self::$DI['client']->getResponse()); } /** @@ -788,7 +794,6 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers Alchemy\Phrasea\Controller\Admin\Bas::delete */ public function testDeleteCollectionUnauthorized() @@ -796,6 +801,8 @@ class AdminCollectionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->setAdmin(false); self::$DI['client']->request('POST', '/admin/collection/' . self::$DI['collection']->get_base_id() . '/delete/'); + + $this->assertForbiddenResponse(self::$DI['client']->getResponse()); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/AdminDashboardTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/AdminDashboardTest.php index 28b774164c..4c5dfcfc25 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/AdminDashboardTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/AdminDashboardTest.php @@ -7,7 +7,6 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract protected $client; /** - * @expectedException Symfony\Component\HttpKernel\Exception\HttpException * @covers \Alchemy\Phrasea\Controller\Admin\Dashboard::slash * @covers \Alchemy\Phrasea\Controller\Admin\Dashboard::connect * @covers \Alchemy\Phrasea\Controller\Admin\Dashboard::call @@ -16,6 +15,8 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { $this->setAdmin(false); self::$DI['client']->request('GET', '/admin/dashboard/'); + + $this->assertForbiddenResponse(self::$DI['client']->getResponse()); } /** @@ -62,7 +63,6 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers \Alchemy\Phrasea\Controller\Admin\Dashboard::sendMail */ public function testSendMailTestBadRequest() @@ -70,6 +70,8 @@ class AdminDashboardTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->setAdmin(true); self::$DI['client']->request('POST', '/admin/dashboard/send-mail-test/'); + + $this->assertBadResponse(self::$DI['client']->getResponse()); } /** * @covers \Alchemy\Phrasea\Controller\Admin\Dashboard::resetAdminRights diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/DataboxTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/DataboxTest.php index 3ce605c95d..b74e2ff4e4 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/DataboxTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/DataboxTest.php @@ -126,7 +126,6 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract /** * @covers \Alchemy\Phrasea\Controller\Admin\Database::getDatabaseCGU - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException */ public function testGetCGUHasNoRights() { @@ -138,6 +137,8 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->setAdmin(true); self::$DI['client']->request('GET', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/cgus/'); + + $this->assertForbiddenResponse(self::$DI['client']->getResponse()); } /** @@ -199,7 +200,6 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers \Alchemy\Phrasea\Controller\Admin\Database::progressBarInfos */ public function testGetInformationDocumentBadRequest() @@ -207,6 +207,8 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->setAdmin(true); self::$DI['client']->request('GET', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/informations/documents/'); + + $this->assertBadResponse(self::$DI['client']->getResponse()); } /** @@ -252,7 +254,6 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers \Alchemy\Phrasea\Controller\Admin\Database::getDatabase */ public function testGetDataboxUnauthorizedException() @@ -260,10 +261,11 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->setAdmin(false); self::$DI['client']->request('GET', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/'); + + $this->assertForbiddenResponse(self::$DI['client']->getResponse()); } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers \Alchemy\Phrasea\Controller\Admin\Database::getReorder */ public function testGetCollectionOrderUnauthorizedException() @@ -271,10 +273,11 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->setAdmin(false); self::$DI['client']->request('GET', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/collections/order/'); + + $this->assertForbiddenResponse(self::$DI['client']->getResponse()); } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers \Alchemy\Phrasea\Controller\Admin\Database::getDatabaseCGU */ public function testGetCGUUnauthorizedException() @@ -282,6 +285,8 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->setAdmin(false); self::$DI['client']->request('GET', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/cgus/'); + + $this->assertForbiddenResponse(self::$DI['client']->getResponse()); } /** @@ -297,7 +302,6 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers \Alchemy\Phrasea\Controller\Admin\Database::progressBarInfos */ public function testGetInformationDetailsUnauthorizedException() @@ -305,10 +309,11 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->setAdmin(false); self::$DI['client']->request('GET', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/informations/details/'); + + $this->assertForbiddenResponse(self::$DI['client']->getResponse()); } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers \Alchemy\Phrasea\Controller\Admin\Database::getNewCollection */ public function testGetNewCollectionUnauthorizedException() @@ -316,6 +321,8 @@ class DataboxTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->setAdmin(false); self::$DI['client']->request('GET', '/admin/databox/' . self::$DI['collection']->get_sbas_id() . '/collection/'); + + $this->assertForbiddenResponse(self::$DI['client']->getResponse()); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/DataboxesTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/DataboxesTest.php index 6662b864b3..613ae3ab45 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/DataboxesTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/DataboxesTest.php @@ -39,13 +39,14 @@ class DataboxesTest extends \PhraseanetWebTestCaseAuthenticatedAbstract /** * @covers Alchemy\Phrasea\Controller\Admin\Databases::getDatabases - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException */ public function testGetSlashUnauthorizedException() { $this->setAdmin(false); self::$DI['client']->request('GET', '/admin/databoxes/'); + + $this->assertForbiddenResponse(self::$DI['client']->getResponse()); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/DescriptionTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/DescriptionTest.php index 78c687cbe8..026f750c38 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/DescriptionTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/DescriptionTest.php @@ -2,8 +2,6 @@ namespace Alchemy\Tests\Phrasea\Controller\Admin; -use Symfony\Component\HttpKernel\Exception\HttpException; - class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { protected $client; @@ -186,23 +184,19 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $field = \databox_field::create(self::$DI['app'], $databox, $name, false); $id = $field->get_id(); - try { - self::$DI['client']->request("POST", "/admin/description/" . $databox->get_sbas_id() . "/", array( - 'field_ids' => array($id) - , 'name_' . $id => $name - , 'multi_' . $id => 1 - , 'indexable_' . $id => 1 - , 'src_' . $id => '/rdf:RDF/rdf:Description/IPTC:SupplementalCategories' - , 'required_' . $id => 0 - , 'readonly_' . $id => 0 - , 'type_' . $id => 'string' - , 'vocabulary_' . $id => 'User' - )); - print(self::$DI['client']->getResponse()->getContent()); - $this->fail('Should throw an HttpException'); - } catch (HttpException $e) { + self::$DI['client']->request("POST", "/admin/description/" . $databox->get_sbas_id() . "/", array( + 'field_ids' => array($id) + , 'name_' . $id => $name + , 'multi_' . $id => 1 + , 'indexable_' . $id => 1 + , 'src_' . $id => '/rdf:RDF/rdf:Description/IPTC:SupplementalCategories' + , 'required_' . $id => 0 + , 'readonly_' . $id => 0 + , 'type_' . $id => 'string' + , 'vocabulary_' . $id => 'User' + )); - } + $this->assertForbiddenResponse(self::$DI['client']->getResponse()); $field->delete(); } @@ -214,12 +208,9 @@ class DescriptionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $databoxes = self::$DI['app']['phraseanet.appbox']->get_databoxes(); $databox = array_shift($databoxes); - try { - self::$DI['client']->request("GET", "/admin/description/" . $databox->get_sbas_id() . "/"); - $this->fail('Should throw an HttpException'); - } catch (HttpException $e) { + self::$DI['client']->request("GET", "/admin/description/" . $databox->get_sbas_id() . "/"); - } + $this->assertForbiddenResponse(self::$DI['client']->getResponse()); } public function testGetDescription() diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/PublicationTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/PublicationTest.php index c46d78113e..dd52be9933 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/PublicationTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/PublicationTest.php @@ -8,12 +8,6 @@ class Module_Admin_Route_PublicationTest extends \PhraseanetWebTestCaseAuthentic public static $api = null; protected $client; - public function setUp() - { - parent::setUp(); - self::$DI['app.use-exception-handler'] = true; - } - public function testList() { $crawler = self::$DI['client']->request('GET', '/admin/publications/list/'); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Admin/SetupTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Admin/SetupTest.php index 855f478793..99abc33580 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Admin/SetupTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Admin/SetupTest.php @@ -18,14 +18,14 @@ class SetupTest extends \PhraseanetWebTestCaseAuthenticatedAbstract /** * @covers Alchemy\Phrasea\Controller\Admin\Setup::getGlobals - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException */ public function testGetSlashUnauthorizedException() { $this->setAdmin(false); self::$DI['client']->request('GET', '/admin/setup/'); - $this->assertTrue(self::$DI['client']->getResponse()->isOk()); + + $this->assertForbiddenResponse(self::$DI['client']->getResponse()); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/DoDownloadTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/DoDownloadTest.php index 376c0896bb..83e54ceedd 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/DoDownloadTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/DoDownloadTest.php @@ -46,22 +46,26 @@ class DoDownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract /** * @covers Alchemy\Phrasea\Controller\Prod\DoDownload::prepareDownload - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException */ public function testPrepareDownloadTokenNotFound() { $token = 'AzBdisusjA'; self::$DI['client']->request('GET', sprintf('/download/%s/prepare/', $token)); + + $this->assertNotFoundResponse(self::$DI['client']->getResponse()); } /** * @covers Alchemy\Phrasea\Controller\Prod\DoDownload::prepareDownload - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException */ public function testPrepareDownloadInvalidData() { $token = $this->getToken(array('bad_string' => base64_decode(serialize(array('fail'))))); self::$DI['client']->request('GET', sprintf('/download/%s/prepare/', $token)); + + $response = self::$DI['client']->getResponse(); + $this->assertEquals(500, $response->getStatusCode()); + $this->assertTrue(false !== stripos($response->getContent(), 'internal server error')); } /** @@ -185,7 +189,6 @@ class DoDownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract /** * @covers Alchemy\Phrasea\Controller\Prod\DoDownload::downloadDocuments - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException */ public function testDocumentsDownloadNotFound() { @@ -215,29 +218,32 @@ class DoDownloadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract )); $url = sprintf('/download/%s/get/', $token); self::$DI['client']->request('POST', $url); - $response = self::$DI['client']->getResponse(); - $this->assertTrue($response->isOk()); - unset($response); + + $this->assertNotFoundResponse(self::$DI['client']->getResponse()); } /** * @covers Alchemy\Phrasea\Controller\Prod\DoDownload::downloadDocuments - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException */ public function testDocumentsDownloadTokenNotFound() { $token = 'AzBdisusjA'; self::$DI['client']->request('POST', sprintf('/download/%s/get/', $token)); + + $this->assertNotFoundResponse(self::$DI['client']->getResponse()); } /** * @covers Alchemy\Phrasea\Controller\Prod\DoDownload::downloadDocuments - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException */ public function testDocumentsDownloadInvalidData() { $token = $this->getToken(array('bad_string' => base64_decode(serialize(array('fail'))))); self::$DI['client']->request('POST', sprintf('/download/%s/get/', $token)); + + $response = self::$DI['client']->getResponse(); + $this->assertEquals(500, $response->getStatusCode()); + $this->assertTrue(false !== stripos($response->getContent(), 'internal server error')); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/ExportTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/ExportTest.php index eb8a76bc5a..2d56cead5f 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/ExportTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/ExportTest.php @@ -76,7 +76,6 @@ class ExportTest extends \PhraseanetWebTestCaseAuthenticatedAbstract } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers Alchemy\Phrasea\Controller\Prod\Export::testFtpConnexion */ public function testFtpConnexionNoXMLHTTPRequests() @@ -98,10 +97,8 @@ class ExportTest extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['client']->request('POST', '/prod/export/ftp/test/', array('lst' => self::$DI['record_1']->get_serialize_key())); $response = self::$DI['client']->getResponse(); $datas = (array) json_decode($response->getContent()); - $this->assertArrayHasKey('success', $datas); - $this->assertFalse($datas['success']); - $this->assertArrayHasKey('message', $datas); - unset($response, $datas); + + $this->assertBadResponse(self::$DI['client']->getResponse()); } /** @@ -126,13 +123,14 @@ class ExportTest extends \PhraseanetWebTestCaseAuthenticatedAbstract } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers Alchemy\Phrasea\Controller\Prod\Export::exportFtp * @dataProvider getMissingArguments */ public function testExportFtpBadRequest($params) { self::$DI['client']->request('POST', '/prod/export/ftp/', $params); + + $this->assertBadResponse(self::$DI['client']->getResponse()); } public function getMissingArguments() diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/MustacheLoaderTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/MustacheLoaderTest.php index 3cdddc07b2..907f409c98 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/MustacheLoaderTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/MustacheLoaderTest.php @@ -10,26 +10,21 @@ class MustacheLoaderTest extends \PhraseanetWebTestCaseAuthenticatedAbstract { self::$DI['client']->request('GET', '/prod/MustacheLoader/'); - $response = self::$DI['client']->getResponse(); - /* @var $response \Symfony\Component\HttpFoundation\Response */ - $this->assertEquals(400, $response->getStatusCode()); + $this->assertBadResponse(self::$DI['client']->getResponse()); } public function testRouteSlashWrongUrl() { self::$DI['client']->request('GET', '/prod/MustacheLoader/', array('template' => '/../../../../config/config.yml')); - $response = self::$DI['client']->getResponse(); - $this->assertEquals(400, $response->getStatusCode()); - /* @var $response \Symfony\Component\HttpFoundation\Response */ + $this->assertBadResponse(self::$DI['client']->getResponse()); } public function testRouteSlashWrongFile() { self::$DI['client']->request('GET', '/prod/MustacheLoader/', array('template' => 'patator_lala')); - $response = self::$DI['client']->getResponse(); - $this->assertEquals(404, $response->getStatusCode()); + $this->assertNotFoundResponse(self::$DI['client']->getResponse()); } public function testRouteGood() diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/PropertyTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/PropertyTest.php index a1234c8417..8e3e1a4807 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/PropertyTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/PropertyTest.php @@ -20,12 +20,13 @@ class PropertyTest extends \PhraseanetWebTestCaseAuthenticatedAbstract } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers Alchemy\Phrasea\Controller\Prod\Property::displayStatusProperty */ public function testDisplayStatusPropertyNotXMLHTTPRequets() { self::$DI['client']->request('GET', '/prod/records/property/'); + + $this->assertBadResponse(self::$DI['client']->getResponse()); } /** @@ -40,12 +41,13 @@ class PropertyTest extends \PhraseanetWebTestCaseAuthenticatedAbstract } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers Alchemy\Phrasea\Controller\Prod\Property::displayProperty */ public function testDisplayTypePropertyNotXMLHTTPRequets() { self::$DI['client']->request('GET', '/prod/records/property/type/'); + + $this->assertBadResponse(self::$DI['client']->getResponse()); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/RecordsTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/RecordsTest.php index 250a060c81..fa60fd8ba3 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/RecordsTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/RecordsTest.php @@ -70,11 +70,12 @@ class RecordsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract /** * @covers Alchemy\Phrasea\Controller\Prod\Records::getRecord - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException */ public function testGetRecordDetailNotAjax() { self::$DI['client']->request('POST', '/prod/records/'); + + $this->assertBadResponse(self::$DI['client']->getResponse()); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/TooltipTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/TooltipTest.php index dcb0904fde..1b8f863bee 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/TooltipTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/TooltipTest.php @@ -18,25 +18,22 @@ class ControllerTooltipTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->assertTrue(self::$DI['client']->getResponse()->isOk()); } - /** - * @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException - */ public function testRouteBasketFail() { $crawler = self::$DI['client']->request('POST', '/prod/tooltip/basket/notanid/'); $pageContent = self::$DI['client']->getResponse()->getContent(); $this->assertFalse(self::$DI['client']->getResponse()->isOk()); + $this->assertNotFoundResponse(self::$DI['client']->getResponse()); } - /** - * @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException - */ public function testRouteBasketFail2() { $crawler = self::$DI['client']->request('POST', '/prod/tooltip/basket/-5/'); $pageContent = self::$DI['client']->getResponse()->getContent(); $this->assertFalse(self::$DI['client']->getResponse()->isOk()); + + $this->assertNotFoundResponse(self::$DI['client']->getResponse()); } public function testRoutePreview() diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/UploadTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/UploadTest.php index a48e43957a..16a7d45a06 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/UploadTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/UploadTest.php @@ -20,7 +20,6 @@ class UploadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract public function setUp() { parent::setUp(); - self::$DI['app.use-exception-handler'] = true; $this->tmpFile = sys_get_temp_dir() . '/' . time() . mt_rand(1000, 9999) . '.jpg'; copy(__DIR__ . '/../../../../../files/cestlafete.jpg', $this->tmpFile); } diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/UsrListsTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/UsrListsTest.php index 28e3891bf3..6f1d81dd5b 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/UsrListsTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/UsrListsTest.php @@ -241,7 +241,7 @@ class ControllerUsrListsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $response = self::$DI['client']->getResponse(); - $this->assertEquals(400, $response->getStatusCode()); + $this->assertBadResponse($response); $this->assertEquals('UTF-8', $response->getCharset()); @@ -251,11 +251,9 @@ class ControllerUsrListsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $response = self::$DI['client']->getResponse(); - $this->assertEquals(400, $response->getStatusCode()); + $this->assertBadResponse($response); $this->assertEquals('UTF-8', $response->getCharset()); - - $route = '/prod/lists/list/' . $list->getId() . '/share/' . self::$DI['user_alt1']->get_id() . '/'; self::$DI['client']->request('POST', $route, array('role' => \Entities\UsrListOwner::ROLE_ADMIN)); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Prod/WorkZoneTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Prod/WorkZoneTest.php index 5caf83206e..eb643cc1f2 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Prod/WorkZoneTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Prod/WorkZoneTest.php @@ -28,8 +28,7 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['client']->request('POST', $route); $response = self::$DI['client']->getResponse(); - $this->assertEquals(400, $response->getStatusCode()); - $this->assertFalse($response->isOk()); + $this->assertBadResponse(self::$DI['client']->getResponse()); } public function testAttachStoryToWZ() @@ -146,8 +145,7 @@ class ControllerWorkZoneTest extends \PhraseanetWebTestCaseAuthenticatedAbstract self::$DI['client']->request('POST', $route); $response = self::$DI['client']->getResponse(); - $this->assertEquals(404, $response->getStatusCode()); - $this->assertFalse($response->isOk()); + $this->assertNotFoundResponse(self::$DI['client']->getResponse()); //attach $attachRoute = sprintf("/prod/WorkZone/attachStories/"); diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Root/AccountTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Root/AccountTest.php index a5ab5d64dc..88e2b4fe06 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Root/AccountTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Root/AccountTest.php @@ -120,11 +120,12 @@ class AccountTest extends \PhraseanetWebTestCaseAuthenticatedAbstract /** * @covers \Alchemy\Phrasea\Controller\Root\Account::resetEmail - * @expectedException Symfony\Component\HttpKernel\Exception\HttpException */ public function testPostResetMailBadRequest() { self::$DI['client']->request('POST', '/account/reset-email/'); + + $this->assertBadResponse(self::$DI['client']->getResponse()); } /** @@ -363,12 +364,11 @@ class AccountTest extends \PhraseanetWebTestCaseAuthenticatedAbstract $this->assertEquals(count($ret), count($bases)); } - /** - * @expectedException Symfony\Component\HttpKernel\Exception\HttpException - */ public function testAUthorizedAppGrantAccessBadRequest() { self::$DI['client']->request('GET', '/account/security/application/3/grant/'); + + $this->assertBadResponse(self::$DI['client']->getResponse()); } public function testAUthorizedAppGrantAccessNotSuccessfull() diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Root/DevelopersTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Root/DevelopersTest.php index 9fb4aba2ec..d3fc9f01fd 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Root/DevelopersTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Root/DevelopersTest.php @@ -74,11 +74,12 @@ class DevelopersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract /** * @cover \Alchemy\Phrasea\Controller\Root\Developers::getApp - * @expectedException Symfony\Component\HttpKernel\Exception\HttpException */ public function testGetUnknowApp() { self::$DI['client']->request('GET', '/developers/application/0/'); + + $this->assertNotFoundResponse(self::$DI['client']->getResponse()); } /** @@ -94,11 +95,12 @@ class DevelopersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract /** * @cover \Alchemy\Phrasea\Controller\Root\Developers::deleteApp - * @expectedException Symfony\Component\HttpKernel\Exception\HttpException */ public function testDeleteAppBadRequest() { self::$DI['client']->request('DELETE', '/developers/application/1/'); + + $this->assertBadResponse(self::$DI['client']->getResponse()); } /** @@ -134,11 +136,12 @@ class DevelopersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract /** * @cover \Alchemy\Phrasea\Controller\Root\Developers::renewAppCallback - * @expectedException Symfony\Component\HttpKernel\Exception\HttpException */ public function testRenewAppCallbackBadRequest() { self::$DI['client']->request('POST', '/developers/application/1/callback/'); + + $this->assertBadResponse(self::$DI['client']->getResponse()); } /** @@ -189,11 +192,12 @@ class DevelopersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract /** * @cover \Alchemy\Phrasea\Controller\Root\Developers::renewAccessToken - * @expectedException Symfony\Component\HttpKernel\Exception\HttpException */ public function testRenewAccessTokenbadRequest() { self::$DI['client']->request('POST', '/developers/application/1/access_token/'); + + $this->assertBadResponse(self::$DI['client']->getResponse()); } /** @@ -228,11 +232,12 @@ class DevelopersTest extends \PhraseanetWebTestCaseAuthenticatedAbstract /** * @cover \Alchemy\Phrasea\Controller\Root\Developers::authorizeGrantpassword - * @expectedException Symfony\Component\HttpKernel\Exception\HttpException */ public function testAuthorizeGrantpasswordBadRequest() { self::$DI['client']->request('POST', '/developers/application/1/authorize_grant_password/'); + + $this->assertBadResponse(self::$DI['client']->getResponse()); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Root/LoginTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Root/LoginTest.php index 0ca095e5e3..2d1bf18ddc 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Root/LoginTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Root/LoginTest.php @@ -386,12 +386,13 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract /** * @covers \Alchemy\Phrasea\Controller\Root\Login::register - * @expectedException Symfony\Component\HttpKernel\Exception\HttpException */ public function testPostRegisterBadRequest() { self::$DI['app']->closeAccount(); self::$DI['client']->request('POST', '/login/register/'); + + $this->assertBadResponse(self::$DI['client']->getResponse()); } /** @@ -618,12 +619,13 @@ class LoginTest extends \PhraseanetWebTestCaseAuthenticatedAbstract /** * @covers \Alchemy\Phrasea\Controller\Root\Login::sendConfirmMail - * @expectedException Symfony\Component\HttpKernel\Exception\HttpException */ public function testSendConfirmMailBadRequest() { self::$DI['app']->closeAccount(); self::$DI['client']->request('GET', '/login/send-mail-confirm/'); + + $this->assertBadResponse(self::$DI['client']->getResponse()); } /** diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Root/RSSFeedTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Root/RSSFeedTest.php index 8bf9960e21..f21dd581a9 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Root/RSSFeedTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Root/RSSFeedTest.php @@ -74,7 +74,6 @@ class RssFeedTest extends \PhraseanetWebTestCaseAbstract public function setUp() { parent::setUp(); - self::$DI['app.use-exception-handler'] = true; self::$feed = \Feed_Adapter::create(self::$DI['app'], self::$DI['user'], 'title', 'subtitle'); self::$publisher = \Feed_Publisher_Adapter::getPublisher(self::$DI['app']['phraseanet.appbox'], self::$feed, self::$DI['user']); self::$entry = \Feed_Entry_Adapter::create(self::$DI['app'], self::$feed, self::$publisher, 'title_entry', 'subtitle', 'hello', "test@mail.com"); @@ -334,12 +333,11 @@ class RssFeedTest extends \PhraseanetWebTestCaseAbstract $this->assertEquals(404, self::$DI['client']->getResponse()->getStatusCode()); } - /** - * @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException - */ public function testUnknowFeedId2() { self::$DI['client']->request("GET", "/feeds/feed/titi/"); + + $this->assertNotFoundResponse(self::$DI['client']->getResponse()); } public function testGetFeedId() diff --git a/tests/Alchemy/Tests/Phrasea/Controller/Root/SessionTest.php b/tests/Alchemy/Tests/Phrasea/Controller/Root/SessionTest.php index 9c2d8ad73c..627707b6f3 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/Root/SessionTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/Root/SessionTest.php @@ -70,11 +70,12 @@ class SessionTest extends \PhraseanetWebTestCaseAuthenticatedAbstract /** * @covers \Alchemy\Phrasea\Controller\Root\Session::updateSession - * @expectedException Symfony\Component\HttpKernel\Exception\HttpException */ public function testUpdSessionBadRequest() { self::$DI['client']->request('POST', '/session/update/'); + + $this->assertBadResponse(self::$DI['client']->getResponse()); } private function checkSessionReturn(\stdClass $data) diff --git a/tests/Alchemy/Tests/Phrasea/Controller/User/NotificationsTest.php b/tests/Alchemy/Tests/Phrasea/Controller/User/NotificationsTest.php index 078ed59a45..b4f71d0dde 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/User/NotificationsTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/User/NotificationsTest.php @@ -18,21 +18,23 @@ class NotificationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers Alchemy\Phrasea\Controller\User\Notifications::listNotifications */ public function testListNotificationsNoXMLHTTPRequests() { self::$DI['client']->request('GET', '/user/notifications/'); + + $this->assertBadResponse(self::$DI['client']->getResponse()); } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers Alchemy\Phrasea\Controller\User\Notifications::setNotificationsReaded */ public function testSetNotificationsReadedNoXMLHTTPRequests() { self::$DI['client']->request('POST', '/user/notifications/read/'); + + $this->assertBadResponse(self::$DI['client']->getResponse()); } /** @@ -53,7 +55,6 @@ class NotificationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers Alchemy\Phrasea\Controller\User\Notifications::connect * @covers Alchemy\Phrasea\Controller\User\Notifications::call */ @@ -69,5 +70,7 @@ class NotificationsTest extends \PhraseanetWebTestCaseAuthenticatedAbstract ->will($this->returnValue(true)); self::$DI['client']->request('GET', '/user/notifications/'); + + $this->assertForbiddenResponse(self::$DI['client']->getResponse()); } } diff --git a/tests/Alchemy/Tests/Phrasea/Controller/User/PreferencesTest.php b/tests/Alchemy/Tests/Phrasea/Controller/User/PreferencesTest.php index f82a948d34..4a2d42f058 100644 --- a/tests/Alchemy/Tests/Phrasea/Controller/User/PreferencesTest.php +++ b/tests/Alchemy/Tests/Phrasea/Controller/User/PreferencesTest.php @@ -32,21 +32,23 @@ class PreferencesTest extends \PhraseanetWebTestCaseAuthenticatedAbstract } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers Alchemy\Phrasea\Controller\User\Preferences::saveUserPref */ public function testSaveUserPrefNoXMLHTTPRequests() { self::$DI['client']->request('POST', '/user/preferences/', array('prop' => 'prop_test', 'value' => 'val_test')); + + $this->assertBadResponse(self::$DI['client']->getResponse()); } /** - * @expectedException \Symfony\Component\HttpKernel\Exception\HttpException * @covers Alchemy\Phrasea\Controller\User\Preferences::saveTemporaryPref */ public function testSaveTempPrefNoXMLHTTPRequests() { self::$DI['client']->request('POST', '/user/preferences/temporary/', array('prop' => 'prop_test', 'value' => 'val_test')); + + $this->assertBadResponse(self::$DI['client']->getResponse()); } /** diff --git a/tests/classes/PhraseanetPHPUnitAbstract.php b/tests/classes/PhraseanetPHPUnitAbstract.php index 290d72e68a..c3a2c2d45e 100644 --- a/tests/classes/PhraseanetPHPUnitAbstract.php +++ b/tests/classes/PhraseanetPHPUnitAbstract.php @@ -100,8 +100,6 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase parent::setUp(); - self::$DI['app.use-exception-handler'] = false; - \PHPUnit_Framework_Error_Warning::$enabled = true; \PHPUnit_Framework_Error_Notice::$enabled = true; @@ -112,10 +110,6 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase $app['debug'] = true; - if (!$DI['app.use-exception-handler']) { - unset($app['exception_handler']); - } - $app['EM'] = $app->share($app->extend('EM', function($em) { @unlink('/tmp/db.sqlite'); copy(__DIR__ . '/../db-ref.sqlite', '/tmp/db.sqlite'); @@ -169,6 +163,25 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase set_time_limit(0); } + protected function assertForbiddenResponse(Response $response) + { + $this->assertEquals(403, $response->getStatusCode()); + $this->assertTrue(false !== stripos($response->getContent(), 'forbidden')); + } + + protected function assertBadResponse(Response $response) + { + $this->assertEquals(400, $response->getStatusCode()); + $this->assertTrue(false !== stripos($response->getContent(), 'bad request')); + } + + protected function assertNotFoundResponse(Response $response) + { + $this->assertEquals(404, $response->getStatusCode()); + $this->assertTrue(false !== stripos($response->getContent(), 'not found')); + } + + /** * Insert fixture contained in the specified fixtureLoader * into sqlLite test temporary database From 9a47ef42bab040c7c36113ba91daec1c90147afb Mon Sep 17 00:00:00 2001 From: Romain Neutron Date: Fri, 25 Jan 2013 11:53:09 +0100 Subject: [PATCH 7/7] Add blank lines --- .../Phrasea/Core/Configuration/ApplicationSpecification.php | 3 +++ lib/classes/patch/3803.php | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/lib/Alchemy/Phrasea/Core/Configuration/ApplicationSpecification.php b/lib/Alchemy/Phrasea/Core/Configuration/ApplicationSpecification.php index f5f594d743..44d0cc9468 100644 --- a/lib/Alchemy/Phrasea/Core/Configuration/ApplicationSpecification.php +++ b/lib/Alchemy/Phrasea/Core/Configuration/ApplicationSpecification.php @@ -46,12 +46,15 @@ class ApplicationSpecification implements SpecificationInterface $newServices = $services; } else { $newServices = $services; + $legacyServices = $this->parser->parse( file_get_contents($this->getRealRootPath() . "/conf.d/services.yml") ); + if (!isset($legacyServices[$name])) { throw new InvalidArgumentException(sprintf('%s is not a valid service name')); } + $newServices[$name] = $legacyServices[$name]; } diff --git a/lib/classes/patch/3803.php b/lib/classes/patch/3803.php index 5896394c93..2bbefbff57 100644 --- a/lib/classes/patch/3803.php +++ b/lib/classes/patch/3803.php @@ -64,9 +64,11 @@ class patch_3803 implements patchInterface $confs = $app['phraseanet.configuration']->getConfigurations(); foreach ($confs as $env => $conf) { + if (in_array($env, array('environment', 'key'))) { continue; } + if (!isset($conf['search-engine'])) { $confs[$env]['search-engine'] = $searchEngine; } @@ -81,6 +83,7 @@ class patch_3803 implements patchInterface } if (!$app['phraseanet.registry']->get('GV_sphinx')) { + $phraseaConfiguration = $app['phraseanet.SE']->getConfigurationPanel()->getConfiguration(); if ($app['phraseanet.registry']->get('GV_phrasea_sort')) { @@ -88,7 +91,9 @@ class patch_3803 implements patchInterface } $app['phraseanet.SE']->getConfigurationPanel()->saveConfiguration($phraseaConfiguration); + } else { + $sphinxConfiguration = $app['phraseanet.SE']->getConfigurationPanel()->getConfiguration(); if ($app['phraseanet.registry']->get('GV_sphinx_rt_port')) {