mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-13 21:13:26 +00:00
Merge pull request #290 from romainneutron/fix-tests
[3.8] Fix unit tests, bump to version 3.8.0 alpha 3
This commit is contained in:
391
composer.lock
generated
391
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -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
|
||||
|
@@ -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
|
||||
*
|
||||
|
@@ -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,29 @@ 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 +126,17 @@ class ApplicationSpecification implements SpecificationInterface
|
||||
$this->delete();
|
||||
|
||||
copy(
|
||||
$this->getRealRootPath() . "/config/connexions.sample.yml"
|
||||
$this->getRealRootPath() . "/lib/conf.d/connexions.yml"
|
||||
, $this->getConnexionsPathFile()
|
||||
);
|
||||
|
||||
copy(
|
||||
$this->getRealRootPath() . "/config/services.sample.yml"
|
||||
$this->getRealRootPath() . "/lib/conf.d/services.yml"
|
||||
, $this->getServicesPathFile()
|
||||
);
|
||||
|
||||
copy(
|
||||
$this->getRealRootPath() . "/config/config.sample.yml"
|
||||
$this->getRealRootPath() . "/lib/conf.d/config.yml"
|
||||
, $this->getConfigurationsPathFile()
|
||||
);
|
||||
|
||||
|
@@ -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();
|
||||
|
@@ -31,7 +31,7 @@ class Builder
|
||||
}
|
||||
|
||||
try {
|
||||
$options = $configuration->get("options");
|
||||
$options = $configuration->get("options") ?: array() ;
|
||||
} catch (\Exception $e) {
|
||||
$options = array();
|
||||
}
|
||||
|
@@ -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.");
|
||||
}
|
||||
|
@@ -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()
|
||||
|
@@ -59,52 +59,60 @@ 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';
|
||||
foreach ($confs as $env => $conf) {
|
||||
|
||||
if (file_exists($phraseaConfigFile)) {
|
||||
$phraseaConfiguration = json_decode(file_get_contents($phraseaConfigFile), true);
|
||||
}
|
||||
if (!is_array($phraseaConfiguration)) {
|
||||
$phraseaConfiguration = array();
|
||||
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_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);
|
||||
if (!$app['phraseanet.registry']->get('GV_sphinx')) {
|
||||
|
||||
return;
|
||||
$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);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
84
lib/classes/patch/3804.php
Normal file
84
lib/classes/patch/3804.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2013 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use Alchemy\Phrasea\Application;
|
||||
|
||||
class patch_3804 implements patchInterface
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
private $release = '3.8.0.a3';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var Array
|
||||
*/
|
||||
private $concern = array(base::APPLICATION_BOX);
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_release()
|
||||
{
|
||||
return $this->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;
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
72
lib/conf.d/config.yml
Normal file
72
lib/conf.d/config.yml
Normal file
@@ -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
|
||||
|
19
lib/conf.d/connexions.yml
Normal file
19
lib/conf.d/connexions.yml
Normal file
@@ -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: <HOSTNAME>
|
||||
port: <PORT>
|
||||
user: <USERNAME>
|
||||
password: <PASSWORD>
|
||||
dbname: <DATABASE_NAME>
|
||||
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
|
215
lib/conf.d/services.yml
Normal file
215
lib/conf.d/services.yml
Normal file
@@ -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
|
@@ -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));
|
||||
}
|
||||
|
||||
|
@@ -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()
|
||||
|
@@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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
|
||||
|
@@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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()
|
||||
|
@@ -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/');
|
||||
|
@@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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()
|
||||
|
@@ -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()
|
||||
|
@@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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()
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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));
|
||||
|
@@ -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/");
|
||||
|
@@ -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()
|
||||
|
@@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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()
|
||||
|
@@ -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)
|
||||
|
@@ -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());
|
||||
}
|
||||
}
|
||||
|
@@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,387 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Alchemy\Tests\Phrasea\Core\Configuration;
|
||||
|
||||
class ConfigurationTest extends \PhraseanetPHPUnitAbstract
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var \Alchemy\Phrasea\Core\Configuration
|
||||
*/
|
||||
protected $confProd;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var \Alchemy\Phrasea\Core\Configuration
|
||||
*/
|
||||
protected $confDev;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var \Alchemy\Phrasea\Core\Configuration
|
||||
*/
|
||||
protected $confTest;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var \Alchemy\Phrasea\Core\Configuration
|
||||
*/
|
||||
protected $confNotInstalled;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var \Alchemy\Phrasea\Core\Configuration
|
||||
*/
|
||||
protected $confExperience;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var \Alchemy\Phrasea\Core\Configuration
|
||||
*/
|
||||
protected $object;
|
||||
protected $stubNotInstalled;
|
||||
protected $stubExperience;
|
||||
protected $stubConfTest;
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
$this->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");
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
@@ -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": {}
|
||||
}
|
702
tests/Alchemy/Tests/Phrasea/Core/ConfigurationTest.php
Normal file
702
tests/Alchemy/Tests/Phrasea/Core/ConfigurationTest.php
Normal file
@@ -0,0 +1,702 @@
|
||||
<?php
|
||||
|
||||
namespace Alchemy\Tests\Phrasea\Core;
|
||||
|
||||
use Alchemy\Phrasea\Core\Configuration;
|
||||
use Alchemy\Phrasea\Exception\InvalidArgumentException;
|
||||
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
|
||||
|
||||
class ConfigurationTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @covers Alchemy\Phrasea\Core\Configuration::build
|
||||
*/
|
||||
public function testBuild()
|
||||
{
|
||||
$specifications = $this->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;
|
||||
}
|
||||
}
|
@@ -2,14 +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());
|
||||
|
||||
$this->assertInstanceof('Alchemy\\Phrasea\\Border\\Manager', self::$DI['app']['border-manager']);
|
||||
return array(
|
||||
array('Alchemy\Phrasea\Core\Provider\BorderManagerServiceProvider', 'border-manager', 'Alchemy\\Phrasea\\Border\\Manager'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -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'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -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'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -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'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -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'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace Alchemy\Tests\Phrasea\Core\Provider;
|
||||
|
||||
use Alchemy\Phrasea\Core\Provider\FtpServiceProvider;
|
||||
|
||||
class FTPServiceProvidertest extends \PhraseanetPHPUnitAbstract
|
||||
{
|
||||
public function testGetInstantiate()
|
||||
{
|
||||
self::$DI['app']->register(new FtpServiceProvider());
|
||||
|
||||
$this->assertInstanceOf('Closure', self::$DI['app']['phraseanet.ftp.client']);
|
||||
}
|
||||
}
|
@@ -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'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -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'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -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'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace Alchemy\Tests\Phrasea\Core\Provider;
|
||||
|
||||
abstract class ServiceProviderTestCase extends \PhraseanetPHPUnitAbstract
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
* @dataProvider provideServiceDescription
|
||||
*/
|
||||
public function theSameInstanceShouldBereturnedEveryTime($service, $key, $classname)
|
||||
{
|
||||
self::$DI['app']->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();
|
||||
}
|
@@ -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'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -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'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -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()
|
||||
|
@@ -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
|
||||
|
161
tests/classes/patch/3803Test.php
Normal file
161
tests/classes/patch/3803Test.php
Normal file
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
class patch_3803Test extends PhraseanetPHPUnitAbstract
|
||||
{
|
||||
/**
|
||||
* @covers patch_3803::apply
|
||||
*/
|
||||
public function testApplyInSphinxEnvironment()
|
||||
{
|
||||
$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 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']);
|
||||
}
|
||||
}
|
60
tests/classes/patch/3804Test.php
Normal file
60
tests/classes/patch/3804Test.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
class patch_3804Test extends PhraseanetPHPUnitAbstract
|
||||
{
|
||||
/**
|
||||
* @covers patch_3804::apply
|
||||
*/
|
||||
public function testApply()
|
||||
{
|
||||
$app = self::$DI['app'];
|
||||
|
||||
$patch = new patch_3804();
|
||||
|
||||
$appbox = $this->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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user