refactor service interface

This commit is contained in:
Nicolas Le Goff
2012-03-15 16:43:23 +01:00
parent 7aac757a3c
commit 5557d8b8b7
34 changed files with 187 additions and 357 deletions

View File

@@ -71,7 +71,7 @@ class Manager
try try
{ {
$configuration = $this->core->getConfiguration()->getService($service_name); $configuration = $this->core->getConfiguration()->getService($service_name);
$service = Builder::create($this->core, $service_name, $configuration); $service = Builder::create($this->core, $configuration);
$driver = $service->getDriver(); $driver = $service->getDriver();
$write = true; $write = true;
} }
@@ -80,7 +80,7 @@ class Manager
$configuration = new \Symfony\Component\DependencyInjection\ParameterBag\ParameterBag( $configuration = new \Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
array('type' => 'Cache\\ArrayCache') array('type' => 'Cache\\ArrayCache')
); );
$service = Builder::create($this->core, $service_name, $configuration); $service = Builder::create($this->core, $configuration);
$driver = $service->getDriver(); $driver = $service->getDriver();
$write = false; $write = false;
} }

View File

@@ -217,7 +217,6 @@ class Installer implements ControllerProviderInterface
$ormService = \Alchemy\Phrasea\Core\Service\Builder::create( $ormService = \Alchemy\Phrasea\Core\Service\Builder::create(
$app['Core'] $app['Core']
, $serviceName
, $confService , $confService
); );

View File

@@ -94,7 +94,6 @@ class Core extends \Pimple
$this['CacheService'] = $this->share(function() use ($core) $this['CacheService'] = $this->share(function() use ($core)
{ {
if (!file_exists(__DIR__ . '/../../../tmp/cache_registry.yml')) if (!file_exists(__DIR__ . '/../../../tmp/cache_registry.yml'))
{ {
touch(__DIR__ . '/../../../tmp/cache_registry.yml'); touch(__DIR__ . '/../../../tmp/cache_registry.yml');
@@ -112,7 +111,7 @@ class Core extends \Pimple
$serviceName = $core->getConfiguration()->getOrm(); $serviceName = $core->getConfiguration()->getOrm();
$configuration = $core->getConfiguration()->getService($serviceName); $configuration = $core->getConfiguration()->getService($serviceName);
$Service = Core\Service\Builder::create($core, $serviceName, $configuration); $Service = Core\Service\Builder::create($core, $configuration);
return $Service->getDriver(); return $Service->getDriver();
}); });
@@ -139,7 +138,7 @@ class Core extends \Pimple
$serviceName = $core->getConfiguration()->getTemplating(); $serviceName = $core->getConfiguration()->getTemplating();
$configuration = $core->getConfiguration()->getService($serviceName); $configuration = $core->getConfiguration()->getService($serviceName);
$Service = Core\Service\Builder::create($core, $serviceName, $configuration); $Service = Core\Service\Builder::create($core, $configuration);
return $Service->getDriver(); return $Service->getDriver();
}); });

View File

@@ -23,7 +23,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag,
class Builder class Builder
{ {
public static function create(Core $core, $name, ParameterBag $configuration) public static function create(Core $core, ParameterBag $configuration)
{ {
$classname = __NAMESPACE__ . '\\' . $configuration->get("type"); $classname = __NAMESPACE__ . '\\' . $configuration->get("type");
@@ -41,19 +41,7 @@ class Builder
$options = array(); $options = array();
} }
$mandatory = $classname::getMandatoryOptions(); return new $classname($core, $options);
if ($mandatory !== array_intersect($mandatory, array_keys($options)))
{
throw new Exception\MissingParameters(
sprintf(
'Missing parameters %s'
, implode(', ', array_diff($mandatory, array_keys($options)))
)
);
}
return new $classname($core, $name, $options);
} }
} }

View File

@@ -28,11 +28,6 @@ class ApcCache extends ServiceAbstract implements ServiceInterface
protected $cache; protected $cache;
public function getScope()
{
return 'cache';
}
public function getDriver() public function getDriver()
{ {
if (!extension_loaded('apc')) if (!extension_loaded('apc'))
@@ -55,10 +50,6 @@ class ApcCache extends ServiceAbstract implements ServiceInterface
return 'apc'; return 'apc';
} }
public static function getMandatoryOptions()
{
return array();
}
} }

View File

@@ -29,11 +29,6 @@ class ArrayCache extends ServiceAbstract implements ServiceInterface
protected $cache; protected $cache;
public function getScope()
{
return 'cache';
}
public function getDriver() public function getDriver()
{ {
if (!$this->cache) if (!$this->cache)
@@ -51,10 +46,5 @@ class ArrayCache extends ServiceAbstract implements ServiceInterface
return 'array'; return 'array';
} }
public static function getMandatoryOptions()
{
return array();
}
} }

View File

@@ -26,28 +26,22 @@ use Alchemy\Phrasea\Core,
class MemcacheCache extends ServiceAbstract implements ServiceInterface class MemcacheCache extends ServiceAbstract implements ServiceInterface
{ {
protected $cache;
const DEFAULT_HOST = "localhost"; const DEFAULT_HOST = "localhost";
const DEFAULT_PORT = "11211"; const DEFAULT_PORT = "11211";
protected $cache;
protected $host; protected $host;
protected $port; protected $port;
public function __construct(Core $core, $name, Array $options) protected function init()
{ {
parent::__construct( $core, $name, $options); $options = $this->getOptions();
$this->host = isset($options["host"]) ? $options["host"] : self::DEFAULT_HOST; $this->host = isset($options["host"]) ? $options["host"] : self::DEFAULT_HOST;
$this->port = isset($options["port"]) ? $options["port"] : self::DEFAULT_PORT; $this->port = isset($options["port"]) ? $options["port"] : self::DEFAULT_PORT;
} }
public function getScope()
{
return 'cache';
}
public function getDriver() public function getDriver()
{ {
if (!extension_loaded('memcache')) if (!extension_loaded('memcache'))
@@ -55,7 +49,7 @@ class MemcacheCache extends ServiceAbstract implements ServiceInterface
throw new \Exception('The Memcache cache requires the Memcache extension.'); throw new \Exception('The Memcache cache requires the Memcache extension.');
} }
if(!$this->cache) if (!$this->cache)
{ {
$memcache = new \Memcache(); $memcache = new \Memcache();
@@ -70,7 +64,7 @@ class MemcacheCache extends ServiceAbstract implements ServiceInterface
$this->cache = new CacheDriver\MemcacheCache(); $this->cache = new CacheDriver\MemcacheCache();
$this->cache->setMemcache($memcache); $this->cache->setMemcache($memcache);
$this->cache->setNamespace(md5(realpath(__DIR__.'/../../../../../../'))); $this->cache->setNamespace(md5(realpath(__DIR__ . '/../../../../../../')));
} }
else else
{ {
@@ -96,10 +90,5 @@ class MemcacheCache extends ServiceAbstract implements ServiceInterface
return $this->port; return $this->port;
} }
public static function getMandatoryOptions()
{
return array('host', 'port');
}
} }

View File

@@ -26,28 +26,22 @@ use Alchemy\Phrasea\Core,
class RedisCache extends ServiceAbstract implements ServiceInterface class RedisCache extends ServiceAbstract implements ServiceInterface
{ {
protected $cache;
const DEFAULT_HOST = "localhost"; const DEFAULT_HOST = "localhost";
const DEFAULT_PORT = "6379"; const DEFAULT_PORT = "6379";
protected $cache;
protected $host; protected $host;
protected $port; protected $port;
public function __construct(Core $core, $name, Array $options) protected function init()
{ {
parent::__construct($core, $name, $options); $options = $this->getOptions();
$this->host = isset($options["host"]) ? $options["host"] : self::DEFAULT_HOST; $this->host = isset($options["host"]) ? $options["host"] : self::DEFAULT_HOST;
$this->port = isset($options["port"]) ? $options["port"] : self::DEFAULT_PORT; $this->port = isset($options["port"]) ? $options["port"] : self::DEFAULT_PORT;
} }
public function getScope()
{
return 'cache';
}
/** /**
* *
* @return Cache\ApcCache * @return Cache\ApcCache
@@ -100,10 +94,5 @@ class RedisCache extends ServiceAbstract implements ServiceInterface
return $this->port; return $this->port;
} }
public static function getMandatoryOptions()
{
return array('host', 'port');
}
} }

View File

@@ -28,11 +28,6 @@ class XcacheCache extends ServiceAbstract implements ServiceInterface
protected $cache; protected $cache;
public function getScope()
{
return 'cache';
}
public function getDriver() public function getDriver()
{ {
if (!extension_loaded('xcache')) if (!extension_loaded('xcache'))
@@ -55,9 +50,4 @@ class XcacheCache extends ServiceAbstract implements ServiceInterface
return 'xcache'; return 'xcache';
} }
public static function getMandatoryOptions()
{
return array();
}
} }

View File

@@ -15,9 +15,9 @@ use Alchemy\Phrasea\Core,
Alchemy\Phrasea\Core\Service, Alchemy\Phrasea\Core\Service,
Alchemy\Phrasea\Core\Service\ServiceAbstract, Alchemy\Phrasea\Core\Service\ServiceAbstract,
Alchemy\Phrasea\Core\Service\ServiceInterface; Alchemy\Phrasea\Core\Service\ServiceInterface;
use Alchemy\Phrasea\Core\Service\Log\Monolog as ParentLog; use Alchemy\Phrasea\Core\Service\Log\Monolog as ParentLog;
use Doctrine\Logger\MonologSQLLogger; use Doctrine\Logger\MonologSQLLogger;
/** /**
* *
* @package * @package
@@ -26,27 +26,27 @@ use Doctrine\Logger\MonologSQLLogger;
*/ */
class Monolog extends ParentLog implements ServiceInterface class Monolog extends ParentLog implements ServiceInterface
{ {
const JSON_OUTPUT = 'json'; const JSON_OUTPUT = 'json';
const YAML_OUTPUT = 'yaml'; const YAML_OUTPUT = 'yaml';
const VAR_DUMP_OUTPUT = 'vdump'; const VAR_DUMP_OUTPUT = 'vdump';
protected $outputs = array(
self::JSON_OUTPUT, self::YAML_OUTPUT, self::VAR_DUMP_OUTPUT
);
public function getDriver() public function getDriver()
{ {
$output = isset($this->options["output"]) ? $this->options["output"] : self::JSON_OUTPUT; $output = isset($this->options["output"]) ? $this->options["output"] : self::JSON_OUTPUT;
if (!in_array($output, $this->outputs)) $outputs = array(
self::JSON_OUTPUT, self::YAML_OUTPUT, self::VAR_DUMP_OUTPUT
);
if (!in_array($output, $outputs))
{ {
throw new \Exception(sprintf( throw new \Exception(sprintf(
"The output type '%s' declared in %s %s service is not valid. "The output type '%s' declared in %s service is not valid.
Available types are %s." Available types are %s."
, $output , $output
, $this->name , __CLASS__
, $this->getScope() , implode(", ", $outputs)
, implode(", ", $this->outputs)
) )
); );
} }
@@ -59,9 +59,5 @@ class Monolog extends ParentLog implements ServiceInterface
return 'doctrine_monolog'; return 'doctrine_monolog';
} }
public static function getMandatoryOptions()
{
return array('output', 'channel', 'handler', 'max_day', 'filename');
}
} }

View File

@@ -26,7 +26,6 @@ use Doctrine\DBAL\Logging\EchoSQLLogger;
class Phpecho extends ServiceAbstract implements ServiceInterface class Phpecho extends ServiceAbstract implements ServiceInterface
{ {
public function getDriver() public function getDriver()
{ {
return new EchoSQLLogger(); return new EchoSQLLogger();
@@ -37,14 +36,4 @@ class Phpecho extends ServiceAbstract implements ServiceInterface
return 'phpecho'; return 'phpecho';
} }
public function getScope()
{
return 'log';
}
public static function getMandatoryOptions()
{
return array();
}
} }

View File

@@ -29,19 +29,15 @@ class FirePHP extends ServiceAbstract implements ServiceInterface
protected $logger; protected $logger;
public function __construct(\Alchemy\Phrasea\Core $core, $name, Array $options)
{
parent::__construct($core, $name, $options);
$this->logger = new Logger('FirePHP');
$this->logger->pushHandler(new FirePHPHandler());
return $this;
}
public function getDriver() public function getDriver()
{ {
if (!$this->logger)
{
$this->logger = new Logger('FirePHP');
$this->logger->pushHandler(new FirePHPHandler());
}
return $this->logger; return $this->logger;
} }
@@ -50,14 +46,4 @@ class FirePHP extends ServiceAbstract implements ServiceInterface
return 'FirePHP Monolog'; return 'FirePHP Monolog';
} }
public function getScope()
{
return 'log';
}
public static function getMandatoryOptions()
{
return array();
}
} }

View File

@@ -37,9 +37,9 @@ class Monolog extends ServiceAbstract implements ServiceInterface
*/ */
protected $monolog; protected $monolog;
public function __construct(Core $core, $name, Array $options) protected function init()
{ {
parent::__construct( $core, $name, $options); $options = $this->getOptions();
if (empty($options)) if (empty($options))
{ {
@@ -52,8 +52,8 @@ class Monolog extends ServiceAbstract implements ServiceInterface
if (!$handler) if (!$handler)
{ {
throw new \Exception(sprintf( throw new \Exception(sprintf(
"You must specify at least one handler for %s service" "You must specify at least one handler for '%s' service"
, $this->name , __CLASS__
) )
); );
} }
@@ -64,8 +64,7 @@ class Monolog extends ServiceAbstract implements ServiceInterface
"The handler type '%s' declared in %s %s service is not valid. "The handler type '%s' declared in %s %s service is not valid.
Available types are %s." Available types are %s."
, $handler , $handler
, $this->name , __CLASS__
, $this->getScope()
, implode(", ", $this->handlers) , implode(", ", $this->handlers)
) )
); );
@@ -88,7 +87,7 @@ class Monolog extends ServiceAbstract implements ServiceInterface
{ {
throw new \Exception(sprintf( throw new \Exception(sprintf(
"Missing filename option in '%s' service" "Missing filename option in '%s' service"
, $this->name , __CLASS__
) )
); );
} }
@@ -129,14 +128,9 @@ class Monolog extends ServiceAbstract implements ServiceInterface
return 'monolog'; return 'monolog';
} }
public function getScope() public function getMandatoryOptions()
{ {
return 'log'; return array('channel', 'handler', 'filename');
}
public static function getMandatoryOptions()
{
return array('output', 'channel', 'handler', 'max_day', 'filename');
} }
} }

View File

@@ -27,18 +27,16 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
class Doctrine extends ServiceAbstract implements ServiceInterface class Doctrine extends ServiceAbstract implements ServiceInterface
{ {
protected $outputs = array(
'json', 'yaml', 'vdump'
);
protected $loggers = array( protected $loggers = array(
'Log\\Doctrine\Monolog', 'Log\\Doctrine\\Phpecho' 'Log\\Doctrine\Monolog'
, 'Log\\Doctrine\\Phpecho'
); );
protected $entityManager; protected $entityManager;
protected $debug; protected $debug;
public function __construct(Core $core, $name, Array $options) protected function init()
{ {
parent::__construct($core, $name, $options); $options = $this->getOptions();
$config = new \Doctrine\ORM\Configuration(); $config = new \Doctrine\ORM\Configuration();
@@ -55,16 +53,16 @@ class Doctrine extends ServiceAbstract implements ServiceInterface
if (!$cache || $this->debug) if (!$cache || $this->debug)
{ {
$metaCache = $this->core['CacheService']->get('ORMmetadata', 'Cache\\ArrayCache'); $metaCache = $this->core['CacheService']->get('ORMmetadata', 'Cache\\ArrayCache');
$queryCache = $this->core['CacheService']->get('ORMquery', 'Cache\\ArrayCache'); $queryCache = $this->core['CacheService']->get('ORMquery', 'Cache\\ArrayCache');
} }
else else
{ {
$query = isset($cache["query"]['service']) ? $cache["query"]['service'] : 'Cache\\ArrayCache'; $query = isset($cache["query"]['service']) ? $cache["query"]['service'] : 'Cache\\ArrayCache';
$meta = isset($cache["metadata"]['service']) ? $cache["metadata"]['service'] : 'Cache\\ArrayCache'; $meta = isset($cache["metadata"]['service']) ? $cache["metadata"]['service'] : 'Cache\\ArrayCache';
$queryCache = $this->core['CacheService']->get('ORMquery', $query); $queryCache = $this->core['CacheService']->get('ORMquery', $query);
$metaCache = $this->core['CacheService']->get('ORMmetadata', $meta); $metaCache = $this->core['CacheService']->get('ORMmetadata', $meta);
} }
$resultCache = $this->core['CacheService']->get('ORMresult', 'Cache\\ArrayCache'); $resultCache = $this->core['CacheService']->get('ORMresult', 'Cache\\ArrayCache');
@@ -81,7 +79,7 @@ class Doctrine extends ServiceAbstract implements ServiceInterface
$chainDriverImpl = new \Doctrine\ORM\Mapping\Driver\DriverChain(); $chainDriverImpl = new \Doctrine\ORM\Mapping\Driver\DriverChain();
$driverYaml = new \Doctrine\ORM\Mapping\Driver\YamlDriver( $driverYaml = new \Doctrine\ORM\Mapping\Driver\YamlDriver(
array(__DIR__ . '/../../../../../conf.d/Doctrine') array(__DIR__ . '/../../../../../conf.d/Doctrine')
); );
$chainDriverImpl->addDriver($driverYaml, 'Entities'); $chainDriverImpl->addDriver($driverYaml, 'Entities');
@@ -99,9 +97,9 @@ class Doctrine extends ServiceAbstract implements ServiceInterface
if (!$connexion) if (!$connexion)
{ {
throw new \Exception(sprintf( throw new \Exception(sprintf(
"Missing dbal configuration for '%s' service" "Missing dbal configuration for '%s' service"
, __CLASS__ , __CLASS__
) )
); );
} }
@@ -125,9 +123,9 @@ class Doctrine extends ServiceAbstract implements ServiceInterface
catch (\Exception $e) catch (\Exception $e)
{ {
throw new \Exception(sprintf( throw new \Exception(sprintf(
"Failed to create doctrine service for the following reason '%s'" "Failed to create doctrine service for the following reason '%s'"
, $e->getMessage() , $e->getMessage()
) )
); );
} }
@@ -184,11 +182,13 @@ class Doctrine extends ServiceAbstract implements ServiceInterface
catch (\Exception $e) catch (\Exception $e)
{ {
$message = sprintf( $message = sprintf(
"%s from %s service in orm:log scope" "%s from %s service"
, $e->getMessage() , $e->getMessage()
, $this->name , __CLASS__
); );
$e = new \Exception($message);
$e = new \Exception($message);
throw $e; throw $e;
} }
@@ -197,17 +197,16 @@ class Doctrine extends ServiceAbstract implements ServiceInterface
if (!in_array($type, $this->loggers)) if (!in_array($type, $this->loggers))
{ {
throw new \Exception(sprintf( throw new \Exception(sprintf(
"The logger type '%s' declared in %s %s service is not valid. "The logger type '%s' declared in %s service is not valid.
Available types are %s." Available types are %s."
, $type , $type
, $this->name , __CLASS__
, $this->getScope() , implode(", ", $this->loggers)
, implode(", ", $this->loggers) )
)
); );
} }
$service = Core\Service\Builder::create($this->core, $serviceName, $configuration); $service = Core\Service\Builder::create($this->core, $configuration);
return $service->getDriver(); return $service->getDriver();
} }
@@ -222,17 +221,12 @@ class Doctrine extends ServiceAbstract implements ServiceInterface
return 'doctrine'; return 'doctrine';
} }
public function getScope()
{
return 'orm';
}
public function isDebug() public function isDebug()
{ {
return $this->debug; return $this->debug;
} }
public static function getMandatoryOptions() public function getMandatoryOptions()
{ {
return array('debug', 'dbal'); return array('debug', 'dbal');
} }

View File

@@ -23,25 +23,37 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
abstract class ServiceAbstract abstract class ServiceAbstract
{ {
protected $name;
protected $core; protected $core;
protected $options; protected $options;
protected $configuration;
public function __construct(Core $core, $name, Array $options) final public function __construct(Core $core, Array $options)
{ {
$this->core = $core; $this->core = $core;
$this->name = $name;
$this->options = $options; $this->options = $options;
$mandatory = $this->getMandatoryOptions();
if ($mandatory !== array_intersect($mandatory, array_keys($options)))
{
throw new Exception\MissingParameters(
sprintf(
'Missing parameters %s'
, implode(', ', array_diff($mandatory, array_keys($options)))
)
);
}
$this->init();
} }
/** protected function init()
*
* @return string
*/
public function getName()
{ {
return $this->name; return;
}
protected function getCore()
{
return $this->core;
} }
/** /**
@@ -53,6 +65,13 @@ abstract class ServiceAbstract
return $this->options; return $this->options;
} }
abstract public static function getMandatoryOptions(); /**
*
* @return Array
*/
public function getMandatoryOptions()
{
return array();
}
} }

View File

@@ -20,14 +20,12 @@ namespace Alchemy\Phrasea\Core\Service;
interface ServiceInterface interface ServiceInterface
{ {
public function getName();
public function getType(); public function getType();
public function getDriver(); public function getDriver();
public function getOptions(); public function getOptions();
public function getScope(); public function getMandatoryOptions();
} }

View File

@@ -26,15 +26,13 @@ class Twig extends ServiceAbstract implements ServiceInterface
protected $twig; protected $twig;
protected $templatesPath = array(); protected $templatesPath = array();
public function __construct(Core $core, $name, Array $options) protected function init()
{ {
parent::__construct( $core, $name, $options);
$this->templatesPath = $this->resolvePaths(); $this->templatesPath = $this->resolvePaths();
try try
{ {
if (!isset($this->options['debug']) || !$this->options['debug']) if (!$this->options['debug'])
{ {
$this->options['cache'] = realpath(__DIR__ . '/../../../../../../tmp/cache_twig/'); $this->options['cache'] = realpath(__DIR__ . '/../../../../../../tmp/cache_twig/');
} }
@@ -50,7 +48,7 @@ class Twig extends ServiceAbstract implements ServiceInterface
{ {
throw new \Exception(sprintf( throw new \Exception(sprintf(
"Unable to create '%s' service for the following reason %s" "Unable to create '%s' service for the following reason %s"
, $this->name , __CLASS__
, $e->getMessage() , $e->getMessage()
) )
); );
@@ -207,12 +205,7 @@ class Twig extends ServiceAbstract implements ServiceInterface
return 'twig'; return 'twig';
} }
public function getScope() public function getMandatoryOptions()
{
return 'template_engine';
}
public static function getMandatoryOptions()
{ {
return array('debug', 'charset', 'strict_variables', 'autoescape', 'optimizer'); return array('debug', 'charset', 'strict_variables', 'autoescape', 'optimizer');
} }

View File

@@ -466,7 +466,7 @@ class module_console_fileEnsureDevSetting extends Command
try try
{ {
Core\Service\Builder::create(\bootstrap::getCore(), $templateEngineName, $configuration); Core\Service\Builder::create(\bootstrap::getCore(), $configuration);
$work_message = '<info>Works !</info>'; $work_message = '<info>Works !</info>';
} }
catch (\Exception $e) catch (\Exception $e)
@@ -592,7 +592,7 @@ class module_console_fileEnsureDevSetting extends Command
try try
{ {
$service = Core\Service\Builder::create(\bootstrap::getCore(), $ormName, $configuration); $service = Core\Service\Builder::create(\bootstrap::getCore(), $configuration);
$work_message = '<info>Works !</info>'; $work_message = '<info>Works !</info>';
} }
catch (\Exception $e) catch (\Exception $e)
@@ -774,7 +774,7 @@ class module_console_fileEnsureDevSetting extends Command
$conf = $this->configuration->getService($ServiceName); $conf = $this->configuration->getService($ServiceName);
$Service = Core\Service\Builder::create( $Service = Core\Service\Builder::create(
\bootstrap::getCore(), $ServiceName, $conf \bootstrap::getCore(), $conf
); );
} }
catch (\Exception $e) catch (\Exception $e)
@@ -845,7 +845,7 @@ class module_console_fileEnsureDevSetting extends Command
$originalConfiguration = $this->configuration->getService($ServiceName); $originalConfiguration = $this->configuration->getService($ServiceName);
$Service = Core\Service\Builder::create( $Service = Core\Service\Builder::create(
\bootstrap::getCore(), $ServiceName, $originalConfiguration \bootstrap::getCore(), $originalConfiguration
); );
} }
catch (\Exception $e) catch (\Exception $e)
@@ -879,7 +879,7 @@ class module_console_fileEnsureDevSetting extends Command
$originalConfiguration = $this->configuration->getService($ServiceName); $originalConfiguration = $this->configuration->getService($ServiceName);
$Service = Core\Service\Builder::create( $Service = Core\Service\Builder::create(
\bootstrap::getCore(), $ServiceName, $originalConfiguration \bootstrap::getCore(), $originalConfiguration
); );
} }
catch (\Exception $e) catch (\Exception $e)

View File

@@ -460,7 +460,7 @@ class module_console_fileEnsureProductionSetting extends Command
try try
{ {
Core\Service\Builder::create(\bootstrap::getCore(), $templateEngineName, $configuration); Core\Service\Builder::create(\bootstrap::getCore(), $configuration);
$work_message = '<info>Works !</info>'; $work_message = '<info>Works !</info>';
} }
catch (\Exception $e) catch (\Exception $e)
@@ -586,7 +586,7 @@ class module_console_fileEnsureProductionSetting extends Command
try try
{ {
$service = Core\Service\Builder::create(\bootstrap::getCore(), $ormName, $configuration); $service = Core\Service\Builder::create(\bootstrap::getCore(), $configuration);
$work_message = '<info>Works !</info>'; $work_message = '<info>Works !</info>';
} }
catch (\Exception $e) catch (\Exception $e)
@@ -781,7 +781,7 @@ class module_console_fileEnsureProductionSetting extends Command
$conf = $this->configuration->getService($ServiceName); $conf = $this->configuration->getService($ServiceName);
$Service = Core\Service\Builder::create( $Service = Core\Service\Builder::create(
\bootstrap::getCore(), $ServiceName, $conf \bootstrap::getCore(), $conf
); );
} }
catch (\Exception $e) catch (\Exception $e)
@@ -852,7 +852,7 @@ class module_console_fileEnsureProductionSetting extends Command
$originalConfiguration = $this->configuration->getService($ServiceName); $originalConfiguration = $this->configuration->getService($ServiceName);
$Service = Core\Service\Builder::create( $Service = Core\Service\Builder::create(
\bootstrap::getCore(), $ServiceName, $originalConfiguration \bootstrap::getCore(), $originalConfiguration
); );
} }
catch (\Exception $e) catch (\Exception $e)
@@ -886,7 +886,7 @@ class module_console_fileEnsureProductionSetting extends Command
$originalConfiguration = $this->configuration->getService($ServiceName); $originalConfiguration = $this->configuration->getService($ServiceName);
$Service = Core\Service\Builder::create( $Service = Core\Service\Builder::create(
\bootstrap::getCore(), $ServiceName, $originalConfiguration \bootstrap::getCore(), $originalConfiguration
); );
} }
catch (\Exception $e) catch (\Exception $e)

View File

@@ -20,19 +20,10 @@ require_once __DIR__ . '/../../../../../PhraseanetPHPUnitAbstract.class.inc';
class ServiceApcCacheTest extends PhraseanetPHPUnitAbstract class ServiceApcCacheTest extends PhraseanetPHPUnitAbstract
{ {
public function testScope()
{
$cache = new \Alchemy\Phrasea\Core\Service\Cache\ApcCache(
self::$core, 'hello', array()
);
$this->assertEquals("cache", $cache->getScope());
}
public function testService() public function testService()
{ {
$cache = new \Alchemy\Phrasea\Core\Service\Cache\ApcCache( $cache = new \Alchemy\Phrasea\Core\Service\Cache\ApcCache(
self::$core, 'hello', array() self::$core, array()
); );
if (extension_loaded('apc')) if (extension_loaded('apc'))
@@ -57,7 +48,7 @@ class ServiceApcCacheTest extends PhraseanetPHPUnitAbstract
public function testServiceException() public function testServiceException()
{ {
$cache = new \Alchemy\Phrasea\Core\Service\Cache\ApcCache( $cache = new \Alchemy\Phrasea\Core\Service\Cache\ApcCache(
self::$core, 'hello', array() self::$core, array()
); );
try try
@@ -74,7 +65,7 @@ class ServiceApcCacheTest extends PhraseanetPHPUnitAbstract
public function testType() public function testType()
{ {
$cache = new \Alchemy\Phrasea\Core\Service\Cache\ApcCache( $cache = new \Alchemy\Phrasea\Core\Service\Cache\ApcCache(
self::$core, 'hello', array() self::$core, array()
); );
$this->assertEquals("apc", $cache->getType()); $this->assertEquals("apc", $cache->getType());

View File

@@ -20,19 +20,10 @@ require_once __DIR__ . '/../../../../../PhraseanetPHPUnitAbstract.class.inc';
class ServiceArrayCacheTest extends PhraseanetPHPUnitAbstract class ServiceArrayCacheTest extends PhraseanetPHPUnitAbstract
{ {
public function testScope()
{
$cache = new \Alchemy\Phrasea\Core\Service\Cache\ArrayCache(
self::$core, 'hello', array()
);
$this->assertEquals("cache", $cache->getScope());
}
public function testService() public function testService()
{ {
$cache = new \Alchemy\Phrasea\Core\Service\Cache\ArrayCache( $cache = new \Alchemy\Phrasea\Core\Service\Cache\ArrayCache(
self::$core, 'hello', array() self::$core, array()
); );
$service = $cache->getDriver(); $service = $cache->getDriver();
@@ -42,7 +33,7 @@ class ServiceArrayCacheTest extends PhraseanetPHPUnitAbstract
public function testServiceException() public function testServiceException()
{ {
$cache = new \Alchemy\Phrasea\Core\Service\Cache\ArrayCache( $cache = new \Alchemy\Phrasea\Core\Service\Cache\ArrayCache(
self::$core, 'hello', array() self::$core, array()
); );
try try
@@ -59,7 +50,7 @@ class ServiceArrayCacheTest extends PhraseanetPHPUnitAbstract
public function testType() public function testType()
{ {
$cache = new \Alchemy\Phrasea\Core\Service\Cache\ArrayCache( $cache = new \Alchemy\Phrasea\Core\Service\Cache\ArrayCache(
self::$core, 'hello', array() self::$core, array()
); );
$this->assertEquals("array", $cache->getType()); $this->assertEquals("array", $cache->getType());

View File

@@ -20,19 +20,10 @@ require_once __DIR__ . '/../../../../../PhraseanetPHPUnitAbstract.class.inc';
class ServiceMemcacheCacheTest extends PhraseanetPHPUnitAbstract class ServiceMemcacheCacheTest extends PhraseanetPHPUnitAbstract
{ {
public function testScope()
{
$cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache(
self::$core, 'hello', array()
);
$this->assertEquals("cache", $cache->getScope());
}
public function testService() public function testService()
{ {
$cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache( $cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache(
self::$core, 'hello', array() self::$core, array()
); );
if (extension_loaded('memcache')) if (extension_loaded('memcache'))
@@ -57,7 +48,7 @@ class ServiceMemcacheCacheTest extends PhraseanetPHPUnitAbstract
public function testServiceException() public function testServiceException()
{ {
$cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache( $cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache(
self::$core, 'hello', array() self::$core, array()
); );
try try
@@ -74,7 +65,7 @@ class ServiceMemcacheCacheTest extends PhraseanetPHPUnitAbstract
public function testType() public function testType()
{ {
$cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache( $cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache(
self::$core, 'hello', array() self::$core, array()
); );
$this->assertEquals("memcache", $cache->getType()); $this->assertEquals("memcache", $cache->getType());
@@ -83,7 +74,7 @@ class ServiceMemcacheCacheTest extends PhraseanetPHPUnitAbstract
public function testHost() public function testHost()
{ {
$cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache( $cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache(
self::$core, 'hello', array() self::$core, array()
); );
$this->assertEquals(\Alchemy\Phrasea\Core\Service\Cache\MemcacheCache::DEFAULT_HOST, $cache->getHost()); $this->assertEquals(\Alchemy\Phrasea\Core\Service\Cache\MemcacheCache::DEFAULT_HOST, $cache->getHost());
@@ -92,7 +83,7 @@ class ServiceMemcacheCacheTest extends PhraseanetPHPUnitAbstract
public function testPort() public function testPort()
{ {
$cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache( $cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache(
self::$core, 'hello', array() self::$core, array()
); );
$this->assertEquals(\Alchemy\Phrasea\Core\Service\Cache\MemcacheCache::DEFAULT_PORT, $cache->getPort()); $this->assertEquals(\Alchemy\Phrasea\Core\Service\Cache\MemcacheCache::DEFAULT_PORT, $cache->getPort());

View File

@@ -20,19 +20,10 @@ require_once __DIR__ . '/../../../../../PhraseanetPHPUnitAbstract.class.inc';
class ServiceXcacheCacheTest extends PhraseanetPHPUnitAbstract class ServiceXcacheCacheTest extends PhraseanetPHPUnitAbstract
{ {
public function testScope()
{
$cache = new \Alchemy\Phrasea\Core\Service\Cache\XcacheCache(
self::$core, 'hello', array()
);
$this->assertEquals("cache", $cache->getScope());
}
public function testService() public function testService()
{ {
$cache = new \Alchemy\Phrasea\Core\Service\Cache\XcacheCache( $cache = new \Alchemy\Phrasea\Core\Service\Cache\XcacheCache(
self::$core, 'hello', array() self::$core, array()
); );
if (extension_loaded('xcache')) if (extension_loaded('xcache'))
@@ -57,7 +48,7 @@ class ServiceXcacheCacheTest extends PhraseanetPHPUnitAbstract
public function testServiceException() public function testServiceException()
{ {
$cache = new \Alchemy\Phrasea\Core\Service\Cache\XcacheCache( $cache = new \Alchemy\Phrasea\Core\Service\Cache\XcacheCache(
self::$core, 'hello', array() self::$core, array()
); );
try try
@@ -74,7 +65,7 @@ class ServiceXcacheCacheTest extends PhraseanetPHPUnitAbstract
public function testType() public function testType()
{ {
$cache = new \Alchemy\Phrasea\Core\Service\Cache\XcacheCache( $cache = new \Alchemy\Phrasea\Core\Service\Cache\XcacheCache(
self::$core, 'hello', array() self::$core, array()
); );
$this->assertEquals("xcache", $cache->getType()); $this->assertEquals("xcache", $cache->getType());

View File

@@ -20,26 +20,23 @@ require_once __DIR__ . '/../../../../../../PhraseanetPHPUnitAbstract.class.inc';
class DoctrineMonologTest extends PhraseanetPHPUnitAbstract class DoctrineMonologTest extends PhraseanetPHPUnitAbstract
{ {
protected $options = array( protected $options = array(
"handler" => "rotate" "handler" => "rotate"
, "filename" => "test" , "filename" => "test"
); , 'output' => 'json'
, 'channel' => 'test'
);
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->options = array(
"handler" => "rotate"
, "filename" => "test"
, 'output' => 'json'
);
} }
public function testService() public function testService()
{ {
$log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Monolog( $log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Monolog(
self::$core, 'hello', $this->options self::$core, $this->options
); );
$this->assertInstanceOf("\Doctrine\Logger\MonologSQLLogger", $log->getDriver()); $this->assertInstanceOf("\Doctrine\Logger\MonologSQLLogger", $log->getDriver());
@@ -48,7 +45,7 @@ class DoctrineMonologTest extends PhraseanetPHPUnitAbstract
public function testType() public function testType()
{ {
$log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Monolog( $log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Monolog(
self::$core, 'hello', $this->options self::$core, $this->options
); );
$this->assertEquals("doctrine_monolog", $log->getType()); $this->assertEquals("doctrine_monolog", $log->getType());
@@ -60,7 +57,7 @@ class DoctrineMonologTest extends PhraseanetPHPUnitAbstract
{ {
$this->options["output"] = "unknowOutput"; $this->options["output"] = "unknowOutput";
$log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Monolog( $log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Monolog(
self::$core, 'hello', $this->options self::$core, $this->options
); );
$log->getDriver(); $log->getDriver();
$this->fail("should raise an exception"); $this->fail("should raise an exception");

View File

@@ -24,7 +24,7 @@ class DoctrinePhpechoTest extends PhraseanetPHPUnitAbstract
{ {
$log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Phpecho( $log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Phpecho(
self::$core, 'hello', array() self::$core, array()
); );
$this->assertInstanceOf("\Doctrine\DBAL\Logging\EchoSQLLogger", $log->getDriver()); $this->assertInstanceOf("\Doctrine\DBAL\Logging\EchoSQLLogger", $log->getDriver());
@@ -33,18 +33,10 @@ class DoctrinePhpechoTest extends PhraseanetPHPUnitAbstract
public function testType() public function testType()
{ {
$log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Phpecho( $log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Phpecho(
self::$core, 'hello', array() self::$core, array()
); );
$this->assertEquals("phpecho", $log->getType()); $this->assertEquals("phpecho", $log->getType());
} }
public function testScope()
{
$log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Phpecho(
self::$core, 'hello', array()
);
$this->assertEquals("log", $log->getScope());
}
} }

View File

@@ -28,23 +28,15 @@ class MonologTest extends PhraseanetPHPUnitAbstract
$this->options = array( $this->options = array(
"handler" => "rotate" "handler" => "rotate"
, "filename" => "test" , "filename" => "test"
, "channel" => "test"
); );
} }
public function testScope()
{
$log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
self::$core, 'hello', $this->options
);
$this->assertEquals("log", $log->getScope());
}
public function testService() public function testService()
{ {
$log = new \Alchemy\Phrasea\Core\Service\Log\Monolog( $log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
self::$core, 'hello', $this->options self::$core, $this->options
); );
$this->assertInstanceOf("\Monolog\Logger", $log->getDriver()); $this->assertInstanceOf("\Monolog\Logger", $log->getDriver());
@@ -53,7 +45,7 @@ class MonologTest extends PhraseanetPHPUnitAbstract
public function testType() public function testType()
{ {
$log = new \Alchemy\Phrasea\Core\Service\Log\Monolog( $log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
self::$core, 'hello', $this->options self::$core, $this->options
); );
$this->assertEquals("monolog", $log->getType()); $this->assertEquals("monolog", $log->getType());
@@ -64,7 +56,7 @@ class MonologTest extends PhraseanetPHPUnitAbstract
try try
{ {
$log = new \Alchemy\Phrasea\Core\Service\Log\Monolog( $log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
self::$core, 'hello', $this->options self::$core, $this->options
); );
$this->fail("should raise an exception"); $this->fail("should raise an exception");
} }
@@ -80,7 +72,7 @@ class MonologTest extends PhraseanetPHPUnitAbstract
{ {
unset($this->options["handler"]); unset($this->options["handler"]);
$log = new \Alchemy\Phrasea\Core\Service\Log\Monolog( $log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
self::$core, 'hello', $this->options self::$core, $this->options
); );
$this->fail("should raise an exception"); $this->fail("should raise an exception");
} }
@@ -96,7 +88,7 @@ class MonologTest extends PhraseanetPHPUnitAbstract
{ {
$this->options["handler"] = "unknowHandler"; $this->options["handler"] = "unknowHandler";
$log = new \Alchemy\Phrasea\Core\Service\Log\Monolog( $log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
self::$core, 'hello', $this->options self::$core, $this->options
); );
$this->fail("should raise an exception"); $this->fail("should raise an exception");
} }
@@ -112,7 +104,7 @@ class MonologTest extends PhraseanetPHPUnitAbstract
{ {
unset($this->options["filename"]); unset($this->options["filename"]);
$log = new \Alchemy\Phrasea\Core\Service\Log\Monolog( $log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
self::$core, 'hello', $this->options self::$core, $this->options
); );
$this->fail("should raise an exception"); $this->fail("should raise an exception");
} }
@@ -127,7 +119,7 @@ class MonologTest extends PhraseanetPHPUnitAbstract
$this->options["handler"] = "stream"; $this->options["handler"] = "stream";
$log = new \Alchemy\Phrasea\Core\Service\Log\Monolog( $log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
self::$core, 'hello', $this->options self::$core, $this->options
); );
$this->assertInstanceOf("\Monolog\Logger", $log->getDriver()); $this->assertInstanceOf("\Monolog\Logger", $log->getDriver());
} }

View File

@@ -37,19 +37,10 @@ class DoctrineTest extends PhraseanetPHPUnitAbstract
); );
} }
public function testScope()
{
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
self::$core, 'hello', $this->options
);
$this->assertEquals("orm", $doctrine->getScope());
}
public function testService() public function testService()
{ {
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine( $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
self::$core, 'hello', $this->options self::$core, $this->options
); );
$this->assertInstanceOf("\Doctrine\ORM\EntityManager", $doctrine->getDriver()); $this->assertInstanceOf("\Doctrine\ORM\EntityManager", $doctrine->getDriver());
@@ -58,7 +49,7 @@ class DoctrineTest extends PhraseanetPHPUnitAbstract
public function testType() public function testType()
{ {
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine( $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
self::$core, 'hello', $this->options self::$core, $this->options
); );
$this->assertEquals("doctrine", $doctrine->getType()); $this->assertEquals("doctrine", $doctrine->getType());
@@ -69,7 +60,7 @@ class DoctrineTest extends PhraseanetPHPUnitAbstract
try try
{ {
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine( $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
self::$core, 'hello', $this->options self::$core, $this->options
); );
$this->fail("should raise an exception"); $this->fail("should raise an exception");
} }
@@ -84,7 +75,7 @@ class DoctrineTest extends PhraseanetPHPUnitAbstract
$this->markTestSkipped('To rewrite'); $this->markTestSkipped('To rewrite');
unset($this->options["cache"]); unset($this->options["cache"]);
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine( $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
self::$core, 'hello', $this->options self::$core, $this->options
); );
foreach ($doctrine->getCacheServices()->all() as $service) foreach ($doctrine->getCacheServices()->all() as $service)
@@ -100,7 +91,7 @@ class DoctrineTest extends PhraseanetPHPUnitAbstract
try try
{ {
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine( $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
self::$core, 'hello', $this->options self::$core, $this->options
); );
$this->fail("An exception should be raised"); $this->fail("An exception should be raised");
} }
@@ -113,14 +104,14 @@ class DoctrineTest extends PhraseanetPHPUnitAbstract
public function testIsDebug() public function testIsDebug()
{ {
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine( $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
self::$core, 'hello', $this->options self::$core, $this->options
); );
$this->assertFalse($doctrine->isDebug()); $this->assertFalse($doctrine->isDebug());
$this->options['debug'] = true; $this->options['debug'] = true;
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine( $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
self::$core, 'hello', $this->options self::$core, $this->options
); );
$this->assertTrue($doctrine->isDebug()); $this->assertTrue($doctrine->isDebug());
@@ -130,7 +121,7 @@ class DoctrineTest extends PhraseanetPHPUnitAbstract
{ {
$this->markTestSkipped('To rewrite'); $this->markTestSkipped('To rewrite');
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine( $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
self::$core, 'hello', $this->options self::$core, $this->options
); );
$this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag" $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag"
, $doctrine->getCacheServices()); , $doctrine->getCacheServices());
@@ -149,7 +140,7 @@ class DoctrineTest extends PhraseanetPHPUnitAbstract
if (extension_loaded("apc") && extension_loaded("xcache")) if (extension_loaded("apc") && extension_loaded("xcache"))
{ {
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine( $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
self::$core, 'hello', $this->options self::$core, $this->options
); );
$this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag" $this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag"
, $doctrine->getCacheServices()); , $doctrine->getCacheServices());
@@ -169,7 +160,7 @@ class DoctrineTest extends PhraseanetPHPUnitAbstract
try try
{ {
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine( $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
self::$core, 'hello', $this->options self::$core, $this->options
); );
$this->fail("An exception should be raised"); $this->fail("An exception should be raised");
} }
@@ -186,7 +177,7 @@ class DoctrineTest extends PhraseanetPHPUnitAbstract
{ {
$this->options["log"] = "unknowLogger"; $this->options["log"] = "unknowLogger";
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine( $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
self::$core, 'hello', $this->options self::$core, $this->options
); );
$this->fail("should raise an exception"); $this->fail("should raise an exception");
} }
@@ -202,7 +193,7 @@ class DoctrineTest extends PhraseanetPHPUnitAbstract
{ {
unset($this->options["dbal"]); unset($this->options["dbal"]);
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine( $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
self::$core, 'hello', $this->options self::$core, $this->options
); );
$this->fail("should raise an exception"); $this->fail("should raise an exception");
} }
@@ -218,7 +209,7 @@ class DoctrineTest extends PhraseanetPHPUnitAbstract
{ {
$this->options["dbal"] = "unknowDbal"; $this->options["dbal"] = "unknowDbal";
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine( $doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
self::$core, 'hello', $this->options self::$core, $this->options
); );
$this->fail("should raise an exception"); $this->fail("should raise an exception");
} }

View File

@@ -32,8 +32,7 @@ class ServiceAbstractTest extends PhraseanetPHPUnitAbstract
$stub = $this->getMockForAbstractClass( $stub = $this->getMockForAbstractClass(
"\Alchemy\Phrasea\Core\Service\ServiceAbstract" "\Alchemy\Phrasea\Core\Service\ServiceAbstract"
, array( , array(
self::$core, self::$core
'abstract'
, array('option' => 'my_options') , array('option' => 'my_options')
) )
); );
@@ -41,11 +40,6 @@ class ServiceAbstractTest extends PhraseanetPHPUnitAbstract
$this->object = $stub; $this->object = $stub;
} }
public function testGetName()
{
$this->assertEquals("abstract", $this->object->getName());
}
public function testGetOptions() public function testGetOptions()
{ {
$this->assertTrue(is_array($this->object->getOptions())); $this->assertTrue(is_array($this->object->getOptions()));

View File

@@ -25,22 +25,19 @@ class TwigTest extends PhraseanetPHPUnitAbstract
public function setUp() public function setUp()
{ {
parent::setUp(); parent::setUp();
$this->options = array(); $this->options = array(
} 'debug' => true
,'charset' => 'utf-8'
public function testScope() ,'strict_variables' => true
{ ,'autoescape' => true
$doctrine = new \Alchemy\Phrasea\Core\Service\TemplateEngine\Twig( ,'optimizer' => true
self::$core, 'hello', $this->options
); );
$this->assertEquals("template_engine", $doctrine->getScope());
} }
public function testService() public function testService()
{ {
$doctrine = new \Alchemy\Phrasea\Core\Service\TemplateEngine\Twig( $doctrine = new \Alchemy\Phrasea\Core\Service\TemplateEngine\Twig(
self::$core, 'hello', $this->options self::$core, $this->options
); );
$this->assertInstanceOf("\Twig_Environment", $doctrine->getDriver()); $this->assertInstanceOf("\Twig_Environment", $doctrine->getDriver());
@@ -49,7 +46,7 @@ class TwigTest extends PhraseanetPHPUnitAbstract
public function testServiceExcpetion() public function testServiceExcpetion()
{ {
$doctrine = new \Alchemy\Phrasea\Core\Service\TemplateEngine\Twig( $doctrine = new \Alchemy\Phrasea\Core\Service\TemplateEngine\Twig(
self::$core, 'hello', $this->options self::$core, $this->options
); );
$this->assertInstanceOf("\Twig_Environment", $doctrine->getDriver()); $this->assertInstanceOf("\Twig_Environment", $doctrine->getDriver());
@@ -58,7 +55,7 @@ class TwigTest extends PhraseanetPHPUnitAbstract
public function testType() public function testType()
{ {
$doctrine = new \Alchemy\Phrasea\Core\Service\TemplateEngine\Twig( $doctrine = new \Alchemy\Phrasea\Core\Service\TemplateEngine\Twig(
self::$core, 'hello', $this->options self::$core, $this->options
); );
$this->assertEquals("twig", $doctrine->getType()); $this->assertEquals("twig", $doctrine->getType());

View File

@@ -28,7 +28,7 @@ class CacheBuilderTest extends PhraseanetPHPUnitAbstract
try try
{ {
$service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, "test", $configuration); $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
$this->fail("An exception should be raised"); $this->fail("An exception should be raised");
} }
catch (\Exception $e) catch (\Exception $e)
@@ -43,7 +43,7 @@ class CacheBuilderTest extends PhraseanetPHPUnitAbstract
array("type" => "Cache\\ArrayCache") array("type" => "Cache\\ArrayCache")
); );
$service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, "test", $configuration); $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
$this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service); $this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service);
} }

View File

@@ -28,7 +28,7 @@ class LogBuilderTest extends PhraseanetPHPUnitAbstract
try try
{ {
$service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, "test", $configuration); $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
$this->fail("An exception should be raised"); $this->fail("An exception should be raised");
} }
catch (\Exception $e) catch (\Exception $e)
@@ -50,7 +50,7 @@ class LogBuilderTest extends PhraseanetPHPUnitAbstract
) )
); );
$service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, "test", $configuration); $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
$this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service); $this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service);
} }
@@ -60,7 +60,7 @@ class LogBuilderTest extends PhraseanetPHPUnitAbstract
array("type" => "Log\\Doctrine\\Phpecho", "options" => array()) array("type" => "Log\\Doctrine\\Phpecho", "options" => array())
); );
$service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, "test", $configuration); $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
$this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service); $this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service);
} }

View File

@@ -28,7 +28,7 @@ class OrmBuilderTest extends PhraseanetPHPUnitAbstract
try try
{ {
$service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, "test", $configuration); $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
$this->fail("An exception should be raised"); $this->fail("An exception should be raised");
} }
catch (\Exception $e) catch (\Exception $e)
@@ -55,7 +55,7 @@ class OrmBuilderTest extends PhraseanetPHPUnitAbstract
) )
); );
$service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, "test", $configuration); $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
$this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service); $this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service);
} }

View File

@@ -28,7 +28,7 @@ class TemplateBuilderTest extends PhraseanetPHPUnitAbstract
try try
{ {
$service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, "test", $configuration); $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
$this->fail("An exception should be raised"); $this->fail("An exception should be raised");
} }
catch (\Exception $e) catch (\Exception $e)
@@ -51,7 +51,7 @@ class TemplateBuilderTest extends PhraseanetPHPUnitAbstract
)) ))
); );
$service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, "test", $configuration); $service = Alchemy\Phrasea\Core\Service\Builder::create(self::$core, $configuration);
$this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service); $this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service);
} }

View File

@@ -822,8 +822,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
$confService = $configuration->getService($serviceName); $confService = $configuration->getService($serviceName);
$templateService = \Alchemy\Phrasea\Core\Service\Builder::create( $templateService = \Alchemy\Phrasea\Core\Service\Builder::create(
self::$core, self::$core
$serviceName
, $confService , $confService
); );