mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-14 05:23:21 +00:00
Fix unit tests, bump to version 3.8.0 alpha 3
This commit is contained in:
@@ -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,26 @@ class ApplicationSpecification implements SpecificationInterface
|
||||
);
|
||||
}
|
||||
|
||||
public function resetServices($name = null)
|
||||
{
|
||||
$services = $this->getServices();
|
||||
|
||||
if (!$name) {
|
||||
$newServices = $services;
|
||||
} else {
|
||||
$newServices = $services;
|
||||
$legacyServices = $this->parser->parse(
|
||||
file_get_contents($this->getRealRootPath() . "/conf.d/services.yml")
|
||||
);
|
||||
if (!isset($legacyServices[$name])) {
|
||||
throw new InvalidArgumentException(sprintf('%s is not a valid service name'));
|
||||
}
|
||||
$newServices[$name] = $legacyServices[$name];
|
||||
}
|
||||
|
||||
return $this->setServices($newServices);
|
||||
}
|
||||
|
||||
public function setServices($services)
|
||||
{
|
||||
return file_put_contents(
|
||||
@@ -108,17 +123,17 @@ class ApplicationSpecification implements SpecificationInterface
|
||||
$this->delete();
|
||||
|
||||
copy(
|
||||
$this->getRealRootPath() . "/config/connexions.sample.yml"
|
||||
$this->getRealRootPath() . "/conf.d/connexions.yml"
|
||||
, $this->getConnexionsPathFile()
|
||||
);
|
||||
|
||||
copy(
|
||||
$this->getRealRootPath() . "/config/services.sample.yml"
|
||||
$this->getRealRootPath() . "/conf.d/services.yml"
|
||||
, $this->getServicesPathFile()
|
||||
);
|
||||
|
||||
copy(
|
||||
$this->getRealRootPath() . "/config/config.sample.yml"
|
||||
$this->getRealRootPath() . "/conf.d/config.yml"
|
||||
, $this->getConfigurationsPathFile()
|
||||
);
|
||||
|
||||
|
@@ -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();
|
||||
|
@@ -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,50 +59,53 @@ class patch_3803 implements patchInterface
|
||||
*/
|
||||
public function apply(base $appbox, Application $app)
|
||||
{
|
||||
$searchEngine = $app['phraseanet.registry']->get('GV_sphinx') ? 'sphinx-search' : 'phrasea';
|
||||
$searchEngine = $app['phraseanet.registry']->get('GV_sphinx') ? 'sphinxsearch' : 'phrasea';
|
||||
|
||||
$app['phraseanet.registry']->set('GV_search_engine', $searchEngine, \registry::TYPE_ENUM);
|
||||
$confs = $app['phraseanet.configuration']->getConfigurations();
|
||||
|
||||
$phraseaConfiguration = null;
|
||||
$phraseaConfigFile = __DIR__ . '/../../../config/phrasea-engine.json';
|
||||
|
||||
if (file_exists($phraseaConfigFile)) {
|
||||
$phraseaConfiguration = json_decode(file_get_contents($phraseaConfigFile), true);
|
||||
}
|
||||
if (!is_array($phraseaConfiguration)) {
|
||||
$phraseaConfiguration = array();
|
||||
foreach ($confs as $env => $conf) {
|
||||
if (in_array($env, array('environment', 'key'))) {
|
||||
continue;
|
||||
}
|
||||
if (!isset($conf['search-engine'])) {
|
||||
$confs[$env]['search-engine'] = $searchEngine;
|
||||
}
|
||||
}
|
||||
|
||||
if ($app['phraseanet.registry']->get('GV_phrasea_sort')) {
|
||||
$phraseaConfiguration['default_sort'] = $app['phraseanet.registry']->get('GV_phrasea_sort');
|
||||
}
|
||||
|
||||
file_put_contents($phraseaConfigFile, $phraseaConfiguration);
|
||||
|
||||
$sphinxConfiguration = null;
|
||||
$sphinxConfigFile = __DIR__ . '/../../../config/sphinx-search.json';
|
||||
$app['phraseanet.configuration']->setConfigurations($confs);
|
||||
|
||||
if (file_exists($sphinxConfigFile)) {
|
||||
$sphinxConfiguration = json_decode(file_get_contents($sphinxConfigFile), true);
|
||||
}
|
||||
if (!is_array($sphinxConfiguration)) {
|
||||
$sphinxConfiguration = array();
|
||||
$services = $app['phraseanet.configuration']->getServices();
|
||||
|
||||
if (!isset($services['SearchEngine'])) {
|
||||
$app['phraseanet.configuration']->resetServices('SearchEngine');
|
||||
}
|
||||
|
||||
if ($app['phraseanet.registry']->get('GV_sphinx_rt_port')) {
|
||||
$sphinxConfiguration['rt_port'] = $app['phraseanet.registry']->get('GV_sphinx_rt_port');
|
||||
if (!$app['phraseanet.registry']->get('GV_sphinx')) {
|
||||
$phraseaConfiguration = $app['phraseanet.SE']->getConfigurationPanel()->getConfiguration();
|
||||
|
||||
if ($app['phraseanet.registry']->get('GV_phrasea_sort')) {
|
||||
$phraseaConfiguration['default_sort'] = $app['phraseanet.registry']->get('GV_phrasea_sort');
|
||||
}
|
||||
|
||||
$app['phraseanet.SE']->getConfigurationPanel()->saveConfiguration($phraseaConfiguration);
|
||||
} else {
|
||||
$sphinxConfiguration = $app['phraseanet.SE']->getConfigurationPanel()->getConfiguration();
|
||||
|
||||
if ($app['phraseanet.registry']->get('GV_sphinx_rt_port')) {
|
||||
$sphinxConfiguration['rt_port'] = $app['phraseanet.registry']->get('GV_sphinx_rt_port');
|
||||
}
|
||||
if ($app['phraseanet.registry']->get('GV_sphinx_rt_host')) {
|
||||
$sphinxConfiguration['rt_host'] = $app['phraseanet.registry']->get('GV_sphinx_rt_host');
|
||||
}
|
||||
if ($app['phraseanet.registry']->get('GV_sphinx_port')) {
|
||||
$sphinxConfiguration['port'] = $app['phraseanet.registry']->get('GV_sphinx_port');
|
||||
}
|
||||
if ($app['phraseanet.registry']->get('GV_sphinx_host')) {
|
||||
$sphinxConfiguration['host'] = $app['phraseanet.registry']->get('GV_sphinx_host');
|
||||
}
|
||||
|
||||
$app['phraseanet.SE']->getConfigurationPanel()->saveConfiguration($sphinxConfiguration);
|
||||
}
|
||||
if ($app['phraseanet.registry']->get('GV_sphinx_rt_host')) {
|
||||
$sphinxConfiguration['rt_host'] = $app['phraseanet.registry']->get('GV_sphinx_rt_host');
|
||||
}
|
||||
if ($app['phraseanet.registry']->get('GV_sphinx_port')) {
|
||||
$sphinxConfiguration['port'] = $app['phraseanet.registry']->get('GV_sphinx_port');
|
||||
}
|
||||
if ($app['phraseanet.registry']->get('GV_sphinx_host')) {
|
||||
$sphinxConfiguration['host'] = $app['phraseanet.registry']->get('GV_sphinx_host');
|
||||
}
|
||||
|
||||
file_put_contents($sphinxConfigFile, $sphinxConfiguration);
|
||||
|
||||
return;
|
||||
}
|
||||
|
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;
|
||||
}
|
||||
}
|
||||
|
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));
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
@@ -10,6 +10,11 @@ class BorderManagerServiceProvidertest extends \PhraseanetPHPUnitAbstract
|
||||
{
|
||||
self::$DI['app']->register(new BorderManagerServiceProvider());
|
||||
|
||||
$this->assertInstanceof('Alchemy\\Phrasea\\Border\\Manager', self::$DI['app']['border-manager']);
|
||||
$borderManager1 = self::$DI['app']['border-manager'];
|
||||
$borderManager2 = self::$DI['app']['border-manager'];
|
||||
|
||||
$this->assertInstanceof('Alchemy\\Phrasea\\Border\\Manager', $borderManager1);
|
||||
|
||||
$this->assertEquals($borderManager1, $borderManager2);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,20 @@
|
||||
<?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());
|
||||
|
||||
$ftpclient1 = self::$DI['app']['phraseanet.ftp.client'];
|
||||
$ftpclient2 = self::$DI['app']['phraseanet.ftp.client'];
|
||||
$this->assertInstanceof('ftpclient', $ftpclient1);
|
||||
$this->assertInstanceof('ftpclient', $ftpclient2);
|
||||
|
||||
$this->assertNotEquals($ftpclient1, $ftpclient2);
|
||||
}
|
||||
}
|
@@ -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()
|
||||
|
Reference in New Issue
Block a user