mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-15 22:13:13 +00:00
refactor service interface
This commit is contained in:
@@ -71,7 +71,7 @@ class Manager
|
||||
try
|
||||
{
|
||||
$configuration = $this->core->getConfiguration()->getService($service_name);
|
||||
$service = Builder::create($this->core, $service_name, $configuration);
|
||||
$service = Builder::create($this->core, $configuration);
|
||||
$driver = $service->getDriver();
|
||||
$write = true;
|
||||
}
|
||||
@@ -80,7 +80,7 @@ class Manager
|
||||
$configuration = new \Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(
|
||||
array('type' => 'Cache\\ArrayCache')
|
||||
);
|
||||
$service = Builder::create($this->core, $service_name, $configuration);
|
||||
$service = Builder::create($this->core, $configuration);
|
||||
$driver = $service->getDriver();
|
||||
$write = false;
|
||||
}
|
||||
|
@@ -217,7 +217,6 @@ class Installer implements ControllerProviderInterface
|
||||
|
||||
$ormService = \Alchemy\Phrasea\Core\Service\Builder::create(
|
||||
$app['Core']
|
||||
, $serviceName
|
||||
, $confService
|
||||
);
|
||||
|
||||
|
@@ -94,7 +94,6 @@ class Core extends \Pimple
|
||||
|
||||
$this['CacheService'] = $this->share(function() use ($core)
|
||||
{
|
||||
|
||||
if (!file_exists(__DIR__ . '/../../../tmp/cache_registry.yml'))
|
||||
{
|
||||
touch(__DIR__ . '/../../../tmp/cache_registry.yml');
|
||||
@@ -112,7 +111,7 @@ class Core extends \Pimple
|
||||
$serviceName = $core->getConfiguration()->getOrm();
|
||||
$configuration = $core->getConfiguration()->getService($serviceName);
|
||||
|
||||
$Service = Core\Service\Builder::create($core, $serviceName, $configuration);
|
||||
$Service = Core\Service\Builder::create($core, $configuration);
|
||||
|
||||
return $Service->getDriver();
|
||||
});
|
||||
@@ -139,7 +138,7 @@ class Core extends \Pimple
|
||||
$serviceName = $core->getConfiguration()->getTemplating();
|
||||
$configuration = $core->getConfiguration()->getService($serviceName);
|
||||
|
||||
$Service = Core\Service\Builder::create($core, $serviceName, $configuration);
|
||||
$Service = Core\Service\Builder::create($core, $configuration);
|
||||
|
||||
return $Service->getDriver();
|
||||
});
|
||||
|
@@ -23,7 +23,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag,
|
||||
class Builder
|
||||
{
|
||||
|
||||
public static function create(Core $core, $name, ParameterBag $configuration)
|
||||
public static function create(Core $core, ParameterBag $configuration)
|
||||
{
|
||||
$classname = __NAMESPACE__ . '\\' . $configuration->get("type");
|
||||
|
||||
@@ -41,19 +41,7 @@ class Builder
|
||||
$options = array();
|
||||
}
|
||||
|
||||
$mandatory = $classname::getMandatoryOptions();
|
||||
|
||||
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);
|
||||
return new $classname($core, $options);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -28,11 +28,6 @@ class ApcCache extends ServiceAbstract implements ServiceInterface
|
||||
|
||||
protected $cache;
|
||||
|
||||
public function getScope()
|
||||
{
|
||||
return 'cache';
|
||||
}
|
||||
|
||||
public function getDriver()
|
||||
{
|
||||
if (!extension_loaded('apc'))
|
||||
@@ -55,10 +50,6 @@ class ApcCache extends ServiceAbstract implements ServiceInterface
|
||||
return 'apc';
|
||||
}
|
||||
|
||||
public static function getMandatoryOptions()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -29,11 +29,6 @@ class ArrayCache extends ServiceAbstract implements ServiceInterface
|
||||
|
||||
protected $cache;
|
||||
|
||||
public function getScope()
|
||||
{
|
||||
return 'cache';
|
||||
}
|
||||
|
||||
public function getDriver()
|
||||
{
|
||||
if (!$this->cache)
|
||||
@@ -51,10 +46,5 @@ class ArrayCache extends ServiceAbstract implements ServiceInterface
|
||||
return 'array';
|
||||
}
|
||||
|
||||
public static function getMandatoryOptions()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -26,28 +26,22 @@ use Alchemy\Phrasea\Core,
|
||||
class MemcacheCache extends ServiceAbstract implements ServiceInterface
|
||||
{
|
||||
|
||||
protected $cache;
|
||||
|
||||
const DEFAULT_HOST = "localhost";
|
||||
const DEFAULT_PORT = "11211";
|
||||
|
||||
protected $cache;
|
||||
protected $host;
|
||||
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->port = isset($options["port"]) ? $options["port"] : self::DEFAULT_PORT;
|
||||
}
|
||||
|
||||
public function getScope()
|
||||
{
|
||||
return 'cache';
|
||||
}
|
||||
|
||||
public function getDriver()
|
||||
{
|
||||
if (!extension_loaded('memcache'))
|
||||
@@ -55,7 +49,7 @@ class MemcacheCache extends ServiceAbstract implements ServiceInterface
|
||||
throw new \Exception('The Memcache cache requires the Memcache extension.');
|
||||
}
|
||||
|
||||
if(!$this->cache)
|
||||
if (!$this->cache)
|
||||
{
|
||||
$memcache = new \Memcache();
|
||||
|
||||
@@ -70,7 +64,7 @@ class MemcacheCache extends ServiceAbstract implements ServiceInterface
|
||||
$this->cache = new CacheDriver\MemcacheCache();
|
||||
$this->cache->setMemcache($memcache);
|
||||
|
||||
$this->cache->setNamespace(md5(realpath(__DIR__.'/../../../../../../')));
|
||||
$this->cache->setNamespace(md5(realpath(__DIR__ . '/../../../../../../')));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -96,10 +90,5 @@ class MemcacheCache extends ServiceAbstract implements ServiceInterface
|
||||
return $this->port;
|
||||
}
|
||||
|
||||
public static function getMandatoryOptions()
|
||||
{
|
||||
return array('host', 'port');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -26,28 +26,22 @@ use Alchemy\Phrasea\Core,
|
||||
class RedisCache extends ServiceAbstract implements ServiceInterface
|
||||
{
|
||||
|
||||
protected $cache;
|
||||
|
||||
const DEFAULT_HOST = "localhost";
|
||||
const DEFAULT_PORT = "6379";
|
||||
|
||||
protected $cache;
|
||||
protected $host;
|
||||
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->port = isset($options["port"]) ? $options["port"] : self::DEFAULT_PORT;
|
||||
}
|
||||
|
||||
public function getScope()
|
||||
{
|
||||
return 'cache';
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return Cache\ApcCache
|
||||
@@ -100,10 +94,5 @@ class RedisCache extends ServiceAbstract implements ServiceInterface
|
||||
return $this->port;
|
||||
}
|
||||
|
||||
public static function getMandatoryOptions()
|
||||
{
|
||||
return array('host', 'port');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -28,11 +28,6 @@ class XcacheCache extends ServiceAbstract implements ServiceInterface
|
||||
|
||||
protected $cache;
|
||||
|
||||
public function getScope()
|
||||
{
|
||||
return 'cache';
|
||||
}
|
||||
|
||||
public function getDriver()
|
||||
{
|
||||
if (!extension_loaded('xcache'))
|
||||
@@ -55,9 +50,4 @@ class XcacheCache extends ServiceAbstract implements ServiceInterface
|
||||
return 'xcache';
|
||||
}
|
||||
|
||||
public static function getMandatoryOptions()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -15,9 +15,9 @@ use Alchemy\Phrasea\Core,
|
||||
Alchemy\Phrasea\Core\Service,
|
||||
Alchemy\Phrasea\Core\Service\ServiceAbstract,
|
||||
Alchemy\Phrasea\Core\Service\ServiceInterface;
|
||||
|
||||
use Alchemy\Phrasea\Core\Service\Log\Monolog as ParentLog;
|
||||
use Doctrine\Logger\MonologSQLLogger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
@@ -26,27 +26,27 @@ use Doctrine\Logger\MonologSQLLogger;
|
||||
*/
|
||||
class Monolog extends ParentLog implements ServiceInterface
|
||||
{
|
||||
|
||||
const JSON_OUTPUT = 'json';
|
||||
const YAML_OUTPUT = 'yaml';
|
||||
const VAR_DUMP_OUTPUT = 'vdump';
|
||||
|
||||
protected $outputs = array(
|
||||
self::JSON_OUTPUT, self::YAML_OUTPUT, self::VAR_DUMP_OUTPUT
|
||||
);
|
||||
|
||||
public function getDriver()
|
||||
{
|
||||
$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(
|
||||
"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."
|
||||
, $output
|
||||
, $this->name
|
||||
, $this->getScope()
|
||||
, implode(", ", $this->outputs)
|
||||
, __CLASS__
|
||||
, implode(", ", $outputs)
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -59,9 +59,5 @@ class Monolog extends ParentLog implements ServiceInterface
|
||||
return 'doctrine_monolog';
|
||||
}
|
||||
|
||||
public static function getMandatoryOptions()
|
||||
{
|
||||
return array('output', 'channel', 'handler', 'max_day', 'filename');
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -26,7 +26,6 @@ use Doctrine\DBAL\Logging\EchoSQLLogger;
|
||||
class Phpecho extends ServiceAbstract implements ServiceInterface
|
||||
{
|
||||
|
||||
|
||||
public function getDriver()
|
||||
{
|
||||
return new EchoSQLLogger();
|
||||
@@ -37,14 +36,4 @@ class Phpecho extends ServiceAbstract implements ServiceInterface
|
||||
return 'phpecho';
|
||||
}
|
||||
|
||||
public function getScope()
|
||||
{
|
||||
return 'log';
|
||||
}
|
||||
|
||||
public static function getMandatoryOptions()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -29,19 +29,15 @@ class FirePHP extends ServiceAbstract implements ServiceInterface
|
||||
|
||||
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()
|
||||
{
|
||||
if (!$this->logger)
|
||||
{
|
||||
$this->logger = new Logger('FirePHP');
|
||||
|
||||
$this->logger->pushHandler(new FirePHPHandler());
|
||||
}
|
||||
|
||||
return $this->logger;
|
||||
}
|
||||
|
||||
@@ -50,14 +46,4 @@ class FirePHP extends ServiceAbstract implements ServiceInterface
|
||||
return 'FirePHP Monolog';
|
||||
}
|
||||
|
||||
public function getScope()
|
||||
{
|
||||
return 'log';
|
||||
}
|
||||
|
||||
public static function getMandatoryOptions()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -37,9 +37,9 @@ class Monolog extends ServiceAbstract implements ServiceInterface
|
||||
*/
|
||||
protected $monolog;
|
||||
|
||||
public function __construct(Core $core, $name, Array $options)
|
||||
protected function init()
|
||||
{
|
||||
parent::__construct( $core, $name, $options);
|
||||
$options = $this->getOptions();
|
||||
|
||||
if (empty($options))
|
||||
{
|
||||
@@ -52,8 +52,8 @@ class Monolog extends ServiceAbstract implements ServiceInterface
|
||||
if (!$handler)
|
||||
{
|
||||
throw new \Exception(sprintf(
|
||||
"You must specify at least one handler for %s service"
|
||||
, $this->name
|
||||
"You must specify at least one handler for '%s' service"
|
||||
, __CLASS__
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -64,8 +64,7 @@ class Monolog extends ServiceAbstract implements ServiceInterface
|
||||
"The handler type '%s' declared in %s %s service is not valid.
|
||||
Available types are %s."
|
||||
, $handler
|
||||
, $this->name
|
||||
, $this->getScope()
|
||||
, __CLASS__
|
||||
, implode(", ", $this->handlers)
|
||||
)
|
||||
);
|
||||
@@ -88,7 +87,7 @@ class Monolog extends ServiceAbstract implements ServiceInterface
|
||||
{
|
||||
throw new \Exception(sprintf(
|
||||
"Missing filename option in '%s' service"
|
||||
, $this->name
|
||||
, __CLASS__
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -129,14 +128,9 @@ class Monolog extends ServiceAbstract implements ServiceInterface
|
||||
return 'monolog';
|
||||
}
|
||||
|
||||
public function getScope()
|
||||
public function getMandatoryOptions()
|
||||
{
|
||||
return 'log';
|
||||
}
|
||||
|
||||
public static function getMandatoryOptions()
|
||||
{
|
||||
return array('output', 'channel', 'handler', 'max_day', 'filename');
|
||||
return array('channel', 'handler', 'filename');
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -27,18 +27,16 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
class Doctrine extends ServiceAbstract implements ServiceInterface
|
||||
{
|
||||
|
||||
protected $outputs = array(
|
||||
'json', 'yaml', 'vdump'
|
||||
);
|
||||
protected $loggers = array(
|
||||
'Log\\Doctrine\Monolog', 'Log\\Doctrine\\Phpecho'
|
||||
'Log\\Doctrine\Monolog'
|
||||
, 'Log\\Doctrine\\Phpecho'
|
||||
);
|
||||
protected $entityManager;
|
||||
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();
|
||||
|
||||
@@ -55,16 +53,16 @@ class Doctrine extends ServiceAbstract implements ServiceInterface
|
||||
|
||||
if (!$cache || $this->debug)
|
||||
{
|
||||
$metaCache = $this->core['CacheService']->get('ORMmetadata', 'Cache\\ArrayCache');
|
||||
$queryCache = $this->core['CacheService']->get('ORMquery', 'Cache\\ArrayCache');
|
||||
$metaCache = $this->core['CacheService']->get('ORMmetadata', 'Cache\\ArrayCache');
|
||||
$queryCache = $this->core['CacheService']->get('ORMquery', 'Cache\\ArrayCache');
|
||||
}
|
||||
else
|
||||
{
|
||||
$query = isset($cache["query"]['service']) ? $cache["query"]['service'] : 'Cache\\ArrayCache';
|
||||
$meta = isset($cache["metadata"]['service']) ? $cache["metadata"]['service'] : 'Cache\\ArrayCache';
|
||||
$query = isset($cache["query"]['service']) ? $cache["query"]['service'] : 'Cache\\ArrayCache';
|
||||
$meta = isset($cache["metadata"]['service']) ? $cache["metadata"]['service'] : 'Cache\\ArrayCache';
|
||||
|
||||
$queryCache = $this->core['CacheService']->get('ORMquery', $query);
|
||||
$metaCache = $this->core['CacheService']->get('ORMmetadata', $meta);
|
||||
$queryCache = $this->core['CacheService']->get('ORMquery', $query);
|
||||
$metaCache = $this->core['CacheService']->get('ORMmetadata', $meta);
|
||||
}
|
||||
|
||||
$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();
|
||||
|
||||
$driverYaml = new \Doctrine\ORM\Mapping\Driver\YamlDriver(
|
||||
array(__DIR__ . '/../../../../../conf.d/Doctrine')
|
||||
array(__DIR__ . '/../../../../../conf.d/Doctrine')
|
||||
);
|
||||
|
||||
$chainDriverImpl->addDriver($driverYaml, 'Entities');
|
||||
@@ -99,9 +97,9 @@ class Doctrine extends ServiceAbstract implements ServiceInterface
|
||||
if (!$connexion)
|
||||
{
|
||||
throw new \Exception(sprintf(
|
||||
"Missing dbal configuration for '%s' service"
|
||||
, __CLASS__
|
||||
)
|
||||
"Missing dbal configuration for '%s' service"
|
||||
, __CLASS__
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -125,9 +123,9 @@ class Doctrine extends ServiceAbstract implements ServiceInterface
|
||||
catch (\Exception $e)
|
||||
{
|
||||
throw new \Exception(sprintf(
|
||||
"Failed to create doctrine service for the following reason '%s'"
|
||||
, $e->getMessage()
|
||||
)
|
||||
"Failed to create doctrine service for the following reason '%s'"
|
||||
, $e->getMessage()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -184,11 +182,13 @@ class Doctrine extends ServiceAbstract implements ServiceInterface
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$message = sprintf(
|
||||
"%s from %s service in orm:log scope"
|
||||
, $e->getMessage()
|
||||
, $this->name
|
||||
"%s from %s service"
|
||||
, $e->getMessage()
|
||||
, __CLASS__
|
||||
);
|
||||
$e = new \Exception($message);
|
||||
|
||||
$e = new \Exception($message);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
@@ -197,17 +197,16 @@ class Doctrine extends ServiceAbstract implements ServiceInterface
|
||||
if (!in_array($type, $this->loggers))
|
||||
{
|
||||
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."
|
||||
, $type
|
||||
, $this->name
|
||||
, $this->getScope()
|
||||
, implode(", ", $this->loggers)
|
||||
)
|
||||
, $type
|
||||
, __CLASS__
|
||||
, implode(", ", $this->loggers)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$service = Core\Service\Builder::create($this->core, $serviceName, $configuration);
|
||||
$service = Core\Service\Builder::create($this->core, $configuration);
|
||||
|
||||
return $service->getDriver();
|
||||
}
|
||||
@@ -222,17 +221,12 @@ class Doctrine extends ServiceAbstract implements ServiceInterface
|
||||
return 'doctrine';
|
||||
}
|
||||
|
||||
public function getScope()
|
||||
{
|
||||
return 'orm';
|
||||
}
|
||||
|
||||
public function isDebug()
|
||||
{
|
||||
return $this->debug;
|
||||
}
|
||||
|
||||
public static function getMandatoryOptions()
|
||||
public function getMandatoryOptions()
|
||||
{
|
||||
return array('debug', 'dbal');
|
||||
}
|
||||
|
@@ -23,25 +23,37 @@ use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
abstract class ServiceAbstract
|
||||
{
|
||||
|
||||
protected $name;
|
||||
protected $core;
|
||||
protected $options;
|
||||
protected $configuration;
|
||||
|
||||
public function __construct(Core $core, $name, Array $options)
|
||||
final public function __construct(Core $core, Array $options)
|
||||
{
|
||||
$this->core = $core;
|
||||
$this->name = $name;
|
||||
$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();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
protected function init()
|
||||
{
|
||||
return $this->name;
|
||||
return;
|
||||
}
|
||||
|
||||
protected function getCore()
|
||||
{
|
||||
return $this->core;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,6 +65,13 @@ abstract class ServiceAbstract
|
||||
return $this->options;
|
||||
}
|
||||
|
||||
abstract public static function getMandatoryOptions();
|
||||
/**
|
||||
*
|
||||
* @return Array
|
||||
*/
|
||||
public function getMandatoryOptions()
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -20,14 +20,12 @@ namespace Alchemy\Phrasea\Core\Service;
|
||||
interface ServiceInterface
|
||||
{
|
||||
|
||||
public function getName();
|
||||
|
||||
public function getType();
|
||||
|
||||
public function getDriver();
|
||||
|
||||
public function getOptions();
|
||||
|
||||
public function getScope();
|
||||
public function getMandatoryOptions();
|
||||
|
||||
}
|
||||
|
@@ -26,15 +26,13 @@ class Twig extends ServiceAbstract implements ServiceInterface
|
||||
protected $twig;
|
||||
protected $templatesPath = array();
|
||||
|
||||
public function __construct(Core $core, $name, Array $options)
|
||||
protected function init()
|
||||
{
|
||||
parent::__construct( $core, $name, $options);
|
||||
|
||||
$this->templatesPath = $this->resolvePaths();
|
||||
|
||||
try
|
||||
{
|
||||
if (!isset($this->options['debug']) || !$this->options['debug'])
|
||||
if (!$this->options['debug'])
|
||||
{
|
||||
$this->options['cache'] = realpath(__DIR__ . '/../../../../../../tmp/cache_twig/');
|
||||
}
|
||||
@@ -50,7 +48,7 @@ class Twig extends ServiceAbstract implements ServiceInterface
|
||||
{
|
||||
throw new \Exception(sprintf(
|
||||
"Unable to create '%s' service for the following reason %s"
|
||||
, $this->name
|
||||
, __CLASS__
|
||||
, $e->getMessage()
|
||||
)
|
||||
);
|
||||
@@ -207,12 +205,7 @@ class Twig extends ServiceAbstract implements ServiceInterface
|
||||
return 'twig';
|
||||
}
|
||||
|
||||
public function getScope()
|
||||
{
|
||||
return 'template_engine';
|
||||
}
|
||||
|
||||
public static function getMandatoryOptions()
|
||||
public function getMandatoryOptions()
|
||||
{
|
||||
return array('debug', 'charset', 'strict_variables', 'autoescape', 'optimizer');
|
||||
}
|
||||
|
@@ -466,7 +466,7 @@ class module_console_fileEnsureDevSetting extends Command
|
||||
|
||||
try
|
||||
{
|
||||
Core\Service\Builder::create(\bootstrap::getCore(), $templateEngineName, $configuration);
|
||||
Core\Service\Builder::create(\bootstrap::getCore(), $configuration);
|
||||
$work_message = '<info>Works !</info>';
|
||||
}
|
||||
catch (\Exception $e)
|
||||
@@ -592,7 +592,7 @@ class module_console_fileEnsureDevSetting extends Command
|
||||
|
||||
try
|
||||
{
|
||||
$service = Core\Service\Builder::create(\bootstrap::getCore(), $ormName, $configuration);
|
||||
$service = Core\Service\Builder::create(\bootstrap::getCore(), $configuration);
|
||||
$work_message = '<info>Works !</info>';
|
||||
}
|
||||
catch (\Exception $e)
|
||||
@@ -774,7 +774,7 @@ class module_console_fileEnsureDevSetting extends Command
|
||||
$conf = $this->configuration->getService($ServiceName);
|
||||
|
||||
$Service = Core\Service\Builder::create(
|
||||
\bootstrap::getCore(), $ServiceName, $conf
|
||||
\bootstrap::getCore(), $conf
|
||||
);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
@@ -845,7 +845,7 @@ class module_console_fileEnsureDevSetting extends Command
|
||||
$originalConfiguration = $this->configuration->getService($ServiceName);
|
||||
|
||||
$Service = Core\Service\Builder::create(
|
||||
\bootstrap::getCore(), $ServiceName, $originalConfiguration
|
||||
\bootstrap::getCore(), $originalConfiguration
|
||||
);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
@@ -879,7 +879,7 @@ class module_console_fileEnsureDevSetting extends Command
|
||||
$originalConfiguration = $this->configuration->getService($ServiceName);
|
||||
|
||||
$Service = Core\Service\Builder::create(
|
||||
\bootstrap::getCore(), $ServiceName, $originalConfiguration
|
||||
\bootstrap::getCore(), $originalConfiguration
|
||||
);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
|
@@ -460,7 +460,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
||||
|
||||
try
|
||||
{
|
||||
Core\Service\Builder::create(\bootstrap::getCore(), $templateEngineName, $configuration);
|
||||
Core\Service\Builder::create(\bootstrap::getCore(), $configuration);
|
||||
$work_message = '<info>Works !</info>';
|
||||
}
|
||||
catch (\Exception $e)
|
||||
@@ -586,7 +586,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
||||
|
||||
try
|
||||
{
|
||||
$service = Core\Service\Builder::create(\bootstrap::getCore(), $ormName, $configuration);
|
||||
$service = Core\Service\Builder::create(\bootstrap::getCore(), $configuration);
|
||||
$work_message = '<info>Works !</info>';
|
||||
}
|
||||
catch (\Exception $e)
|
||||
@@ -781,7 +781,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
||||
$conf = $this->configuration->getService($ServiceName);
|
||||
|
||||
$Service = Core\Service\Builder::create(
|
||||
\bootstrap::getCore(), $ServiceName, $conf
|
||||
\bootstrap::getCore(), $conf
|
||||
);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
@@ -852,7 +852,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
||||
$originalConfiguration = $this->configuration->getService($ServiceName);
|
||||
|
||||
$Service = Core\Service\Builder::create(
|
||||
\bootstrap::getCore(), $ServiceName, $originalConfiguration
|
||||
\bootstrap::getCore(), $originalConfiguration
|
||||
);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
@@ -886,7 +886,7 @@ class module_console_fileEnsureProductionSetting extends Command
|
||||
$originalConfiguration = $this->configuration->getService($ServiceName);
|
||||
|
||||
$Service = Core\Service\Builder::create(
|
||||
\bootstrap::getCore(), $ServiceName, $originalConfiguration
|
||||
\bootstrap::getCore(), $originalConfiguration
|
||||
);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
|
@@ -20,19 +20,10 @@ require_once __DIR__ . '/../../../../../PhraseanetPHPUnitAbstract.class.inc';
|
||||
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()
|
||||
{
|
||||
$cache = new \Alchemy\Phrasea\Core\Service\Cache\ApcCache(
|
||||
self::$core, 'hello', array()
|
||||
self::$core, array()
|
||||
);
|
||||
|
||||
if (extension_loaded('apc'))
|
||||
@@ -57,7 +48,7 @@ class ServiceApcCacheTest extends PhraseanetPHPUnitAbstract
|
||||
public function testServiceException()
|
||||
{
|
||||
$cache = new \Alchemy\Phrasea\Core\Service\Cache\ApcCache(
|
||||
self::$core, 'hello', array()
|
||||
self::$core, array()
|
||||
);
|
||||
|
||||
try
|
||||
@@ -74,7 +65,7 @@ class ServiceApcCacheTest extends PhraseanetPHPUnitAbstract
|
||||
public function testType()
|
||||
{
|
||||
$cache = new \Alchemy\Phrasea\Core\Service\Cache\ApcCache(
|
||||
self::$core, 'hello', array()
|
||||
self::$core, array()
|
||||
);
|
||||
|
||||
$this->assertEquals("apc", $cache->getType());
|
||||
|
@@ -20,19 +20,10 @@ require_once __DIR__ . '/../../../../../PhraseanetPHPUnitAbstract.class.inc';
|
||||
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()
|
||||
{
|
||||
$cache = new \Alchemy\Phrasea\Core\Service\Cache\ArrayCache(
|
||||
self::$core, 'hello', array()
|
||||
self::$core, array()
|
||||
);
|
||||
|
||||
$service = $cache->getDriver();
|
||||
@@ -42,7 +33,7 @@ class ServiceArrayCacheTest extends PhraseanetPHPUnitAbstract
|
||||
public function testServiceException()
|
||||
{
|
||||
$cache = new \Alchemy\Phrasea\Core\Service\Cache\ArrayCache(
|
||||
self::$core, 'hello', array()
|
||||
self::$core, array()
|
||||
);
|
||||
|
||||
try
|
||||
@@ -59,7 +50,7 @@ class ServiceArrayCacheTest extends PhraseanetPHPUnitAbstract
|
||||
public function testType()
|
||||
{
|
||||
$cache = new \Alchemy\Phrasea\Core\Service\Cache\ArrayCache(
|
||||
self::$core, 'hello', array()
|
||||
self::$core, array()
|
||||
);
|
||||
|
||||
$this->assertEquals("array", $cache->getType());
|
||||
|
@@ -20,19 +20,10 @@ require_once __DIR__ . '/../../../../../PhraseanetPHPUnitAbstract.class.inc';
|
||||
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()
|
||||
{
|
||||
$cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache(
|
||||
self::$core, 'hello', array()
|
||||
self::$core, array()
|
||||
);
|
||||
|
||||
if (extension_loaded('memcache'))
|
||||
@@ -57,7 +48,7 @@ class ServiceMemcacheCacheTest extends PhraseanetPHPUnitAbstract
|
||||
public function testServiceException()
|
||||
{
|
||||
$cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache(
|
||||
self::$core, 'hello', array()
|
||||
self::$core, array()
|
||||
);
|
||||
|
||||
try
|
||||
@@ -74,7 +65,7 @@ class ServiceMemcacheCacheTest extends PhraseanetPHPUnitAbstract
|
||||
public function testType()
|
||||
{
|
||||
$cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache(
|
||||
self::$core, 'hello', array()
|
||||
self::$core, array()
|
||||
);
|
||||
|
||||
$this->assertEquals("memcache", $cache->getType());
|
||||
@@ -83,7 +74,7 @@ class ServiceMemcacheCacheTest extends PhraseanetPHPUnitAbstract
|
||||
public function testHost()
|
||||
{
|
||||
$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());
|
||||
@@ -92,7 +83,7 @@ class ServiceMemcacheCacheTest extends PhraseanetPHPUnitAbstract
|
||||
public function testPort()
|
||||
{
|
||||
$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());
|
||||
|
@@ -20,19 +20,10 @@ require_once __DIR__ . '/../../../../../PhraseanetPHPUnitAbstract.class.inc';
|
||||
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()
|
||||
{
|
||||
$cache = new \Alchemy\Phrasea\Core\Service\Cache\XcacheCache(
|
||||
self::$core, 'hello', array()
|
||||
self::$core, array()
|
||||
);
|
||||
|
||||
if (extension_loaded('xcache'))
|
||||
@@ -57,7 +48,7 @@ class ServiceXcacheCacheTest extends PhraseanetPHPUnitAbstract
|
||||
public function testServiceException()
|
||||
{
|
||||
$cache = new \Alchemy\Phrasea\Core\Service\Cache\XcacheCache(
|
||||
self::$core, 'hello', array()
|
||||
self::$core, array()
|
||||
);
|
||||
|
||||
try
|
||||
@@ -74,7 +65,7 @@ class ServiceXcacheCacheTest extends PhraseanetPHPUnitAbstract
|
||||
public function testType()
|
||||
{
|
||||
$cache = new \Alchemy\Phrasea\Core\Service\Cache\XcacheCache(
|
||||
self::$core, 'hello', array()
|
||||
self::$core, array()
|
||||
);
|
||||
|
||||
$this->assertEquals("xcache", $cache->getType());
|
||||
|
@@ -20,26 +20,23 @@ require_once __DIR__ . '/../../../../../../PhraseanetPHPUnitAbstract.class.inc';
|
||||
class DoctrineMonologTest extends PhraseanetPHPUnitAbstract
|
||||
{
|
||||
|
||||
protected $options = array(
|
||||
"handler" => "rotate"
|
||||
, "filename" => "test"
|
||||
);
|
||||
protected $options = array(
|
||||
"handler" => "rotate"
|
||||
, "filename" => "test"
|
||||
, 'output' => 'json'
|
||||
, 'channel' => 'test'
|
||||
);
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->options = array(
|
||||
"handler" => "rotate"
|
||||
, "filename" => "test"
|
||||
, 'output' => 'json'
|
||||
);
|
||||
}
|
||||
|
||||
public function testService()
|
||||
{
|
||||
|
||||
$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());
|
||||
@@ -48,7 +45,7 @@ class DoctrineMonologTest extends PhraseanetPHPUnitAbstract
|
||||
public function testType()
|
||||
{
|
||||
$log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Monolog(
|
||||
self::$core, 'hello', $this->options
|
||||
self::$core, $this->options
|
||||
);
|
||||
|
||||
$this->assertEquals("doctrine_monolog", $log->getType());
|
||||
@@ -60,7 +57,7 @@ class DoctrineMonologTest extends PhraseanetPHPUnitAbstract
|
||||
{
|
||||
$this->options["output"] = "unknowOutput";
|
||||
$log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Monolog(
|
||||
self::$core, 'hello', $this->options
|
||||
self::$core, $this->options
|
||||
);
|
||||
$log->getDriver();
|
||||
$this->fail("should raise an exception");
|
||||
|
@@ -24,7 +24,7 @@ class DoctrinePhpechoTest extends PhraseanetPHPUnitAbstract
|
||||
{
|
||||
|
||||
$log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Phpecho(
|
||||
self::$core, 'hello', array()
|
||||
self::$core, array()
|
||||
);
|
||||
|
||||
$this->assertInstanceOf("\Doctrine\DBAL\Logging\EchoSQLLogger", $log->getDriver());
|
||||
@@ -33,18 +33,10 @@ class DoctrinePhpechoTest extends PhraseanetPHPUnitAbstract
|
||||
public function testType()
|
||||
{
|
||||
$log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Phpecho(
|
||||
self::$core, 'hello', array()
|
||||
self::$core, array()
|
||||
);
|
||||
|
||||
$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());
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -28,23 +28,15 @@ class MonologTest extends PhraseanetPHPUnitAbstract
|
||||
$this->options = array(
|
||||
"handler" => "rotate"
|
||||
, "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()
|
||||
{
|
||||
$log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
|
||||
self::$core, 'hello', $this->options
|
||||
self::$core, $this->options
|
||||
);
|
||||
|
||||
$this->assertInstanceOf("\Monolog\Logger", $log->getDriver());
|
||||
@@ -53,7 +45,7 @@ class MonologTest extends PhraseanetPHPUnitAbstract
|
||||
public function testType()
|
||||
{
|
||||
$log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
|
||||
self::$core, 'hello', $this->options
|
||||
self::$core, $this->options
|
||||
);
|
||||
|
||||
$this->assertEquals("monolog", $log->getType());
|
||||
@@ -64,7 +56,7 @@ class MonologTest extends PhraseanetPHPUnitAbstract
|
||||
try
|
||||
{
|
||||
$log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
|
||||
self::$core, 'hello', $this->options
|
||||
self::$core, $this->options
|
||||
);
|
||||
$this->fail("should raise an exception");
|
||||
}
|
||||
@@ -80,7 +72,7 @@ class MonologTest extends PhraseanetPHPUnitAbstract
|
||||
{
|
||||
unset($this->options["handler"]);
|
||||
$log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
|
||||
self::$core, 'hello', $this->options
|
||||
self::$core, $this->options
|
||||
);
|
||||
$this->fail("should raise an exception");
|
||||
}
|
||||
@@ -96,7 +88,7 @@ class MonologTest extends PhraseanetPHPUnitAbstract
|
||||
{
|
||||
$this->options["handler"] = "unknowHandler";
|
||||
$log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
|
||||
self::$core, 'hello', $this->options
|
||||
self::$core, $this->options
|
||||
);
|
||||
$this->fail("should raise an exception");
|
||||
}
|
||||
@@ -112,7 +104,7 @@ class MonologTest extends PhraseanetPHPUnitAbstract
|
||||
{
|
||||
unset($this->options["filename"]);
|
||||
$log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
|
||||
self::$core, 'hello', $this->options
|
||||
self::$core, $this->options
|
||||
);
|
||||
$this->fail("should raise an exception");
|
||||
}
|
||||
@@ -127,7 +119,7 @@ class MonologTest extends PhraseanetPHPUnitAbstract
|
||||
|
||||
$this->options["handler"] = "stream";
|
||||
$log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
|
||||
self::$core, 'hello', $this->options
|
||||
self::$core, $this->options
|
||||
);
|
||||
$this->assertInstanceOf("\Monolog\Logger", $log->getDriver());
|
||||
}
|
||||
|
@@ -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()
|
||||
{
|
||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
||||
self::$core, 'hello', $this->options
|
||||
self::$core, $this->options
|
||||
);
|
||||
|
||||
$this->assertInstanceOf("\Doctrine\ORM\EntityManager", $doctrine->getDriver());
|
||||
@@ -58,7 +49,7 @@ class DoctrineTest extends PhraseanetPHPUnitAbstract
|
||||
public function testType()
|
||||
{
|
||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
||||
self::$core, 'hello', $this->options
|
||||
self::$core, $this->options
|
||||
);
|
||||
|
||||
$this->assertEquals("doctrine", $doctrine->getType());
|
||||
@@ -69,7 +60,7 @@ class DoctrineTest extends PhraseanetPHPUnitAbstract
|
||||
try
|
||||
{
|
||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
||||
self::$core, 'hello', $this->options
|
||||
self::$core, $this->options
|
||||
);
|
||||
$this->fail("should raise an exception");
|
||||
}
|
||||
@@ -84,7 +75,7 @@ class DoctrineTest extends PhraseanetPHPUnitAbstract
|
||||
$this->markTestSkipped('To rewrite');
|
||||
unset($this->options["cache"]);
|
||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
||||
self::$core, 'hello', $this->options
|
||||
self::$core, $this->options
|
||||
);
|
||||
|
||||
foreach ($doctrine->getCacheServices()->all() as $service)
|
||||
@@ -100,7 +91,7 @@ class DoctrineTest extends PhraseanetPHPUnitAbstract
|
||||
try
|
||||
{
|
||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
||||
self::$core, 'hello', $this->options
|
||||
self::$core, $this->options
|
||||
);
|
||||
$this->fail("An exception should be raised");
|
||||
}
|
||||
@@ -113,14 +104,14 @@ class DoctrineTest extends PhraseanetPHPUnitAbstract
|
||||
public function testIsDebug()
|
||||
{
|
||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
||||
self::$core, 'hello', $this->options
|
||||
self::$core, $this->options
|
||||
);
|
||||
|
||||
$this->assertFalse($doctrine->isDebug());
|
||||
|
||||
$this->options['debug'] = true;
|
||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
||||
self::$core, 'hello', $this->options
|
||||
self::$core, $this->options
|
||||
);
|
||||
|
||||
$this->assertTrue($doctrine->isDebug());
|
||||
@@ -130,7 +121,7 @@ class DoctrineTest extends PhraseanetPHPUnitAbstract
|
||||
{
|
||||
$this->markTestSkipped('To rewrite');
|
||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
||||
self::$core, 'hello', $this->options
|
||||
self::$core, $this->options
|
||||
);
|
||||
$this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag"
|
||||
, $doctrine->getCacheServices());
|
||||
@@ -149,7 +140,7 @@ class DoctrineTest extends PhraseanetPHPUnitAbstract
|
||||
if (extension_loaded("apc") && extension_loaded("xcache"))
|
||||
{
|
||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
||||
self::$core, 'hello', $this->options
|
||||
self::$core, $this->options
|
||||
);
|
||||
$this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag"
|
||||
, $doctrine->getCacheServices());
|
||||
@@ -169,7 +160,7 @@ class DoctrineTest extends PhraseanetPHPUnitAbstract
|
||||
try
|
||||
{
|
||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
||||
self::$core, 'hello', $this->options
|
||||
self::$core, $this->options
|
||||
);
|
||||
$this->fail("An exception should be raised");
|
||||
}
|
||||
@@ -186,7 +177,7 @@ class DoctrineTest extends PhraseanetPHPUnitAbstract
|
||||
{
|
||||
$this->options["log"] = "unknowLogger";
|
||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
||||
self::$core, 'hello', $this->options
|
||||
self::$core, $this->options
|
||||
);
|
||||
$this->fail("should raise an exception");
|
||||
}
|
||||
@@ -202,7 +193,7 @@ class DoctrineTest extends PhraseanetPHPUnitAbstract
|
||||
{
|
||||
unset($this->options["dbal"]);
|
||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
||||
self::$core, 'hello', $this->options
|
||||
self::$core, $this->options
|
||||
);
|
||||
$this->fail("should raise an exception");
|
||||
}
|
||||
@@ -218,7 +209,7 @@ class DoctrineTest extends PhraseanetPHPUnitAbstract
|
||||
{
|
||||
$this->options["dbal"] = "unknowDbal";
|
||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
||||
self::$core, 'hello', $this->options
|
||||
self::$core, $this->options
|
||||
);
|
||||
$this->fail("should raise an exception");
|
||||
}
|
||||
|
@@ -32,8 +32,7 @@ class ServiceAbstractTest extends PhraseanetPHPUnitAbstract
|
||||
$stub = $this->getMockForAbstractClass(
|
||||
"\Alchemy\Phrasea\Core\Service\ServiceAbstract"
|
||||
, array(
|
||||
self::$core,
|
||||
'abstract'
|
||||
self::$core
|
||||
, array('option' => 'my_options')
|
||||
)
|
||||
);
|
||||
@@ -41,11 +40,6 @@ class ServiceAbstractTest extends PhraseanetPHPUnitAbstract
|
||||
$this->object = $stub;
|
||||
}
|
||||
|
||||
public function testGetName()
|
||||
{
|
||||
$this->assertEquals("abstract", $this->object->getName());
|
||||
}
|
||||
|
||||
public function testGetOptions()
|
||||
{
|
||||
$this->assertTrue(is_array($this->object->getOptions()));
|
||||
|
@@ -25,22 +25,19 @@ class TwigTest extends PhraseanetPHPUnitAbstract
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
$this->options = array();
|
||||
}
|
||||
|
||||
public function testScope()
|
||||
{
|
||||
$doctrine = new \Alchemy\Phrasea\Core\Service\TemplateEngine\Twig(
|
||||
self::$core, 'hello', $this->options
|
||||
$this->options = array(
|
||||
'debug' => true
|
||||
,'charset' => 'utf-8'
|
||||
,'strict_variables' => true
|
||||
,'autoescape' => true
|
||||
,'optimizer' => true
|
||||
);
|
||||
|
||||
$this->assertEquals("template_engine", $doctrine->getScope());
|
||||
}
|
||||
|
||||
public function testService()
|
||||
{
|
||||
$doctrine = new \Alchemy\Phrasea\Core\Service\TemplateEngine\Twig(
|
||||
self::$core, 'hello', $this->options
|
||||
self::$core, $this->options
|
||||
);
|
||||
|
||||
$this->assertInstanceOf("\Twig_Environment", $doctrine->getDriver());
|
||||
@@ -49,7 +46,7 @@ class TwigTest extends PhraseanetPHPUnitAbstract
|
||||
public function testServiceExcpetion()
|
||||
{
|
||||
$doctrine = new \Alchemy\Phrasea\Core\Service\TemplateEngine\Twig(
|
||||
self::$core, 'hello', $this->options
|
||||
self::$core, $this->options
|
||||
);
|
||||
|
||||
$this->assertInstanceOf("\Twig_Environment", $doctrine->getDriver());
|
||||
@@ -58,7 +55,7 @@ class TwigTest extends PhraseanetPHPUnitAbstract
|
||||
public function testType()
|
||||
{
|
||||
$doctrine = new \Alchemy\Phrasea\Core\Service\TemplateEngine\Twig(
|
||||
self::$core, 'hello', $this->options
|
||||
self::$core, $this->options
|
||||
);
|
||||
|
||||
$this->assertEquals("twig", $doctrine->getType());
|
||||
|
@@ -28,7 +28,7 @@ class CacheBuilderTest extends PhraseanetPHPUnitAbstract
|
||||
|
||||
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");
|
||||
}
|
||||
catch (\Exception $e)
|
||||
@@ -43,7 +43,7 @@ class CacheBuilderTest extends PhraseanetPHPUnitAbstract
|
||||
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);
|
||||
}
|
||||
|
||||
|
@@ -28,7 +28,7 @@ class LogBuilderTest extends PhraseanetPHPUnitAbstract
|
||||
|
||||
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");
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ class LogBuilderTest extends PhraseanetPHPUnitAbstract
|
||||
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);
|
||||
}
|
||||
|
||||
|
@@ -28,7 +28,7 @@ class OrmBuilderTest extends PhraseanetPHPUnitAbstract
|
||||
|
||||
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");
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
@@ -28,7 +28,7 @@ class TemplateBuilderTest extends PhraseanetPHPUnitAbstract
|
||||
|
||||
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");
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
|
@@ -822,8 +822,7 @@ abstract class PhraseanetPHPUnitAbstract extends WebTestCase
|
||||
$confService = $configuration->getService($serviceName);
|
||||
|
||||
$templateService = \Alchemy\Phrasea\Core\Service\Builder::create(
|
||||
self::$core,
|
||||
$serviceName
|
||||
self::$core
|
||||
, $confService
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user