mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-18 15:33:15 +00:00
Update unit tests
This commit is contained in:
39
tests/Alchemy/Tests/Phrasea/Cache/FactoryTest.php
Normal file
39
tests/Alchemy/Tests/Phrasea/Cache/FactoryTest.php
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Alchemy\Tests\Phrasea\Cache;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Cache\Factory;
|
||||||
|
|
||||||
|
class FactoryTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @dataProvider provideCacheTypes
|
||||||
|
*/
|
||||||
|
public function testFactoryCreate($name, $extension, $expected)
|
||||||
|
{
|
||||||
|
if (null !== $extension && !extension_loaded($extension)) {
|
||||||
|
$this->markTestSkipped(sprintf('Extension %s is not loaded', $extension));
|
||||||
|
}
|
||||||
|
|
||||||
|
$factory = new Factory();
|
||||||
|
$this->assertInstanceOf($expected, $factory->create($name, array()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideCacheTypes()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array('apc', 'apc', 'Alchemy\Phrasea\Cache\ApcCache'),
|
||||||
|
array('apccache', 'apc', 'Alchemy\Phrasea\Cache\ApcCache'),
|
||||||
|
array('array', null, 'Alchemy\Phrasea\Cache\ArrayCache'),
|
||||||
|
array('arraycache', null, 'Alchemy\Phrasea\Cache\ArrayCache'),
|
||||||
|
array('memcache', 'memcache', 'Alchemy\Phrasea\Cache\MemcacheCache'),
|
||||||
|
array('memcachecache', 'memcache', 'Alchemy\Phrasea\Cache\MemcacheCache'),
|
||||||
|
array('redis', 'redis', 'Alchemy\Phrasea\Cache\RedisCache'),
|
||||||
|
array('rediscache', 'redis', 'Alchemy\Phrasea\Cache\RedisCache'),
|
||||||
|
array('wincache', 'wincache', 'Alchemy\Phrasea\Cache\WincacheCache'),
|
||||||
|
array('wincachecache', 'wincache', 'Alchemy\Phrasea\Cache\WincacheCache'),
|
||||||
|
array('xcache', 'xcache', 'Alchemy\Phrasea\Cache\XcacheCache'),
|
||||||
|
array('xcachecache', 'xcache', 'Alchemy\Phrasea\Cache\XcacheCache'),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
187
tests/Alchemy/Tests/Phrasea/Cache/ManagerTest.php
Normal file
187
tests/Alchemy/Tests/Phrasea/Cache/ManagerTest.php
Normal file
@@ -0,0 +1,187 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Alchemy\Tests\Phrasea\Cache;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Cache\Manager;
|
||||||
|
use Alchemy\Phrasea\Core\Configuration\Compiler;
|
||||||
|
use Alchemy\Phrasea\Exception\RuntimeException;
|
||||||
|
|
||||||
|
class ManagerTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
private $file;
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
$this->file = __DIR__ . '/tmp-file.php';
|
||||||
|
$this->compiler = new Compiler();
|
||||||
|
$this->clean();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tearDown()
|
||||||
|
{
|
||||||
|
$this->clean();
|
||||||
|
parent::tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function clean()
|
||||||
|
{
|
||||||
|
if (is_file($this->file)) {
|
||||||
|
unlink($this->file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function createEmptyRegistry()
|
||||||
|
{
|
||||||
|
file_put_contents($this->file, $this->compiler->compile(array()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testFactoryCreateOne()
|
||||||
|
{
|
||||||
|
$compiler = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration\Compiler')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$logger = $this->getMockBuilder('Monolog\Logger')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$factory = $this->getMockBuilder('Alchemy\Phrasea\Cache\Factory')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
$compiler->expects($this->once())
|
||||||
|
->method('compile');
|
||||||
|
|
||||||
|
$cache = $this->getMock('Alchemy\Phrasea\Cache\Cache');
|
||||||
|
|
||||||
|
$name = 'array';
|
||||||
|
$values = array('option', 'value');
|
||||||
|
|
||||||
|
$factory->expects($this->once())
|
||||||
|
->method('create')
|
||||||
|
->with($name, $values)
|
||||||
|
->will($this->returnValue($cache));
|
||||||
|
|
||||||
|
$this->createEmptyRegistry();
|
||||||
|
|
||||||
|
$manager = new Manager($compiler, $this->file, $logger, $factory);
|
||||||
|
$this->assertSame($cache, $manager->factory('custom-type', $name, $values));
|
||||||
|
$this->assertSame($cache, $manager->factory('custom-type', $name, $values));
|
||||||
|
$this->assertSame($cache, $manager->factory('custom-type', $name, $values));
|
||||||
|
$this->assertSame($cache, $manager->factory('custom-type', $name, $values));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testNoCompilationIfNoChange()
|
||||||
|
{
|
||||||
|
file_put_contents($this->file, $this->compiler->compile(array("custom-type" => "array")));
|
||||||
|
|
||||||
|
$compiler = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration\Compiler')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$logger = $this->getMockBuilder('Monolog\Logger')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$factory = $this->getMockBuilder('Alchemy\Phrasea\Cache\Factory')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
$compiler->expects($this->never())
|
||||||
|
->method('compile');
|
||||||
|
|
||||||
|
$cache = $this->getMock('Alchemy\Phrasea\Cache\Cache');
|
||||||
|
|
||||||
|
$name = 'array';
|
||||||
|
$values = array('option', 'value');
|
||||||
|
|
||||||
|
$factory->expects($this->once())
|
||||||
|
->method('create')
|
||||||
|
->with($name, $values)
|
||||||
|
->will($this->returnValue($cache));
|
||||||
|
|
||||||
|
$manager = new Manager($compiler, $this->file, $logger, $factory);
|
||||||
|
$this->assertSame($cache, $manager->factory('custom-type', $name, $values));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testNoCompilationIfNoChangeWithMultiple()
|
||||||
|
{
|
||||||
|
file_put_contents($this->file, $this->compiler->compile(array(
|
||||||
|
"custom-type" => "array",
|
||||||
|
"another-type" => "array",
|
||||||
|
"yet-another-type" => "array",
|
||||||
|
)));
|
||||||
|
|
||||||
|
$compiler = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration\Compiler')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$logger = $this->getMockBuilder('Monolog\Logger')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$factory = $this->getMockBuilder('Alchemy\Phrasea\Cache\Factory')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
$compiler->expects($this->never())
|
||||||
|
->method('compile');
|
||||||
|
|
||||||
|
$cache = $this->getMock('Alchemy\Phrasea\Cache\Cache');
|
||||||
|
|
||||||
|
$name = 'array';
|
||||||
|
$values = array('option', 'value');
|
||||||
|
|
||||||
|
$factory->expects($this->exactly(3))
|
||||||
|
->method('create')
|
||||||
|
->with($name, $values)
|
||||||
|
->will($this->returnValue($cache));
|
||||||
|
|
||||||
|
$manager = new Manager($compiler, $this->file, $logger, $factory);
|
||||||
|
$this->assertSame($cache, $manager->factory('custom-type', $name, $values));
|
||||||
|
$this->assertSame($cache, $manager->factory('another-type', $name, $values));
|
||||||
|
$this->assertSame($cache, $manager->factory('yet-another-type', $name, $values));
|
||||||
|
$this->assertSame($cache, $manager->factory('custom-type', $name, $values));
|
||||||
|
$this->assertSame($cache, $manager->factory('another-type', $name, $values));
|
||||||
|
$this->assertSame($cache, $manager->factory('yet-another-type', $name, $values));
|
||||||
|
$this->assertSame($cache, $manager->factory('custom-type', $name, $values));
|
||||||
|
$this->assertSame($cache, $manager->factory('another-type', $name, $values));
|
||||||
|
$this->assertSame($cache, $manager->factory('yet-another-type', $name, $values));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testUnknownCacheReturnsArrayCacheAndLogs()
|
||||||
|
{
|
||||||
|
file_put_contents($this->file, $this->compiler->compile(array(
|
||||||
|
"custom-type" => "unknown",
|
||||||
|
)));
|
||||||
|
|
||||||
|
$compiler = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration\Compiler')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$logger = $this->getMockBuilder('Monolog\Logger')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$factory = $this->getMockBuilder('Alchemy\Phrasea\Cache\Factory')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
$compiler->expects($this->never())
|
||||||
|
->method('compile');
|
||||||
|
|
||||||
|
$logger->expects($this->once())
|
||||||
|
->method('error');
|
||||||
|
|
||||||
|
$cache = $this->getMock('Alchemy\Phrasea\Cache\Cache');
|
||||||
|
|
||||||
|
$name = 'unknown';
|
||||||
|
$values = array('option', 'value');
|
||||||
|
|
||||||
|
$factory->expects($this->at(0))
|
||||||
|
->method('create')
|
||||||
|
->with($name, $values)
|
||||||
|
->will($this->throwException(new RuntimeException('Unknown cache type')));
|
||||||
|
|
||||||
|
$factory->expects($this->at(1))
|
||||||
|
->method('create')
|
||||||
|
->with('array', array())
|
||||||
|
->will($this->returnValue($cache));
|
||||||
|
|
||||||
|
$manager = new Manager($compiler, $this->file, $logger, $factory);
|
||||||
|
$this->assertSame($cache, $manager->factory('custom-type', $name, $values));
|
||||||
|
}
|
||||||
|
}
|
@@ -15,7 +15,7 @@ class MustacheLoaderTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
|
|
||||||
public function testRouteSlashWrongUrl()
|
public function testRouteSlashWrongUrl()
|
||||||
{
|
{
|
||||||
self::$DI['client']->request('GET', '/prod/MustacheLoader/', array('template' => '/../../../../config/config.yml'));
|
self::$DI['client']->request('GET', '/prod/MustacheLoader/', array('template' => '/../../../../config/configuration.yml'));
|
||||||
|
|
||||||
$this->assertBadResponse(self::$DI['client']->getResponse());
|
$this->assertBadResponse(self::$DI['client']->getResponse());
|
||||||
}
|
}
|
||||||
|
@@ -100,7 +100,7 @@ class UploadTest extends \PhraseanetWebTestCaseAuthenticatedAbstract
|
|||||||
if ($datas['element'] == 'record') {
|
if ($datas['element'] == 'record') {
|
||||||
$id = explode('_', $datas['id']);
|
$id = explode('_', $datas['id']);
|
||||||
|
|
||||||
$record = new \record_adapter($id[0], $id[1]);
|
$record = new \record_adapter(self::$DI['app'], $id[0], $id[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
namespace Alchemy\Tests\Phrasea\Controller\Utils;
|
namespace Alchemy\Tests\Phrasea\Controller\Utils;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Configuration;
|
|
||||||
|
|
||||||
class ControllerConnectionTestTest extends \PhraseanetWebTestCaseAbstract
|
class ControllerConnectionTestTest extends \PhraseanetWebTestCaseAbstract
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@@ -11,18 +9,14 @@ class ControllerConnectionTestTest extends \PhraseanetWebTestCaseAbstract
|
|||||||
*/
|
*/
|
||||||
public function testRouteMysql()
|
public function testRouteMysql()
|
||||||
{
|
{
|
||||||
$configuration = Configuration::build();
|
$connexion = self::$DI['app']['phraseanet.configuration']['main']['database'];
|
||||||
|
|
||||||
$chooseConnexion = $configuration->getPhraseanet()->get('database');
|
|
||||||
|
|
||||||
$connexion = $configuration->getConnexion($chooseConnexion);
|
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
"hostname" => $connexion->get('host'),
|
"hostname" => $connexion['host'],
|
||||||
"port" => $connexion->get('port'),
|
"port" => $connexion['port'],
|
||||||
"user" => $connexion->get('user'),
|
"user" => $connexion['user'],
|
||||||
"password" => $connexion->get('password'),
|
"password" => $connexion['password'],
|
||||||
"dbname" => $connexion->get('dbname')
|
"dbname" => $connexion['dbname'],
|
||||||
);
|
);
|
||||||
|
|
||||||
self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params);
|
self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params);
|
||||||
@@ -32,18 +26,14 @@ class ControllerConnectionTestTest extends \PhraseanetWebTestCaseAbstract
|
|||||||
|
|
||||||
public function testRouteMysqlFailed()
|
public function testRouteMysqlFailed()
|
||||||
{
|
{
|
||||||
$configuration = Configuration::build();
|
$connexion = self::$DI['app']['phraseanet.configuration']['main']['database'];
|
||||||
|
|
||||||
$chooseConnexion = $configuration->getPhraseanet()->get('database');
|
|
||||||
|
|
||||||
$connexion = $configuration->getConnexion($chooseConnexion);
|
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
"hostname" => $connexion->get('host'),
|
"hostname" => $connexion['host'],
|
||||||
"port" => $connexion->get('port'),
|
"port" => $connexion['port'],
|
||||||
"user" => $connexion->get('user'),
|
"user" => $connexion['user'],
|
||||||
"password" => "fakepassword",
|
"password" => "fakepassword",
|
||||||
"dbname" => $connexion->get('dbname')
|
"dbname" => $connexion['dbname'],
|
||||||
);
|
);
|
||||||
|
|
||||||
self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params);
|
self::$DI['client']->request("GET", "/admin/tests/connection/mysql/", $params);
|
||||||
@@ -62,17 +52,13 @@ class ControllerConnectionTestTest extends \PhraseanetWebTestCaseAbstract
|
|||||||
|
|
||||||
public function testRouteMysqlDbFailed()
|
public function testRouteMysqlDbFailed()
|
||||||
{
|
{
|
||||||
$configuration = Configuration::build();
|
$connexion = self::$DI['app']['phraseanet.configuration']['main']['database'];
|
||||||
|
|
||||||
$chooseConnexion = $configuration->getPhraseanet()->get('database');
|
|
||||||
|
|
||||||
$connexion = $configuration->getConnexion($chooseConnexion);
|
|
||||||
|
|
||||||
$params = array(
|
$params = array(
|
||||||
"hostname" => $connexion->get('host'),
|
"hostname" => $connexion['host'],
|
||||||
"port" => $connexion->get('port'),
|
"port" => $connexion['port'],
|
||||||
"user" => $connexion->get('user'),
|
"user" => $connexion['user'],
|
||||||
"password" => $connexion->get('password'),
|
"password" => $connexion['password'],
|
||||||
"dbname" => "fake-DTABASE-name"
|
"dbname" => "fake-DTABASE-name"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -0,0 +1,54 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Alchemy\Tests\Phrasea\Core\Configuration;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Core\Configuration\Compiler;
|
||||||
|
|
||||||
|
class CompilerTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @dataProvider provideDataToCompile
|
||||||
|
*/
|
||||||
|
public function testCompile($data)
|
||||||
|
{
|
||||||
|
$compiler = new Compiler();
|
||||||
|
|
||||||
|
$compiled = $compiler->compile($data);
|
||||||
|
$this->assertInternalType("string", $compiled);
|
||||||
|
$this->assertSame(0, strpos($compiled, "<?php\nreturn array("));
|
||||||
|
$result = eval('?>'.$compiled);
|
||||||
|
|
||||||
|
$this->assertSame($data, $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCompileWithObject()
|
||||||
|
{
|
||||||
|
$compiler = new Compiler();
|
||||||
|
|
||||||
|
$class = new \stdClass();
|
||||||
|
$class->key = 'value';
|
||||||
|
|
||||||
|
$data = array(
|
||||||
|
'key' => $class,
|
||||||
|
'key2' => 'boum',
|
||||||
|
);
|
||||||
|
|
||||||
|
$compiled = $compiler->compile($data);
|
||||||
|
$this->assertInternalType("string", $compiled);
|
||||||
|
$this->assertSame(0, strpos($compiled, "<?php\nreturn array("));
|
||||||
|
$result = eval('?>'.$compiled);
|
||||||
|
|
||||||
|
$this->assertSame(array('key' => array('key' => 'value'), 'key2' => 'boum'), $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function provideDataToCompile()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array(array()),
|
||||||
|
array(array('key' => array('value1', 'value2', 'booleantrue' => true, 'booleanfalse' => false), array('gizmo'))),
|
||||||
|
array(array(array(array()))),
|
||||||
|
array(array('key' => 'value', "associativeint" => 12345, 34567)),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@@ -0,0 +1,316 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Alchemy\Tests\Phrasea\Core\Configuration;
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Core\Configuration\Configuration;
|
||||||
|
use Alchemy\Phrasea\Core\Configuration\Compiler;
|
||||||
|
use Symfony\Component\Yaml\Yaml;
|
||||||
|
|
||||||
|
class ConfigurationTest extends \PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
private $compiled;
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
$this->compiled = __DIR__ . '/Fixtures/configuration-compiled.php';
|
||||||
|
$this->clean();
|
||||||
|
copy(__DIR__ . '/..' . Configuration::CONFIG_REF, __DIR__ . '/Fixtures/configuration.yml');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tearDown()
|
||||||
|
{
|
||||||
|
$this->clean();
|
||||||
|
parent::tearDown();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function clean()
|
||||||
|
{
|
||||||
|
if (is_file($this->compiled)) {
|
||||||
|
unlink($this->compiled);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException Alchemy\Phrasea\Exception\RuntimeException
|
||||||
|
*/
|
||||||
|
public function testGetConfigInvalidConfig()
|
||||||
|
{
|
||||||
|
$config = __DIR__ . '/Fixtures/configuration-unknown.yml';
|
||||||
|
$compiled = $this->compiled;
|
||||||
|
|
||||||
|
$yaml = new Yaml();
|
||||||
|
$compiler = new Compiler();
|
||||||
|
|
||||||
|
$conf = new Configuration($yaml, $compiler, $config, $compiled, false);
|
||||||
|
$conf->getConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testInitialize()
|
||||||
|
{
|
||||||
|
$configFile = __DIR__ . '/Fixtures/configuration-unknown.yml';
|
||||||
|
|
||||||
|
if (is_file($configFile)) {
|
||||||
|
unlink($configFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
$compiled = $this->compiled;
|
||||||
|
|
||||||
|
$yaml = new Yaml();
|
||||||
|
$compiler = new Compiler();
|
||||||
|
|
||||||
|
$conf = new Configuration($yaml, $compiler, $configFile, $compiled, false);
|
||||||
|
$config = $conf->initialize();
|
||||||
|
|
||||||
|
$this->assertArrayHasKey('main', $config);
|
||||||
|
$this->assertFileExists($compiled);
|
||||||
|
$this->assertFileExists($configFile);
|
||||||
|
|
||||||
|
unlink($configFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException Alchemy\Phrasea\Exception\RuntimeException
|
||||||
|
*/
|
||||||
|
public function testInitializeWrongPath()
|
||||||
|
{
|
||||||
|
$configFile = __DIR__ . '/Fixtures/configuration.yml';
|
||||||
|
$compiled = __DIR__ . '/path/to/unknwon/folder/file.php';
|
||||||
|
|
||||||
|
$yaml = new Yaml();
|
||||||
|
$compiler = new Compiler();
|
||||||
|
|
||||||
|
$conf = new Configuration($yaml, $compiler, $configFile, $compiled, false);
|
||||||
|
$conf->initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testArrayAccess()
|
||||||
|
{
|
||||||
|
$config = __DIR__ . '/Fixtures/configuration.yml';
|
||||||
|
$compiled = $this->compiled;
|
||||||
|
|
||||||
|
$compiler = new Compiler();
|
||||||
|
$yaml = new Yaml();
|
||||||
|
|
||||||
|
$conf = new Configuration($yaml, $compiler, $config, $compiled, false);
|
||||||
|
$this->assertEquals('127.0.0.1', $conf['main']['database']['host']);
|
||||||
|
|
||||||
|
$conf['extra-key'] = 'extra-value';
|
||||||
|
$this->assertEquals('extra-value', $conf['extra-key']);
|
||||||
|
|
||||||
|
$updated = $yaml->parse($config);
|
||||||
|
$this->assertEquals('extra-value', $updated['extra-key']);
|
||||||
|
|
||||||
|
$this->assertTrue(isset($conf['extra-key']));
|
||||||
|
unset($conf['extra-key']);
|
||||||
|
$this->assertFalse(isset($conf['extra-key']));
|
||||||
|
|
||||||
|
$updated = $yaml->parse($config);
|
||||||
|
$this->assertFalse(isset($updated['extra-key']));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDelete()
|
||||||
|
{
|
||||||
|
$config = __DIR__ . '/Fixtures/configuration.yml';
|
||||||
|
$compiled = $this->compiled;
|
||||||
|
|
||||||
|
$yaml = new Yaml();
|
||||||
|
$compiler = new Compiler();
|
||||||
|
|
||||||
|
$conf = new Configuration($yaml, $compiler, $config, $compiled, false);
|
||||||
|
$conf->initialize();
|
||||||
|
$conf->delete();
|
||||||
|
$this->assertFileNotExists($compiled);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testIsSetup()
|
||||||
|
{
|
||||||
|
$config = __DIR__ . '/Fixtures/configuration-setup.yml';
|
||||||
|
$compiled = $this->compiled;
|
||||||
|
|
||||||
|
@unlink($config);
|
||||||
|
|
||||||
|
$compiler = new Compiler();
|
||||||
|
$yaml = new Yaml();
|
||||||
|
|
||||||
|
$conf = new Configuration($yaml, $compiler, $config, $compiled, false);
|
||||||
|
$this->assertFalse($conf->isSetup());
|
||||||
|
$conf->initialize();
|
||||||
|
$this->assertTrue($conf->isSetup());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSetdefault()
|
||||||
|
{
|
||||||
|
$configFile = __DIR__ . '/Fixtures/configuration.yml';
|
||||||
|
$compiled = $this->compiled;
|
||||||
|
|
||||||
|
$compiler = new Compiler();
|
||||||
|
$yaml = new Yaml();
|
||||||
|
|
||||||
|
$conf = new Configuration($yaml, $compiler, $configFile, $compiled, false);
|
||||||
|
$conf->initialize();
|
||||||
|
$config = $conf->getConfig();
|
||||||
|
unset($config['main']);
|
||||||
|
$conf->setConfig($config);
|
||||||
|
|
||||||
|
$updated = $yaml->parse($configFile);
|
||||||
|
$this->assertFalse(isset($updated['main']));
|
||||||
|
|
||||||
|
$conf->setDefault('main');
|
||||||
|
|
||||||
|
$updated = $yaml->parse($configFile);
|
||||||
|
$this->assertTrue(isset($updated['main']));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSetdefaultRecursive()
|
||||||
|
{
|
||||||
|
$configFile = __DIR__ . '/Fixtures/configuration.yml';
|
||||||
|
$compiled = $this->compiled;
|
||||||
|
|
||||||
|
$compiler = new Compiler();
|
||||||
|
$yaml = new Yaml();
|
||||||
|
|
||||||
|
$conf = new Configuration($yaml, $compiler, $configFile, $compiled, false);
|
||||||
|
$conf->initialize();
|
||||||
|
$config = $conf->getConfig();
|
||||||
|
unset($config['main']['cache']);
|
||||||
|
$conf->setConfig($config);
|
||||||
|
|
||||||
|
$updated = $yaml->parse($configFile);
|
||||||
|
$this->assertFalse(isset($updated['main']['cache']));
|
||||||
|
|
||||||
|
$conf->setDefault('main', 'cache');
|
||||||
|
|
||||||
|
$updated = $yaml->parse($configFile);
|
||||||
|
$this->assertTrue(isset($updated['main']['cache']));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @expectedException Alchemy\Phrasea\Exception\InvalidArgumentException
|
||||||
|
*/
|
||||||
|
public function testSetdefaultInvalidKey()
|
||||||
|
{
|
||||||
|
$configFile = __DIR__ . '/Fixtures/configuration.yml';
|
||||||
|
$compiled = $this->compiled;
|
||||||
|
|
||||||
|
$compiler = new Compiler();
|
||||||
|
$yaml = new Yaml();
|
||||||
|
|
||||||
|
$conf = new Configuration($yaml, $compiler, $configFile, $compiled, false);
|
||||||
|
$conf->setDefault('unexistant key');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetConfig()
|
||||||
|
{
|
||||||
|
$configFile = __DIR__ . '/Fixtures/configuration.yml';
|
||||||
|
$compiled = $this->compiled;
|
||||||
|
|
||||||
|
$compiler = new Compiler();
|
||||||
|
$yaml = new Yaml();
|
||||||
|
|
||||||
|
$conf = new Configuration($yaml, $compiler, $configFile, $compiled, false);
|
||||||
|
$conf->initialize();
|
||||||
|
|
||||||
|
$updated = $yaml->parse(file_get_contents($configFile));
|
||||||
|
$this->assertEquals($updated, $conf->getConfig());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testSetConfig()
|
||||||
|
{
|
||||||
|
$configFile = __DIR__ . '/Fixtures/configuration.yml';
|
||||||
|
$compiled = $this->compiled;
|
||||||
|
|
||||||
|
$compiler = new Compiler();
|
||||||
|
$yaml = new Yaml();
|
||||||
|
|
||||||
|
$conf = new Configuration($yaml, $compiler, $configFile, $compiled, false);
|
||||||
|
$conf->setConfig(array('main' => 'boule'));
|
||||||
|
|
||||||
|
$updated = $yaml->parse(file_get_contents($configFile));
|
||||||
|
$this->assertEquals(array('main' => 'boule'), $conf->getConfig());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCompilNever()
|
||||||
|
{
|
||||||
|
$configFile = __DIR__ . '/Fixtures/configuration.yml';
|
||||||
|
$compiled = $this->compiled;
|
||||||
|
|
||||||
|
$yaml = new Yaml();
|
||||||
|
$compiler = new Compiler();
|
||||||
|
file_put_contents($this->compiled, $compiler->compile($yaml->parse($configFile)));
|
||||||
|
|
||||||
|
$compiler = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration\Compiler')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$compiler->expects($this->never())
|
||||||
|
->method('compile');
|
||||||
|
|
||||||
|
$yaml = $this->getMockBuilder('Symfony\Component\Yaml\Yaml')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$yaml::staticExpects($this->never())
|
||||||
|
->method('parse');
|
||||||
|
|
||||||
|
$conf = new Configuration($yaml, $compiler, $configFile, $compiled, false);
|
||||||
|
$conf->getConfig();
|
||||||
|
$conf->getConfig();
|
||||||
|
$conf->getConfig();
|
||||||
|
$conf['main'];
|
||||||
|
$conf['main'];
|
||||||
|
$conf['main'];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testCompilInDebugMode()
|
||||||
|
{
|
||||||
|
$configFile = __DIR__ . '/Fixtures/configuration.yml';
|
||||||
|
$compiled = $this->compiled;
|
||||||
|
|
||||||
|
$yaml = new Yaml();
|
||||||
|
$compiler = new Compiler();
|
||||||
|
file_put_contents($this->compiled, $compiler->compile($yaml->parse($configFile)));
|
||||||
|
|
||||||
|
// compilation is older than config
|
||||||
|
touch($this->compiled, time()-2);
|
||||||
|
touch($configFile, time()-1);
|
||||||
|
clearstatcache();
|
||||||
|
|
||||||
|
$compiler = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration\Compiler')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$compiler->expects($this->once())
|
||||||
|
->method('compile')
|
||||||
|
->with(array('main' => 'tiptop'))
|
||||||
|
->will($this->returnValue('<?php return array("main" => "tiptop");'));
|
||||||
|
|
||||||
|
$yaml = $this->getMockBuilder('Symfony\Component\Yaml\Yaml')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
$yaml::staticExpects($this->once())
|
||||||
|
->method('parse')
|
||||||
|
->will($this->returnValue(array('main' => 'tiptop')));
|
||||||
|
|
||||||
|
$conf = new Configuration($yaml, $compiler, $configFile, $compiled, true);
|
||||||
|
$this->assertSame(array('main' => 'tiptop'), $conf->getConfig());
|
||||||
|
$this->assertSame(array('main' => 'tiptop'), $conf->getConfig());
|
||||||
|
$this->assertSame(array('main' => 'tiptop'), $conf->getConfig());
|
||||||
|
$this->assertSame('tiptop', $conf['main']);
|
||||||
|
$this->assertSame('tiptop', $conf['main']);
|
||||||
|
$this->assertSame('tiptop', $conf['main']);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetTestConnectionConf()
|
||||||
|
{
|
||||||
|
$configFile = __DIR__ . '/Fixtures/configuration.yml';
|
||||||
|
$compiled = $this->compiled;
|
||||||
|
|
||||||
|
$yaml = new Yaml();
|
||||||
|
$compiler = new Compiler();
|
||||||
|
|
||||||
|
$conf = new Configuration($yaml, $compiler, $configFile, $compiled, true);
|
||||||
|
$data = $conf->getTestConnectionParameters();
|
||||||
|
|
||||||
|
$this->assertArrayHasKey('driver', $data);
|
||||||
|
$this->assertArrayHasKey('path', $data);
|
||||||
|
$this->assertArrayHasKey('charset', $data);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,113 @@
|
|||||||
|
main:
|
||||||
|
servername: 'http://local.phrasea/'
|
||||||
|
maintenance: false
|
||||||
|
database:
|
||||||
|
host: 127.0.0.1
|
||||||
|
port: '3306'
|
||||||
|
user: root
|
||||||
|
password: ''
|
||||||
|
dbname: ab_test
|
||||||
|
driver: pdo_mysql
|
||||||
|
charset: UTF8
|
||||||
|
database-test:
|
||||||
|
driver: pdo_sqlite
|
||||||
|
path: '/tmp/db.sqlite'
|
||||||
|
charset: UTF8
|
||||||
|
api-timers: true
|
||||||
|
cache:
|
||||||
|
type: MemcacheCache
|
||||||
|
options:
|
||||||
|
host: localhost
|
||||||
|
port: 11211
|
||||||
|
opcodecache:
|
||||||
|
type: ArrayCache
|
||||||
|
options: []
|
||||||
|
search-engine:
|
||||||
|
type: Alchemy\Phrasea\SearchEngine\Phrasea\PhraseaEngine
|
||||||
|
options: []
|
||||||
|
task-manager:
|
||||||
|
options: null
|
||||||
|
binaries: []
|
||||||
|
border-manager:
|
||||||
|
enabled: true
|
||||||
|
checkers:
|
||||||
|
-
|
||||||
|
type: Checker\Sha256
|
||||||
|
enabled: true
|
||||||
|
-
|
||||||
|
type: Checker\UUID
|
||||||
|
enabled: true
|
||||||
|
-
|
||||||
|
type: Checker\Colorspace
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
colorspaces: [cmyk, grayscale, rgb]
|
||||||
|
-
|
||||||
|
type: Checker\Dimension
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
width: 80
|
||||||
|
height: 160
|
||||||
|
-
|
||||||
|
type: Checker\Extension
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
extensions: [jpg, jpeg, bmp, tif, gif, png, pdf, doc, odt, mpg, mpeg, mov, avi, xls, flv, mp3, mp2]
|
||||||
|
-
|
||||||
|
type: Checker\Filename
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
sensitive: true
|
||||||
|
-
|
||||||
|
type: Checker\MediaType
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
mediatypes: [Audio, Document, Flash, Image, Video]
|
||||||
|
authentication:
|
||||||
|
auto-create:
|
||||||
|
enabled: false
|
||||||
|
templates: { }
|
||||||
|
captcha:
|
||||||
|
enabled: true
|
||||||
|
trials-before-failure: 9
|
||||||
|
providers:
|
||||||
|
facebook:
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
app-id: ''
|
||||||
|
secret: ''
|
||||||
|
twitter:
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
consumer-key: ''
|
||||||
|
consumer-secret: ''
|
||||||
|
google-plus:
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
client-id: ''
|
||||||
|
client-secret: ''
|
||||||
|
github:
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
client-id: ''
|
||||||
|
client-secret: ''
|
||||||
|
viadeo:
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
client-id: ''
|
||||||
|
client-secret: ''
|
||||||
|
linkedin:
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
client-id: ''
|
||||||
|
client-secret: ''
|
||||||
|
registration-fields:
|
||||||
|
-
|
||||||
|
name: company
|
||||||
|
required: true
|
||||||
|
-
|
||||||
|
name: firstname
|
||||||
|
required: true
|
||||||
|
-
|
||||||
|
name: geonameid
|
||||||
|
required: true
|
@@ -0,0 +1,113 @@
|
|||||||
|
main:
|
||||||
|
servername: 'http://local.phrasea/'
|
||||||
|
maintenance: false
|
||||||
|
database:
|
||||||
|
host: 127.0.0.1
|
||||||
|
port: '3306'
|
||||||
|
user: root
|
||||||
|
password: ''
|
||||||
|
dbname: ab_test
|
||||||
|
driver: pdo_mysql
|
||||||
|
charset: UTF8
|
||||||
|
database-test:
|
||||||
|
driver: pdo_sqlite
|
||||||
|
path: '/tmp/db.sqlite'
|
||||||
|
charset: UTF8
|
||||||
|
api-timers: true
|
||||||
|
cache:
|
||||||
|
type: MemcacheCache
|
||||||
|
options:
|
||||||
|
host: localhost
|
||||||
|
port: 11211
|
||||||
|
opcodecache:
|
||||||
|
type: ArrayCache
|
||||||
|
options: []
|
||||||
|
search-engine:
|
||||||
|
type: Alchemy\Phrasea\SearchEngine\Phrasea\PhraseaEngine
|
||||||
|
options: []
|
||||||
|
task-manager:
|
||||||
|
options: null
|
||||||
|
binaries: []
|
||||||
|
border-manager:
|
||||||
|
enabled: true
|
||||||
|
checkers:
|
||||||
|
-
|
||||||
|
type: Checker\Sha256
|
||||||
|
enabled: true
|
||||||
|
-
|
||||||
|
type: Checker\UUID
|
||||||
|
enabled: true
|
||||||
|
-
|
||||||
|
type: Checker\Colorspace
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
colorspaces: [cmyk, grayscale, rgb]
|
||||||
|
-
|
||||||
|
type: Checker\Dimension
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
width: 80
|
||||||
|
height: 160
|
||||||
|
-
|
||||||
|
type: Checker\Extension
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
extensions: [jpg, jpeg, bmp, tif, gif, png, pdf, doc, odt, mpg, mpeg, mov, avi, xls, flv, mp3, mp2]
|
||||||
|
-
|
||||||
|
type: Checker\Filename
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
sensitive: true
|
||||||
|
-
|
||||||
|
type: Checker\MediaType
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
mediatypes: [Audio, Document, Flash, Image, Video]
|
||||||
|
authentication:
|
||||||
|
auto-create:
|
||||||
|
enabled: false
|
||||||
|
templates: { }
|
||||||
|
captcha:
|
||||||
|
enabled: true
|
||||||
|
trials-before-failure: 9
|
||||||
|
providers:
|
||||||
|
facebook:
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
app-id: ''
|
||||||
|
secret: ''
|
||||||
|
twitter:
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
consumer-key: ''
|
||||||
|
consumer-secret: ''
|
||||||
|
google-plus:
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
client-id: ''
|
||||||
|
client-secret: ''
|
||||||
|
github:
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
client-id: ''
|
||||||
|
client-secret: ''
|
||||||
|
viadeo:
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
client-id: ''
|
||||||
|
client-secret: ''
|
||||||
|
linkedin:
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
client-id: ''
|
||||||
|
client-secret: ''
|
||||||
|
registration-fields:
|
||||||
|
-
|
||||||
|
name: company
|
||||||
|
required: true
|
||||||
|
-
|
||||||
|
name: firstname
|
||||||
|
required: true
|
||||||
|
-
|
||||||
|
name: geonameid
|
||||||
|
required: true
|
@@ -1,702 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Alchemy\Tests\Phrasea\Core;
|
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Configuration;
|
|
||||||
use Alchemy\Phrasea\Exception\InvalidArgumentException;
|
|
||||||
use Alchemy\Phrasea\Exception\RuntimeException;
|
|
||||||
use Symfony\Component\DependencyInjection\Exception\ParameterNotFoundException;
|
|
||||||
|
|
||||||
class ConfigurationTest extends \PHPUnit_Framework_TestCase
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::build
|
|
||||||
*/
|
|
||||||
public function testBuild()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('dev' => array()));
|
|
||||||
|
|
||||||
$configuration = Configuration::build($specifications, 'dev');
|
|
||||||
|
|
||||||
$this->assertEquals('dev', $configuration->getEnvironnement());
|
|
||||||
$this->assertEquals($specifications, $configuration->getSpecifications());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @test
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::build
|
|
||||||
*/
|
|
||||||
public function buildShouldFailIfTheRequiredEnvironmentDoesNotExist()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('prod' => array()));
|
|
||||||
|
|
||||||
try {
|
|
||||||
Configuration::build($specifications, 'dev');
|
|
||||||
$this->fail('Should have raised an exception');
|
|
||||||
} catch (InvalidArgumentException $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @test
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::build
|
|
||||||
*/
|
|
||||||
public function environmentShouldBeNullIsTheSpecsAreNotSetup()
|
|
||||||
{
|
|
||||||
$specifications = $this->getNotSetupedSpecifications();
|
|
||||||
$configuration = Configuration::build($specifications, 'dev');
|
|
||||||
|
|
||||||
$this->assertNull($configuration->getEnvironnement());
|
|
||||||
$this->assertEquals($specifications, $configuration->getSpecifications());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::get
|
|
||||||
*/
|
|
||||||
public function testGet()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('dev' => array('pif' => 'pouf')));
|
|
||||||
$configuration = Configuration::build($specifications, 'dev');
|
|
||||||
|
|
||||||
$this->assertEquals('pouf', $configuration->get('pif'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::get
|
|
||||||
*/
|
|
||||||
public function testGetOnNonExistentParameterShouldFail()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('dev' => array('pif' => 'pouf')));
|
|
||||||
$configuration = Configuration::build($specifications, 'dev');
|
|
||||||
|
|
||||||
try {
|
|
||||||
$configuration->get('paf');
|
|
||||||
$this->fail('Should have raised an exception');
|
|
||||||
} catch (ParameterNotFoundException $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::has
|
|
||||||
*/
|
|
||||||
public function testHas()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('dev' => array('pif' => 'pouf')));
|
|
||||||
$configuration = Configuration::build($specifications, 'dev');
|
|
||||||
|
|
||||||
$this->assertTrue($configuration->has('pif'));
|
|
||||||
$this->assertFalse($configuration->has('paf'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @test
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::build
|
|
||||||
*/
|
|
||||||
public function defaultEnvironmentShouldBeTheOneInTheEnvironmentKey()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('environment' => 'dave', 'dave' => array('pif' => 'pouf')));
|
|
||||||
$configuration = Configuration::build($specifications);
|
|
||||||
|
|
||||||
$this->assertEquals('dave', $configuration->getEnvironnement());
|
|
||||||
$this->assertEquals($specifications, $configuration->getSpecifications());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @test
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::build
|
|
||||||
*/
|
|
||||||
public function anErrorShouldBeThrownIfNoEnvironmentProvided()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('dave' => array('pif' => 'pouf')));
|
|
||||||
|
|
||||||
try {
|
|
||||||
Configuration::build($specifications);
|
|
||||||
$this->fail('Should have raised an exception');
|
|
||||||
} catch (RuntimeException $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::setEnvironnement
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::getEnvironnement
|
|
||||||
*/
|
|
||||||
public function testSetEnvironnementShouldSetTheEnvironment()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('dev' => array('pif' => 'pouf'), 'prod' => array('bim' => 'bame')));
|
|
||||||
$configuration = Configuration::build($specifications, 'dev');
|
|
||||||
|
|
||||||
$this->assertEquals('dev', $configuration->getEnvironnement());
|
|
||||||
$this->assertTrue($configuration->has('pif'));
|
|
||||||
$this->assertFalse($configuration->has('bim'));
|
|
||||||
|
|
||||||
$configuration->setEnvironnement('prod');
|
|
||||||
$this->assertEquals('prod', $configuration->getEnvironnement());
|
|
||||||
$this->assertFalse($configuration->has('pif'));
|
|
||||||
$this->assertTrue($configuration->has('bim'));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::setEnvironnement
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::getEnvironnement
|
|
||||||
*/
|
|
||||||
public function testSetEnvironnementShouldThrowAnExceptionIfEnvironmentDoesNotExists()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('dev' => array('pif' => 'pouf'), 'prod' => array('bim' => 'bame')));
|
|
||||||
$configuration = Configuration::build($specifications, 'dev');
|
|
||||||
|
|
||||||
try {
|
|
||||||
$configuration->setEnvironnement('test');
|
|
||||||
$this->fail('Should have raised an exception');
|
|
||||||
} catch (InvalidArgumentException $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::getEnvironnement
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::setEnvironnement
|
|
||||||
*/
|
|
||||||
public function testSetEnvironnementWhenSetupNotReadyShouldAlwaysWork()
|
|
||||||
{
|
|
||||||
$specifications = $this->getNotSetupedSpecifications();
|
|
||||||
$configuration = Configuration::build($specifications, 'dev');
|
|
||||||
|
|
||||||
$configuration->setEnvironnement('prout');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::isDebug
|
|
||||||
*/
|
|
||||||
public function testIsDebugIsFalseWhileSetup()
|
|
||||||
{
|
|
||||||
$specifications = $this->getNotSetupedSpecifications();
|
|
||||||
$configuration = Configuration::build($specifications);
|
|
||||||
|
|
||||||
$this->assertFalse($configuration->isDebug());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::isDebug
|
|
||||||
*/
|
|
||||||
public function testIsDebugIsFalseByDefault()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('dev' => array()));
|
|
||||||
$configuration = Configuration::build($specifications, 'dev');
|
|
||||||
|
|
||||||
$this->assertFalse($configuration->isDebug());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::isDebug
|
|
||||||
*/
|
|
||||||
public function testIsDebug()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('dev' => array('phraseanet' => array('debug' => true))));
|
|
||||||
$configuration = Configuration::build($specifications, 'dev');
|
|
||||||
|
|
||||||
$this->assertTrue($configuration->isDebug());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::isMaintained
|
|
||||||
*/
|
|
||||||
public function testIsMaintainedIsFalseWhileSetup()
|
|
||||||
{
|
|
||||||
$specifications = $this->getNotSetupedSpecifications();
|
|
||||||
$configuration = Configuration::build($specifications);
|
|
||||||
|
|
||||||
$this->assertFalse($configuration->isMaintained());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::isMaintained
|
|
||||||
*/
|
|
||||||
public function testIsMaintainedIsFalseByDefault()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('dev' => array()));
|
|
||||||
$configuration = Configuration::build($specifications, 'dev');
|
|
||||||
|
|
||||||
$this->assertFalse($configuration->isMaintained());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::isMaintained
|
|
||||||
*/
|
|
||||||
public function testIsMaintained()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('dev' => array('phraseanet' => array('maintenance' => true))));
|
|
||||||
$configuration = Configuration::build($specifications, 'dev');
|
|
||||||
|
|
||||||
$this->assertTrue($configuration->isMaintained());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::isDisplayingErrors
|
|
||||||
*/
|
|
||||||
public function testIsDisplayingErrorsIsFalseWhileSetup()
|
|
||||||
{
|
|
||||||
$specifications = $this->getNotSetupedSpecifications();
|
|
||||||
$configuration = Configuration::build($specifications);
|
|
||||||
|
|
||||||
$this->assertFalse($configuration->isDisplayingErrors());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::isDisplayingErrors
|
|
||||||
*/
|
|
||||||
public function testIsDisplayingErrorsIsFalseByDefault()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('dev' => array()));
|
|
||||||
$configuration = Configuration::build($specifications, 'dev');
|
|
||||||
|
|
||||||
$this->assertFalse($configuration->isDisplayingErrors());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::isDisplayingErrors
|
|
||||||
*/
|
|
||||||
public function testIsDisplayingErrors()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('dev' => array('phraseanet' => array('display_errors' => true))));
|
|
||||||
$configuration = Configuration::build($specifications, 'dev');
|
|
||||||
|
|
||||||
$this->assertTrue($configuration->isDisplayingErrors());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::getPhraseanet
|
|
||||||
*/
|
|
||||||
public function testGetPhraseanet()
|
|
||||||
{
|
|
||||||
$phraseanet = array('display_errors' => true);
|
|
||||||
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('dev' => array('phraseanet' => $phraseanet)));
|
|
||||||
$configuration = Configuration::build($specifications, 'dev');
|
|
||||||
|
|
||||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\ParameterBag\ParameterBag', $configuration->getPhraseanet());
|
|
||||||
$this->assertEquals($phraseanet, $configuration->getPhraseanet()->all());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::initialize
|
|
||||||
*/
|
|
||||||
public function testInitialize()
|
|
||||||
{
|
|
||||||
$specifications = $this->getNotSetupedSpecifications();
|
|
||||||
$specifications->expects($this->once())
|
|
||||||
->method('initialize');
|
|
||||||
|
|
||||||
$configuration = Configuration::build($specifications);
|
|
||||||
$configuration->initialize();
|
|
||||||
|
|
||||||
$this->assertEquals('prod', $configuration->getEnvironnement());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::delete
|
|
||||||
*/
|
|
||||||
public function testDelete()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('prod' => array()));
|
|
||||||
$specifications->expects($this->once())
|
|
||||||
->method('delete');
|
|
||||||
|
|
||||||
$configuration = Configuration::build($specifications, 'prod');
|
|
||||||
$configuration->delete();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::setConfigurations
|
|
||||||
*/
|
|
||||||
public function testSetConfigurations()
|
|
||||||
{
|
|
||||||
$conf = array('prod' => array('bim' => 'boum'));
|
|
||||||
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('prod' => array()));
|
|
||||||
$specifications->expects($this->once())
|
|
||||||
->method('setConfigurations')
|
|
||||||
->with($this->equalTo($conf));
|
|
||||||
|
|
||||||
$configuration = Configuration::build($specifications, 'prod');
|
|
||||||
$configuration->setConfigurations($conf);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::setServices
|
|
||||||
*/
|
|
||||||
public function testSetServices()
|
|
||||||
{
|
|
||||||
$services = array('Template' => array());
|
|
||||||
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('prod' => array()));
|
|
||||||
$specifications->expects($this->once())
|
|
||||||
->method('setServices')
|
|
||||||
->with($this->equalTo($services));
|
|
||||||
|
|
||||||
$configuration = Configuration::build($specifications, 'prod');
|
|
||||||
$configuration->setServices($services);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::resetServices
|
|
||||||
*/
|
|
||||||
public function testResetAllServices()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('prod' => array()));
|
|
||||||
$specifications->expects($this->once())
|
|
||||||
->method('resetServices')
|
|
||||||
->with($this->equalTo(null));
|
|
||||||
|
|
||||||
$configuration = Configuration::build($specifications, 'prod');
|
|
||||||
$configuration->resetServices();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::resetServices
|
|
||||||
*/
|
|
||||||
public function testResetByName()
|
|
||||||
{
|
|
||||||
$name = 'coool-service';
|
|
||||||
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('prod' => array()));
|
|
||||||
$specifications->expects($this->once())
|
|
||||||
->method('resetServices')
|
|
||||||
->with($this->equalTo($name));
|
|
||||||
|
|
||||||
$configuration = Configuration::build($specifications, 'prod');
|
|
||||||
$configuration->resetServices($name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::setBinaries
|
|
||||||
*/
|
|
||||||
public function testSetBinaries()
|
|
||||||
{
|
|
||||||
$binaries = array('binarie' => array('php' => '/usr/local/bin/php'));
|
|
||||||
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('prod' => array()));
|
|
||||||
$specifications->expects($this->once())
|
|
||||||
->method('setBinaries')
|
|
||||||
->with($this->equalTo($binaries));
|
|
||||||
|
|
||||||
$configuration = Configuration::build($specifications, 'prod');
|
|
||||||
$configuration->setBinaries($binaries);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::setConnexions
|
|
||||||
*/
|
|
||||||
public function testSetConnexions()
|
|
||||||
{
|
|
||||||
$connexions = array('main' => array('path' => '/usr/local/db'));
|
|
||||||
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('prod' => array()));
|
|
||||||
$specifications->expects($this->once())
|
|
||||||
->method('setConnexions')
|
|
||||||
->with($this->equalTo($connexions));
|
|
||||||
|
|
||||||
$configuration = Configuration::build($specifications, 'prod');
|
|
||||||
$configuration->setConnexions($connexions);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::getConfigurations
|
|
||||||
*/
|
|
||||||
public function testGetConfigurations()
|
|
||||||
{
|
|
||||||
$specifications = $this->getNotSetupedSpecifications();
|
|
||||||
$specifications->expects($this->once())
|
|
||||||
->method('getConfigurations');
|
|
||||||
|
|
||||||
$configuration = Configuration::build($specifications, 'prod');
|
|
||||||
$configuration->getConfigurations();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::getServices
|
|
||||||
*/
|
|
||||||
public function testGetServices()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('prod' => array()));
|
|
||||||
$specifications->expects($this->once())
|
|
||||||
->method('getServices');
|
|
||||||
|
|
||||||
$configuration = Configuration::build($specifications, 'prod');
|
|
||||||
$configuration->getServices();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::getBinaries
|
|
||||||
*/
|
|
||||||
public function testGetBinaries()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('prod' => array()));
|
|
||||||
$specifications->expects($this->once())
|
|
||||||
->method('getBinaries');
|
|
||||||
|
|
||||||
$configuration = Configuration::build($specifications, 'prod');
|
|
||||||
$configuration->getBinaries();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::getConnexions
|
|
||||||
*/
|
|
||||||
public function testGetConnexions()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('prod' => array()));
|
|
||||||
$specifications->expects($this->once())
|
|
||||||
->method('getConnexions');
|
|
||||||
|
|
||||||
$configuration = Configuration::build($specifications, 'prod');
|
|
||||||
$configuration->getConnexions();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::getConnexion
|
|
||||||
*/
|
|
||||||
public function testGetConnexion()
|
|
||||||
{
|
|
||||||
$testConnexion = array('path' => '/tmp/db');
|
|
||||||
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('prod' => array()));
|
|
||||||
$specifications->expects($this->once())
|
|
||||||
->method('getConnexions')
|
|
||||||
->will($this->returnValue(array('test' => $testConnexion)));
|
|
||||||
|
|
||||||
$configuration = Configuration::build($specifications, 'prod');
|
|
||||||
|
|
||||||
$conn = $configuration->getConnexion('test');
|
|
||||||
|
|
||||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\ParameterBag\ParameterBag', $conn);
|
|
||||||
$this->assertEquals($testConnexion, $conn->all());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::getConnexion
|
|
||||||
*/
|
|
||||||
public function testGetConnexionThatDoesNotExist()
|
|
||||||
{
|
|
||||||
$testConnexion = array('path' => '/tmp/db');
|
|
||||||
|
|
||||||
$specifications = $this->getSetupedSpecifications(array('prod' => array()));
|
|
||||||
$specifications->expects($this->once())
|
|
||||||
->method('getConnexions')
|
|
||||||
->will($this->returnValue(array('test' => $testConnexion)));
|
|
||||||
|
|
||||||
$configuration = Configuration::build($specifications, 'prod');
|
|
||||||
|
|
||||||
try {
|
|
||||||
$configuration->getConnexion('not-exists');
|
|
||||||
$this->fail('Should have raised an exception');
|
|
||||||
} catch (InvalidArgumentException $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::getTemplating
|
|
||||||
*/
|
|
||||||
public function testGetTemplating()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array(
|
|
||||||
'prod' => array('template_engine' => 'ObjectTwig')
|
|
||||||
));
|
|
||||||
|
|
||||||
$configuration = Configuration::build($specifications, 'prod');
|
|
||||||
$this->assertEquals('TemplateEngine\\ObjectTwig', $configuration->getTemplating());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::getCache
|
|
||||||
*/
|
|
||||||
public function testGetCache()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array(
|
|
||||||
'prod' => array('cache' => 'ObjectCache')
|
|
||||||
));
|
|
||||||
|
|
||||||
$configuration = Configuration::build($specifications, 'prod');
|
|
||||||
$this->assertEquals('Cache\\ObjectCache', $configuration->getCache());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::getOpcodeCache
|
|
||||||
*/
|
|
||||||
public function testGetOpcodeCache()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array(
|
|
||||||
'prod' => array('opcodecache' => 'ObjectOpcodeCache')
|
|
||||||
));
|
|
||||||
|
|
||||||
$configuration = Configuration::build($specifications, 'prod');
|
|
||||||
$this->assertEquals('Cache\\ObjectOpcodeCache', $configuration->getOpcodeCache());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::getOrm
|
|
||||||
*/
|
|
||||||
public function testGetOrm()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array(
|
|
||||||
'prod' => array('orm' => 'ObjectORM')
|
|
||||||
));
|
|
||||||
|
|
||||||
$configuration = Configuration::build($specifications, 'prod');
|
|
||||||
$this->assertEquals('Orm\\ObjectORM', $configuration->getOrm());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::getSearchEngine
|
|
||||||
*/
|
|
||||||
public function testGetSearchEngine()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array(
|
|
||||||
'prod' => array('search-engine' => 'ObjectPhrasea')
|
|
||||||
));
|
|
||||||
|
|
||||||
$configuration = Configuration::build($specifications, 'prod');
|
|
||||||
$this->assertEquals('SearchEngine\\ObjectPhrasea', $configuration->getSearchEngine());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::getBorder
|
|
||||||
*/
|
|
||||||
public function testGetBorder()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array(
|
|
||||||
'prod' => array('border-manager' => 'ObjectBorder')
|
|
||||||
));
|
|
||||||
|
|
||||||
$configuration = Configuration::build($specifications, 'prod');
|
|
||||||
$this->assertEquals('Border\\ObjectBorder', $configuration->getBorder());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::getTaskManager
|
|
||||||
*/
|
|
||||||
public function testGetTaskManager()
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array(
|
|
||||||
'prod' => array('task-manager' => 'ObjectTask')
|
|
||||||
));
|
|
||||||
|
|
||||||
$configuration = Configuration::build($specifications, 'prod');
|
|
||||||
$this->assertEquals('TaskManager\\ObjectTask', $configuration->getTaskManager());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::getService
|
|
||||||
* @dataProvider provideServices
|
|
||||||
*/
|
|
||||||
public function testGetService($services, $name, $expected)
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array(
|
|
||||||
'prod' => array('task-manager' => 'ObjectTask')
|
|
||||||
));
|
|
||||||
|
|
||||||
$specifications->expects($this->once())
|
|
||||||
->method('getServices')
|
|
||||||
->will($this->returnValue($services));
|
|
||||||
|
|
||||||
$configuration = Configuration::build($specifications, 'prod');
|
|
||||||
$service = $configuration->getService($name);
|
|
||||||
|
|
||||||
$this->assertInstanceOf('Symfony\Component\DependencyInjection\ParameterBag\ParameterBag', $service);
|
|
||||||
$this->assertEquals($expected, $service->all());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Configuration::getService
|
|
||||||
* @dataProvider provideFailingServiceData
|
|
||||||
*/
|
|
||||||
public function testGetServiceFail($services, $name)
|
|
||||||
{
|
|
||||||
$specifications = $this->getSetupedSpecifications(array(
|
|
||||||
'prod' => array('task-manager' => 'ObjectTask')
|
|
||||||
));
|
|
||||||
|
|
||||||
$specifications->expects($this->once())
|
|
||||||
->method('getServices')
|
|
||||||
->will($this->returnValue($services));
|
|
||||||
|
|
||||||
$configuration = Configuration::build($specifications, 'prod');
|
|
||||||
|
|
||||||
try {
|
|
||||||
$configuration->getService($name);
|
|
||||||
$this->fail('Should have raised an exception');
|
|
||||||
} catch (InvalidArgumentException $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function provideServices()
|
|
||||||
{
|
|
||||||
$services = array(
|
|
||||||
'servicetld' => array(
|
|
||||||
'sub' => array('data'),
|
|
||||||
'anothersub' => array('datalevel1' => array(
|
|
||||||
'datalevel2' => array('lowleveldata')
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
'anothertop' => array('pif' => 'paf')
|
|
||||||
);
|
|
||||||
|
|
||||||
return array(
|
|
||||||
array($services, 'servicetld\\sub', array('data')),
|
|
||||||
array($services, 'servicetld\\anothersub\\datalevel1', array('datalevel2' => array('lowleveldata'))),
|
|
||||||
array($services, 'anothertop', array('pif' => 'paf')),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function provideFailingServiceData()
|
|
||||||
{
|
|
||||||
$services = array(
|
|
||||||
'servicetld' => array(
|
|
||||||
'sub' => array('data'),
|
|
||||||
'anothersub' => array('datalevel1' => array(
|
|
||||||
'datalevel2' => array('lowleveldata')
|
|
||||||
)),
|
|
||||||
),
|
|
||||||
'anothertop' => array('pif' => 'paf')
|
|
||||||
);
|
|
||||||
|
|
||||||
return array(
|
|
||||||
array($services, 'servicetld\\sub\\data'),
|
|
||||||
array($services, 'servicetld\\data'),
|
|
||||||
array($services, 'servicetld\\anothersub\\datalevel2'),
|
|
||||||
array($services, 'anotherothertop'),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getNotSetupedSpecifications()
|
|
||||||
{
|
|
||||||
$specifications = $this->getMock('Alchemy\Phrasea\Core\Configuration\SpecificationInterface');
|
|
||||||
|
|
||||||
$specifications->expects($this->any())
|
|
||||||
->method('isSetup')
|
|
||||||
->will($this->returnValue(false));
|
|
||||||
|
|
||||||
return $specifications;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function getSetupedSpecifications($configuration = array())
|
|
||||||
{
|
|
||||||
$specifications = $this->getMock('Alchemy\Phrasea\Core\Configuration\SpecificationInterface');
|
|
||||||
|
|
||||||
$specifications->expects($this->any())
|
|
||||||
->method('isSetup')
|
|
||||||
->will($this->returnValue(true));
|
|
||||||
|
|
||||||
if ($configuration) {
|
|
||||||
$specifications->expects($this->any())
|
|
||||||
->method('getConfigurations')
|
|
||||||
->will($this->returnValue($configuration));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $specifications;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -5,8 +5,8 @@ namespace Alchemy\Tests\Phrasea\Core\Provider;
|
|||||||
use Alchemy\Phrasea\Application as PhraseaApplication;
|
use Alchemy\Phrasea\Application as PhraseaApplication;
|
||||||
use Alchemy\Phrasea\Core\Provider\TokensServiceProvider;
|
use Alchemy\Phrasea\Core\Provider\TokensServiceProvider;
|
||||||
use Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider;
|
use Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider;
|
||||||
|
use Alchemy\Phrasea\Core\Provider\ConfigurationServiceProvider;
|
||||||
use Silex\Application;
|
use Silex\Application;
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider
|
* @covers Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider
|
||||||
@@ -19,7 +19,7 @@ class AuthenticationManagerServiceProvidertest extends ServiceProviderTestCase
|
|||||||
array(
|
array(
|
||||||
'Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider',
|
'Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider',
|
||||||
'authentication',
|
'authentication',
|
||||||
'Alchemy\\Phrasea\\Authentication\\Authenticator'
|
'Alchemy\\Phrasea\\Authentication\\Authenticator',
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider',
|
'Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider',
|
||||||
@@ -69,7 +69,7 @@ class AuthenticationManagerServiceProvidertest extends ServiceProviderTestCase
|
|||||||
array(
|
array(
|
||||||
'Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider',
|
'Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider',
|
||||||
'auth.native',
|
'auth.native',
|
||||||
'Alchemy\Phrasea\Authentication\Phrasea\FailureHandledNativeAuthentication'
|
'Alchemy\Phrasea\Authentication\Phrasea\PasswordAuthenticationInterface'
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider',
|
'Alchemy\Phrasea\Core\Provider\AuthenticationManagerServiceProvider',
|
||||||
@@ -84,15 +84,11 @@ class AuthenticationManagerServiceProvidertest extends ServiceProviderTestCase
|
|||||||
$app = new Application();
|
$app = new Application();
|
||||||
$app->register(new TokensServiceProvider());
|
$app->register(new TokensServiceProvider());
|
||||||
$app->register(new AuthenticationManagerServiceProvider());
|
$app->register(new AuthenticationManagerServiceProvider());
|
||||||
|
$app->register(new ConfigurationServiceProvider());
|
||||||
|
|
||||||
$app['phraseanet.configuration'] = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration')
|
$app['phraseanet.configuration'] = $conf = $app['phraseanet.configuration']->getConfig();
|
||||||
->disableOriginalConstructor()
|
$conf['authentication']['captcha']['trials-before-failure'] = 42;
|
||||||
->getMock();
|
$app['phraseanet.configuration'] = $conf;
|
||||||
|
|
||||||
$app['phraseanet.configuration']->expects($this->once())
|
|
||||||
->method('get')
|
|
||||||
->with('authentication')
|
|
||||||
->will($this->returnValue(array('trials-before-failure' => 42)));
|
|
||||||
|
|
||||||
$app['EM'] = $this->getMockBuilder('Doctrine\Orm\EntityManager')
|
$app['EM'] = $this->getMockBuilder('Doctrine\Orm\EntityManager')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
@@ -108,36 +104,14 @@ class AuthenticationManagerServiceProvidertest extends ServiceProviderTestCase
|
|||||||
public function testFailureAccountCreator()
|
public function testFailureAccountCreator()
|
||||||
{
|
{
|
||||||
$app = new PhraseaApplication();
|
$app = new PhraseaApplication();
|
||||||
|
$app->register(new ConfigurationServiceProvider());
|
||||||
|
|
||||||
$conf = $app['phraseanet.configuration'];
|
$app['phraseanet.configuration'] = $conf = $app['phraseanet.configuration']->getConfig();
|
||||||
|
$conf['authentication']['auto-create'] = array(
|
||||||
$app['phraseanet.configuration'] = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration')
|
'enabled' => true,
|
||||||
->disableOriginalConstructor()
|
'templates' => array(),
|
||||||
->getMock();
|
);
|
||||||
|
$app['phraseanet.configuration'] = $conf;
|
||||||
$app['phraseanet.configuration']->expects($this->any())
|
|
||||||
->method('get')
|
|
||||||
->will($this->returnCallback(function ($key) use ($conf) {
|
|
||||||
if ($key === 'authentication') {
|
|
||||||
return array(
|
|
||||||
'auto-create' => array(
|
|
||||||
'enabled' => true,
|
|
||||||
'templates' => array()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return $conf->get($key);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
$app['phraseanet.configuration']->expects($this->any())
|
|
||||||
->method('getPhraseanet')
|
|
||||||
->will($this->returnValue(new ParameterBag($conf->get('phraseanet'))));
|
|
||||||
|
|
||||||
$conn = $conf->getSpecifications()->getConnexions();
|
|
||||||
|
|
||||||
$app['phraseanet.configuration']->expects($this->any())
|
|
||||||
->method('getConnexion')
|
|
||||||
->will($this->returnValue(new ParameterBag($conn['main_connexion'])));
|
|
||||||
|
|
||||||
$app['authentication.providers.account-creator'];
|
$app['authentication.providers.account-creator'];
|
||||||
}
|
}
|
||||||
@@ -146,6 +120,7 @@ class AuthenticationManagerServiceProvidertest extends ServiceProviderTestCase
|
|||||||
{
|
{
|
||||||
$app = new Application();
|
$app = new Application();
|
||||||
$app->register(new AuthenticationManagerServiceProvider());
|
$app->register(new AuthenticationManagerServiceProvider());
|
||||||
|
$app->register(new ConfigurationServiceProvider());
|
||||||
$app['phraseanet.registry'] = $this->getMockBuilder('registry')
|
$app['phraseanet.registry'] = $this->getMockBuilder('registry')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
@@ -162,14 +137,11 @@ class AuthenticationManagerServiceProvidertest extends ServiceProviderTestCase
|
|||||||
}));
|
}));
|
||||||
$app['phraseanet.appbox'] = self::$DI['app']['phraseanet.appbox'];
|
$app['phraseanet.appbox'] = self::$DI['app']['phraseanet.appbox'];
|
||||||
|
|
||||||
$app['phraseanet.configuration'] = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration')
|
$app['phraseanet.configuration'] = $conf = $app['phraseanet.configuration']->getConfig();
|
||||||
->disableOriginalConstructor()
|
$conf['authentication']['captcha'] = array(
|
||||||
->getMock();
|
'enabled' => true,
|
||||||
|
);
|
||||||
$app['phraseanet.configuration']->expects($this->any())
|
$app['phraseanet.configuration'] = $conf;
|
||||||
->method('get')
|
|
||||||
->with('authentication')
|
|
||||||
->will($this->returnValue(array('captcha' => array('enabled' => true))));
|
|
||||||
|
|
||||||
$app['EM'] = $this->getMockBuilder('Doctrine\Orm\EntityManager')
|
$app['EM'] = $this->getMockBuilder('Doctrine\Orm\EntityManager')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
@@ -185,6 +157,7 @@ class AuthenticationManagerServiceProvidertest extends ServiceProviderTestCase
|
|||||||
{
|
{
|
||||||
$app = new Application();
|
$app = new Application();
|
||||||
$app->register(new AuthenticationManagerServiceProvider());
|
$app->register(new AuthenticationManagerServiceProvider());
|
||||||
|
$app->register(new ConfigurationServiceProvider());
|
||||||
$app['phraseanet.registry'] = $this->getMockBuilder('registry')
|
$app['phraseanet.registry'] = $this->getMockBuilder('registry')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
@@ -201,14 +174,11 @@ class AuthenticationManagerServiceProvidertest extends ServiceProviderTestCase
|
|||||||
}));
|
}));
|
||||||
$app['phraseanet.appbox'] = self::$DI['app']['phraseanet.appbox'];
|
$app['phraseanet.appbox'] = self::$DI['app']['phraseanet.appbox'];
|
||||||
|
|
||||||
$app['phraseanet.configuration'] = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration')
|
$app['phraseanet.configuration'] = $conf = $app['phraseanet.configuration']->getConfig();
|
||||||
->disableOriginalConstructor()
|
$conf['authentication']['captcha'] = array(
|
||||||
->getMock();
|
'enabled' => false,
|
||||||
|
);
|
||||||
$app['phraseanet.configuration']->expects($this->any())
|
$app['phraseanet.configuration'] = $conf;
|
||||||
->method('get')
|
|
||||||
->with('authentication')
|
|
||||||
->will($this->returnValue(array('captcha' => array('enabled' => false))));
|
|
||||||
|
|
||||||
$app['EM'] = $this->getMockBuilder('Doctrine\Orm\EntityManager')
|
$app['EM'] = $this->getMockBuilder('Doctrine\Orm\EntityManager')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
@@ -230,39 +200,15 @@ class AuthenticationManagerServiceProvidertest extends ServiceProviderTestCase
|
|||||||
$template2 = \User_Adapter::create(self::$DI['app'], 'template' . $random->generatePassword(), $random->generatePassword(), null, false);
|
$template2 = \User_Adapter::create(self::$DI['app'], 'template' . $random->generatePassword(), $random->generatePassword(), null, false);
|
||||||
$template2->set_template(self::$DI['user']);
|
$template2->set_template(self::$DI['user']);
|
||||||
|
|
||||||
$conf = $app['phraseanet.configuration'];
|
$app['phraseanet.configuration'] = $conf = $app['phraseanet.configuration']->getConfig();
|
||||||
|
$conf['authentication']['auto-create'] = array(
|
||||||
$app['phraseanet.configuration'] = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration')
|
'enabled' => true,
|
||||||
->disableOriginalConstructor()
|
'templates' => array(
|
||||||
->getMock();
|
$template1->get_id(),
|
||||||
|
$template2->get_login()
|
||||||
$app['phraseanet.configuration']->expects($this->any())
|
)
|
||||||
->method('get')
|
);
|
||||||
->will($this->returnCallback(function ($key) use ($template1, $template2, $conf) {
|
$app['phraseanet.configuration'] = $conf;
|
||||||
if ($key === 'authentication') {
|
|
||||||
return array(
|
|
||||||
'auto-create' => array(
|
|
||||||
'enabled' => true,
|
|
||||||
'templates' => array(
|
|
||||||
$template1->get_id(),
|
|
||||||
$template2->get_login()
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
return $conf->get($key);
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
$app['phraseanet.configuration']->expects($this->any())
|
|
||||||
->method('getPhraseanet')
|
|
||||||
->will($this->returnValue(new ParameterBag($conf->get('phraseanet'))));
|
|
||||||
|
|
||||||
$conn = $conf->getSpecifications()->getConnexions();
|
|
||||||
|
|
||||||
$app['phraseanet.configuration']->expects($this->any())
|
|
||||||
->method('getConnexion')
|
|
||||||
->will($this->returnValue(new ParameterBag($conn['main_connexion'])));
|
|
||||||
|
|
||||||
$this->assertEquals(array($template1, $template2), $app['authentication.providers.account-creator']->getTemplates());
|
$this->assertEquals(array($template1, $template2), $app['authentication.providers.account-creator']->getTemplates());
|
||||||
|
|
||||||
|
@@ -10,7 +10,11 @@ class ConfigurationServiceProvidertest extends ServiceProviderTestCase
|
|||||||
public function provideServiceDescription()
|
public function provideServiceDescription()
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
array('Alchemy\Phrasea\Core\Provider\ConfigurationServiceProvider', 'phraseanet.configuration', 'Alchemy\\Phrasea\\Core\\Configuration'),
|
array(
|
||||||
|
'Alchemy\Phrasea\Core\Provider\ConfigurationServiceProvider',
|
||||||
|
'phraseanet.configuration',
|
||||||
|
'Alchemy\\Phrasea\\Core\\Configuration\\Configuration'
|
||||||
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -13,18 +13,9 @@ class RegistrationServiceProvidertest extends \PhraseanetPHPUnitAbstract
|
|||||||
{
|
{
|
||||||
self::$DI['app']->register(new RegistrationServiceProvider());
|
self::$DI['app']->register(new RegistrationServiceProvider());
|
||||||
|
|
||||||
self::$DI['app']['phraseanet.configuration'] = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration')
|
$conf = self::$DI['app']['phraseanet.configuration']->getConfig();
|
||||||
->disableOriginalConstructor()
|
$conf['registration-fields'] = array('plop');
|
||||||
->getMock();
|
self::$DI['app']['phraseanet.configuration'] = $conf;
|
||||||
|
|
||||||
self::$DI['app']['phraseanet.configuration']->expects($this->once())
|
|
||||||
->method('has')
|
|
||||||
->with('registration-fields')
|
|
||||||
->will($this->returnValue(true));
|
|
||||||
self::$DI['app']['phraseanet.configuration']->expects($this->once())
|
|
||||||
->method('get')
|
|
||||||
->with('registration-fields')
|
|
||||||
->will($this->returnValue(array('plop')));
|
|
||||||
|
|
||||||
$this->assertEquals(array('plop'), self::$DI['app']['registration.fields']);
|
$this->assertEquals(array('plop'), self::$DI['app']['registration.fields']);
|
||||||
$this->assertEquals(array('plop'), self::$DI['app']['registration.fields']);
|
$this->assertEquals(array('plop'), self::$DI['app']['registration.fields']);
|
||||||
|
@@ -1,210 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Alchemy\Tests\Phrasea\Core\Service\Border;
|
|
||||||
|
|
||||||
use Alchemy\Phrasea\Application;
|
|
||||||
use Alchemy\Phrasea\Core\Service\Border\BorderManager;
|
|
||||||
|
|
||||||
class BorderManagerTest extends \PhraseanetPHPUnitAbstract
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Service\Border\BorderManager::getDriver
|
|
||||||
*/
|
|
||||||
public function testGetDriver()
|
|
||||||
{
|
|
||||||
$options = array(
|
|
||||||
'enabled' => true,
|
|
||||||
'checkers' => array(
|
|
||||||
'type' => '',
|
|
||||||
'options' => array()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$manager = new BorderManager(self::$DI['app'], $options);
|
|
||||||
|
|
||||||
$this->assertInstanceOf('\\Alchemy\\Phrasea\\Border\\Manager', $manager->getDriver());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Service\Border\BorderManager::getType
|
|
||||||
*/
|
|
||||||
public function testGetType()
|
|
||||||
{
|
|
||||||
$options = array(
|
|
||||||
'enabled' => true,
|
|
||||||
'checkers' => array(
|
|
||||||
'type' => '',
|
|
||||||
'options' => array()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$manager = new BorderManager(self::$DI['app'], $options);
|
|
||||||
|
|
||||||
$this->assertEquals('border', $manager->getType());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @covers Alchemy\Phrasea\Core\Service\Border\BorderManager::getMandatoryOptions
|
|
||||||
*/
|
|
||||||
public function testGetMandatoryOptions()
|
|
||||||
{
|
|
||||||
$manager = new BorderManager(self::$DI['app'], array('enabled' => true, 'checkers' => array()));
|
|
||||||
$this->assertInternalType('array', $manager->getMandatoryOptions());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider getVariousWrongOptions
|
|
||||||
* @covers Alchemy\Phrasea\Core\Service\Border\BorderManager::init
|
|
||||||
* @covers Alchemy\Phrasea\Core\Service\Border\BorderManager::getUnregisteredCheckers
|
|
||||||
* @covers Alchemy\Phrasea\Core\Service\Border\BorderManager::addUnregisteredCheck
|
|
||||||
*/
|
|
||||||
public function testGetUnregisteredCheckers($options)
|
|
||||||
{
|
|
||||||
$manager = new BorderManager(self::$DI['app'], $options);
|
|
||||||
|
|
||||||
$this->assertEquals(1, count($manager->getUnregisteredCheckers()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @dataProvider getVariousOptions
|
|
||||||
* @covers Alchemy\Phrasea\Core\Service\Border\BorderManager::init
|
|
||||||
*/
|
|
||||||
public function testGetGoodConf($options)
|
|
||||||
{
|
|
||||||
$manager = new BorderManager(self::$DI['app'], $options);
|
|
||||||
|
|
||||||
$this->assertEquals(0, count($manager->getUnregisteredCheckers()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getVariousWrongOptions()
|
|
||||||
{
|
|
||||||
list($databox, $collection) = $this->getDataboxAndCollection();
|
|
||||||
|
|
||||||
return array(
|
|
||||||
array(
|
|
||||||
array(
|
|
||||||
'enabled' => true,
|
|
||||||
'checkers' => array(
|
|
||||||
array(
|
|
||||||
'type' => 'bidule',
|
|
||||||
'options' => array(),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
array(
|
|
||||||
'enabled' => true,
|
|
||||||
'checkers' => array(
|
|
||||||
array(
|
|
||||||
'options' => array(),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
array(
|
|
||||||
'enabled' => true,
|
|
||||||
'checkers' => array(
|
|
||||||
array(
|
|
||||||
'type' => 'Checker\\UUID',
|
|
||||||
'enabled' => false,
|
|
||||||
'options' => array(),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
array(
|
|
||||||
'enabled' => true,
|
|
||||||
'checkers' => array(
|
|
||||||
array(
|
|
||||||
'type' => 'Checker\\UUID',
|
|
||||||
'options' => array(),
|
|
||||||
'databoxes' => array(0),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
array(
|
|
||||||
'enabled' => true,
|
|
||||||
'checkers' => array(
|
|
||||||
array(
|
|
||||||
'type' => 'Checker\\UUID',
|
|
||||||
'options' => array(),
|
|
||||||
'collections' => array(0),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
array(
|
|
||||||
'enabled' => true,
|
|
||||||
'checkers' => array(
|
|
||||||
array(
|
|
||||||
'type' => 'Checker\\UUID',
|
|
||||||
'options' => array(),
|
|
||||||
'databoxes' => array($databox->get_sbas_id()),
|
|
||||||
'collections' => array($collection->get_base_id()),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getDataboxAndCollection()
|
|
||||||
{
|
|
||||||
$app = new Application('test');
|
|
||||||
$databox = $collection = null;
|
|
||||||
|
|
||||||
foreach ($app['phraseanet.appbox']->get_databoxes() as $db) {
|
|
||||||
if (!$databox) {
|
|
||||||
$databox = $db;
|
|
||||||
}
|
|
||||||
if (!$collection) {
|
|
||||||
foreach ($db->get_collections() as $coll) {
|
|
||||||
$collection = $coll;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return array($databox, $collection);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getVariousOptions()
|
|
||||||
{
|
|
||||||
list($databox, $collection) = $this->getDataboxAndCollection();
|
|
||||||
|
|
||||||
return array(
|
|
||||||
array(
|
|
||||||
array(
|
|
||||||
'enabled' => true,
|
|
||||||
'checkers' => array(
|
|
||||||
array(
|
|
||||||
'type' => 'Checker\\UUID',
|
|
||||||
'enabled' => true,
|
|
||||||
'options' => array(),
|
|
||||||
'databoxes' => array($databox->get_sbas_id()),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
array(
|
|
||||||
array(
|
|
||||||
'enabled' => true,
|
|
||||||
'checkers' => array(
|
|
||||||
array(
|
|
||||||
'type' => 'Checker\\UUID',
|
|
||||||
'enabled' => true,
|
|
||||||
'options' => array(),
|
|
||||||
'collections' => array($collection->get_base_id()),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
)
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,51 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Alchemy\Tests\Phrasea\Core\Service\Cache;
|
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Service\Cache\ApcCache;
|
|
||||||
|
|
||||||
class ServiceApcCacheTest extends \PhraseanetPHPUnitAbstract
|
|
||||||
{
|
|
||||||
|
|
||||||
public function testService()
|
|
||||||
{
|
|
||||||
$cache = new \Alchemy\Phrasea\Core\Service\Cache\ApcCache(
|
|
||||||
self::$DI['app'], array()
|
|
||||||
);
|
|
||||||
|
|
||||||
if (extension_loaded('apc')) {
|
|
||||||
$service = $cache->getDriver();
|
|
||||||
$this->assertTrue($service instanceof \Doctrine\Common\Cache\CacheProvider);
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
$cache->getDriver();
|
|
||||||
$this->fail("should raise an exception");
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testServiceException()
|
|
||||||
{
|
|
||||||
$cache = new \Alchemy\Phrasea\Core\Service\Cache\ApcCache(
|
|
||||||
self::$DI['app'], array()
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$cache->getDriver();
|
|
||||||
$this->fail("should raise an exception");
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testType()
|
|
||||||
{
|
|
||||||
$cache = new \Alchemy\Phrasea\Core\Service\Cache\ApcCache(
|
|
||||||
self::$DI['app'], array()
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertEquals("apc", $cache->getType());
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,42 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Alchemy\Tests\Phrasea\Core\Service\Cache;
|
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Service\Cache\ArrayCache;
|
|
||||||
|
|
||||||
class ServiceArrayCacheTest extends \PhraseanetPHPUnitAbstract
|
|
||||||
{
|
|
||||||
|
|
||||||
public function testService()
|
|
||||||
{
|
|
||||||
$cache = new \Alchemy\Phrasea\Core\Service\Cache\ArrayCache(
|
|
||||||
self::$DI['app'], array()
|
|
||||||
);
|
|
||||||
|
|
||||||
$service = $cache->getDriver();
|
|
||||||
$this->assertTrue($service instanceof \Doctrine\Common\Cache\CacheProvider);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testServiceException()
|
|
||||||
{
|
|
||||||
$cache = new \Alchemy\Phrasea\Core\Service\Cache\ArrayCache(
|
|
||||||
self::$DI['app'], array()
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$cache->getDriver();
|
|
||||||
$this->fail("should raise an exception");
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testType()
|
|
||||||
{
|
|
||||||
$cache = new \Alchemy\Phrasea\Core\Service\Cache\ArrayCache(
|
|
||||||
self::$DI['app'], array()
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertEquals("array", $cache->getType());
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,69 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Alchemy\Tests\Phrasea\Core\Service\Cache;
|
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Service\Cache\MemcacheCache;
|
|
||||||
|
|
||||||
class ServiceMemcacheCacheTest extends \PhraseanetPHPUnitAbstract
|
|
||||||
{
|
|
||||||
|
|
||||||
public function testService()
|
|
||||||
{
|
|
||||||
$cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache(
|
|
||||||
self::$DI['app'], array()
|
|
||||||
);
|
|
||||||
|
|
||||||
if (extension_loaded('memcache')) {
|
|
||||||
$service = $cache->getDriver();
|
|
||||||
$this->assertTrue($service instanceof \Doctrine\Common\Cache\CacheProvider);
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
$cache->getDriver();
|
|
||||||
$this->fail("should raise an exception");
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testServiceException()
|
|
||||||
{
|
|
||||||
$cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache(
|
|
||||||
self::$DI['app'], array()
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$cache->getDriver();
|
|
||||||
$this->fail("should raise an exception");
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testType()
|
|
||||||
{
|
|
||||||
$cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache(
|
|
||||||
self::$DI['app'], array()
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertEquals("memcache", $cache->getType());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testHost()
|
|
||||||
{
|
|
||||||
$cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache(
|
|
||||||
self::$DI['app'], array()
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertEquals(\Alchemy\Phrasea\Core\Service\Cache\MemcacheCache::DEFAULT_HOST, $cache->getHost());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testPort()
|
|
||||||
{
|
|
||||||
$cache = new \Alchemy\Phrasea\Core\Service\Cache\MemcacheCache(
|
|
||||||
self::$DI['app'], array()
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertEquals(\Alchemy\Phrasea\Core\Service\Cache\MemcacheCache::DEFAULT_PORT, $cache->getPort());
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,51 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Alchemy\Tests\Phrasea\Core\Service\Cache;
|
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Service\Cache\XcacheCache;
|
|
||||||
|
|
||||||
class ServiceXcacheCacheTest extends \PhraseanetPHPUnitAbstract
|
|
||||||
{
|
|
||||||
|
|
||||||
public function testService()
|
|
||||||
{
|
|
||||||
$cache = new \Alchemy\Phrasea\Core\Service\Cache\XcacheCache(
|
|
||||||
self::$DI['app'], array()
|
|
||||||
);
|
|
||||||
|
|
||||||
if (extension_loaded('xcache')) {
|
|
||||||
$service = $cache->getDriver();
|
|
||||||
$this->assertTrue($service instanceof \Doctrine\Common\Cache\CacheProvider);
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
$cache->getDriver();
|
|
||||||
$this->fail("should raise an exception");
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testServiceException()
|
|
||||||
{
|
|
||||||
$cache = new \Alchemy\Phrasea\Core\Service\Cache\XcacheCache(
|
|
||||||
self::$DI['app'], array()
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$cache->getDriver();
|
|
||||||
$this->fail("should raise an exception");
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testType()
|
|
||||||
{
|
|
||||||
$cache = new \Alchemy\Phrasea\Core\Service\Cache\XcacheCache(
|
|
||||||
self::$DI['app'], array()
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertEquals("xcache", $cache->getType());
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,48 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Alchemy\Tests\Phrasea\Core\Service\Log\Doctrine;
|
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Service\Log\Monolog;
|
|
||||||
|
|
||||||
class DoctrineMonologTest extends \PhraseanetPHPUnitAbstract
|
|
||||||
{
|
|
||||||
protected $options = array(
|
|
||||||
"handler" => "rotate"
|
|
||||||
, "filename" => "test"
|
|
||||||
, 'output' => 'json'
|
|
||||||
, 'channel' => 'test'
|
|
||||||
);
|
|
||||||
|
|
||||||
public function testService()
|
|
||||||
{
|
|
||||||
|
|
||||||
$log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Monolog(
|
|
||||||
self::$DI['app'], $this->options
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertInstanceOf("\Doctrine\Logger\MonologSQLLogger", $log->getDriver());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testType()
|
|
||||||
{
|
|
||||||
$log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Monolog(
|
|
||||||
self::$DI['app'], $this->options
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertEquals("doctrine_monolog", $log->getType());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testExceptionBadOutput()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$this->options["output"] = "unknowOutput";
|
|
||||||
$log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Monolog(
|
|
||||||
self::$DI['app'], $this->options
|
|
||||||
);
|
|
||||||
$log->getDriver();
|
|
||||||
$this->fail("should raise an exception");
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,27 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Alchemy\Tests\Phrasea\Core\Service\Log\Doctrine;
|
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Service\Log\Doctrine\Phpecho;
|
|
||||||
|
|
||||||
class DoctrinePhpechoTest extends \PhraseanetPHPUnitAbstract
|
|
||||||
{
|
|
||||||
|
|
||||||
public function testService()
|
|
||||||
{
|
|
||||||
$log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Phpecho(
|
|
||||||
self::$DI['app'], array()
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertInstanceOf("\Doctrine\DBAL\Logging\EchoSQLLogger", $log->getDriver());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testType()
|
|
||||||
{
|
|
||||||
$log = new \Alchemy\Phrasea\Core\Service\Log\Doctrine\Phpecho(
|
|
||||||
self::$DI['app'], array()
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertEquals("phpecho", $log->getType());
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,99 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Alchemy\Tests\Phrasea\Core\Service\Log;
|
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Service\Log\Monolog;
|
|
||||||
|
|
||||||
class MonologTest extends \PhraseanetPHPUnitAbstract
|
|
||||||
{
|
|
||||||
protected $options;
|
|
||||||
|
|
||||||
public function setUp()
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
$this->options = array(
|
|
||||||
"handler" => "rotate"
|
|
||||||
, "filename" => "test"
|
|
||||||
, "channel" => "test"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testService()
|
|
||||||
{
|
|
||||||
$log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
|
|
||||||
self::$DI['app'], $this->options
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertInstanceOf("\Monolog\Logger", $log->getDriver());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testType()
|
|
||||||
{
|
|
||||||
$log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
|
|
||||||
self::$DI['app'], $this->options
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertEquals("monolog", $log->getType());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testExceptionMissingOptions()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
|
|
||||||
self::$DI['app'], $this->options
|
|
||||||
);
|
|
||||||
$this->fail("should raise an exception");
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testExceptionMissingHandler()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
unset($this->options["handler"]);
|
|
||||||
$log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
|
|
||||||
self::$DI['app'], $this->options
|
|
||||||
);
|
|
||||||
$this->fail("should raise an exception");
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testExceptionUnknowHandler()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$this->options["handler"] = "unknowHandler";
|
|
||||||
$log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
|
|
||||||
self::$DI['app'], $this->options
|
|
||||||
);
|
|
||||||
$this->fail("should raise an exception");
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testMissingFile()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
unset($this->options["filename"]);
|
|
||||||
$log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
|
|
||||||
self::$DI['app'], $this->options
|
|
||||||
);
|
|
||||||
$this->fail("should raise an exception");
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testStreamLogger()
|
|
||||||
{
|
|
||||||
|
|
||||||
$this->options["handler"] = "stream";
|
|
||||||
$log = new \Alchemy\Phrasea\Core\Service\Log\Monolog(
|
|
||||||
self::$DI['app'], $this->options
|
|
||||||
);
|
|
||||||
$this->assertInstanceOf("\Monolog\Logger", $log->getDriver());
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,183 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Alchemy\Tests\Phrasea\Core\Service\Orm;
|
|
||||||
|
|
||||||
use Alchemy\Tests\Phrasea\Core\Service\Orm\DoctrineTest;
|
|
||||||
|
|
||||||
class DoctrineTest extends \PhraseanetPHPUnitAbstract
|
|
||||||
{
|
|
||||||
protected $options;
|
|
||||||
|
|
||||||
public function setUp()
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
$this->options = array(
|
|
||||||
"debug" => false
|
|
||||||
, "log" => array('service' => "Log\\sql_logger")
|
|
||||||
, "dbal" => "main_connexion"
|
|
||||||
, "cache" => array(
|
|
||||||
"metadata" => array('service' => "Cache\\array_cache")
|
|
||||||
, "query" => array('service' => "Cache\\array_cache")
|
|
||||||
, "result" => array('service' => "Cache\\array_cache")
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testService()
|
|
||||||
{
|
|
||||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
|
||||||
self::$DI['app'], $this->options
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertInstanceOf("\Doctrine\ORM\EntityManager", $doctrine->getDriver());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testType()
|
|
||||||
{
|
|
||||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
|
||||||
self::$DI['app'], $this->options
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertEquals("doctrine", $doctrine->getType());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testExceptionMissingOptions()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
|
||||||
self::$DI['app'], $this->options
|
|
||||||
);
|
|
||||||
$this->fail("should raise an exception");
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testNoCacheInOptions()
|
|
||||||
{
|
|
||||||
$this->markTestSkipped('To rewrite');
|
|
||||||
unset($this->options["cache"]);
|
|
||||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
|
||||||
self::$DI['app'], $this->options
|
|
||||||
);
|
|
||||||
|
|
||||||
foreach ($doctrine->getCacheServices()->all() as $service) {
|
|
||||||
$this->assertEquals("array", $service->getType());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testUnknowCache()
|
|
||||||
{
|
|
||||||
$this->options["cache"]["result"] = "unknowCache";
|
|
||||||
|
|
||||||
try {
|
|
||||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
|
||||||
self::$DI['app'], $this->options
|
|
||||||
);
|
|
||||||
$this->fail("An exception should be raised");
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testIsDebug()
|
|
||||||
{
|
|
||||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
|
||||||
self::$DI['app'], $this->options
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertFalse($doctrine->isDebug());
|
|
||||||
|
|
||||||
$this->options['debug'] = true;
|
|
||||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
|
||||||
self::$DI['app'], $this->options
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->assertTrue($doctrine->isDebug());
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetCacheServices()
|
|
||||||
{
|
|
||||||
$this->markTestSkipped('To rewrite');
|
|
||||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
|
||||||
self::$DI['app'], $this->options
|
|
||||||
);
|
|
||||||
$this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag"
|
|
||||||
, $doctrine->getCacheServices());
|
|
||||||
|
|
||||||
foreach ($doctrine->getCacheServices()->all() as $service) {
|
|
||||||
$this->assertEquals("array", $service->getType());
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->options['orm']["cache"] = array(
|
|
||||||
"metadata" => "array_cache"
|
|
||||||
, "query" => "apc_cache"
|
|
||||||
, "result" => "xcache_cache"
|
|
||||||
);
|
|
||||||
|
|
||||||
if (extension_loaded("apc") && extension_loaded("xcache")) {
|
|
||||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
|
||||||
self::$DI['app'], $this->options
|
|
||||||
);
|
|
||||||
$this->assertInstanceOf("\Symfony\Component\DependencyInjection\ParameterBag\ParameterBag"
|
|
||||||
, $doctrine->getCacheServices());
|
|
||||||
|
|
||||||
foreach ($doctrine->getCacheServices()->all() as $key => $service) {
|
|
||||||
if ($key === "metadata")
|
|
||||||
$this->assertEquals("array", $service->getType());
|
|
||||||
elseif ($key === "query")
|
|
||||||
$this->assertEquals("apc", $service->getType());
|
|
||||||
elseif ($key === "result")
|
|
||||||
$this->assertEquals("xcache", $service->getType());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
try {
|
|
||||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
|
||||||
self::$DI['app'], $this->options
|
|
||||||
);
|
|
||||||
$this->fail("An exception should be raised");
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testExceptionUnknowLogService()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$this->options["log"] = "unknowLogger";
|
|
||||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
|
||||||
self::$DI['app'], $this->options
|
|
||||||
);
|
|
||||||
$this->fail("should raise an exception");
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testExceptionMissingDbal()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
unset($this->options["dbal"]);
|
|
||||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
|
||||||
self::$DI['app'], $this->options
|
|
||||||
);
|
|
||||||
$this->fail("should raise an exception");
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testExceptionUnknowDbal()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$this->options["dbal"] = "unknowDbal";
|
|
||||||
$doctrine = new \Alchemy\Phrasea\Core\Service\Orm\Doctrine(
|
|
||||||
self::$DI['app'], $this->options
|
|
||||||
);
|
|
||||||
$this->fail("should raise an exception");
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,33 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Alchemy\Tests\Phrasea\Core\Service;
|
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Service\ServiceAbstract;
|
|
||||||
|
|
||||||
class ServiceAbstractTest extends \PhraseanetPHPUnitAbstract
|
|
||||||
{
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @var \Alchemy\Phrasea\Core\Service\ServiceAbstract
|
|
||||||
*/
|
|
||||||
protected $object;
|
|
||||||
|
|
||||||
public function setUp()
|
|
||||||
{
|
|
||||||
parent::setUp();
|
|
||||||
|
|
||||||
$this->object = $this->getMockForAbstractClass(
|
|
||||||
"\Alchemy\Phrasea\Core\Service\ServiceAbstract"
|
|
||||||
, array(
|
|
||||||
self::$DI['app']
|
|
||||||
, array('option' => 'my_options')
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testGetOptions()
|
|
||||||
{
|
|
||||||
$this->assertTrue(is_array($this->object->getOptions()));
|
|
||||||
$this->assertEquals(array('option' => 'my_options'), $this->object->getOptions());
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,45 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Alchemy\Tests\Phrasea\Core\ServiceBuilder;
|
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Service\Builder;
|
|
||||||
|
|
||||||
class AbstractBuilderTest extends \PhraseanetPHPUnitAbstract
|
|
||||||
{
|
|
||||||
|
|
||||||
public function testConstructExceptionNameEmpty()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$this->getMock(
|
|
||||||
"\Alchemy\Phrasea\Core\Service\Builder"
|
|
||||||
, array()
|
|
||||||
, array(
|
|
||||||
self::$DI['app']
|
|
||||||
, ''
|
|
||||||
, new \Symfony\Component\DependencyInjection\ParameterBag\ParameterBag()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$this->fail("should raise an exception");
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testConstructExceptionCreate()
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
$this->getMock(
|
|
||||||
"\\Alchemy\\Phrasea\\Core\\Service\\Builder"
|
|
||||||
, array()
|
|
||||||
, array(
|
|
||||||
self::$DI['app'],
|
|
||||||
'test',
|
|
||||||
new \Symfony\Component\DependencyInjection\ParameterBag\ParameterBag(),
|
|
||||||
)
|
|
||||||
);
|
|
||||||
$this->fail("should raise an exception");
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,34 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Alchemy\Tests\Phrasea\Core\ServiceBuilder;
|
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Service\Builder;
|
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
|
||||||
|
|
||||||
class CacheBuilderTest extends \PhraseanetPHPUnitAbstract
|
|
||||||
{
|
|
||||||
|
|
||||||
public function testCreateException()
|
|
||||||
{
|
|
||||||
$configuration = new ParameterBag(
|
|
||||||
array("type" => "unknow")
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$service = Builder::create(self::$DI['app'], $configuration);
|
|
||||||
$this->fail("An exception should be raised");
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCreate()
|
|
||||||
{
|
|
||||||
$configuration = new ParameterBag(
|
|
||||||
array("type" => "Cache\\ArrayCache")
|
|
||||||
);
|
|
||||||
|
|
||||||
$service = Builder::create(self::$DI['app'], $configuration);
|
|
||||||
$this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,51 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Alchemy\Tests\Phrasea\Core\ServiceBuilder;
|
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Service\Builder;
|
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
|
||||||
|
|
||||||
class LogBuilderTest extends \PhraseanetPHPUnitAbstract
|
|
||||||
{
|
|
||||||
|
|
||||||
public function testCreateException()
|
|
||||||
{
|
|
||||||
$configuration = new ParameterBag(
|
|
||||||
array("type" => "unknow", "options" => array())
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$service = Builder::create(self::$DI['app'], $configuration);
|
|
||||||
$this->fail("An exception should be raised");
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCreate()
|
|
||||||
{
|
|
||||||
$configuration = new ParameterBag(
|
|
||||||
array("type" => "Log\\Doctrine\\Monolog", "options" => array(
|
|
||||||
"handler" => "rotate"
|
|
||||||
, "filename" => "test"
|
|
||||||
, 'channel' => 'Test'
|
|
||||||
, 'output' => 'json'
|
|
||||||
, 'max_day' => '1'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$service = Builder::create(self::$DI['app'], $configuration);
|
|
||||||
$this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCreateNamespace()
|
|
||||||
{
|
|
||||||
$configuration = new ParameterBag(
|
|
||||||
array("type" => "Log\\Doctrine\\Phpecho", "options" => array())
|
|
||||||
);
|
|
||||||
|
|
||||||
$service = Builder::create(self::$DI['app'], $configuration);
|
|
||||||
$this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,44 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Alchemy\Tests\Phrasea\Core\ServiceBuilder;
|
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Service\Builder;
|
|
||||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
|
||||||
|
|
||||||
class OrmBuilderTest extends \PhraseanetPHPUnitAbstract
|
|
||||||
{
|
|
||||||
|
|
||||||
public function testCreateException()
|
|
||||||
{
|
|
||||||
$configuration = new ParameterBag(
|
|
||||||
array("type" => "unknow", "options" => array())
|
|
||||||
);
|
|
||||||
|
|
||||||
try {
|
|
||||||
$service = Builder::create(self::$DI['app'], $configuration);
|
|
||||||
$this->fail("An exception should be raised");
|
|
||||||
} catch (\Exception $e) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function testCreate()
|
|
||||||
{
|
|
||||||
$configuration = new ParameterBag(
|
|
||||||
array("type" => "Orm\\Doctrine", "options" => array(
|
|
||||||
"debug" => false
|
|
||||||
, "log" => array('service' => "Log\\query_logger")
|
|
||||||
, "dbal" => "main_connexion"
|
|
||||||
, "cache" => array(
|
|
||||||
"metadata" => "Cache\\array_cache"
|
|
||||||
, "query" => "Cache\\array_cache"
|
|
||||||
, "result" => "Cache\\array_cache"
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$service = Builder::create(self::$DI['app'], $configuration);
|
|
||||||
$this->assertInstanceOf("\Alchemy\Phrasea\Core\Service\ServiceAbstract", $service);
|
|
||||||
}
|
|
||||||
}
|
|
@@ -19,15 +19,11 @@ abstract class AbstractSetupTester extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
protected function uninstall()
|
protected function uninstall()
|
||||||
{
|
{
|
||||||
rename(__DIR__ . '/../../../../../config/config.yml', __DIR__ . '/../../../../../config/config.yml.test');
|
rename(__DIR__ . '/../../../../../config/configuration.yml', __DIR__ . '/../../../../../config/configuration.yml.test');
|
||||||
rename(__DIR__ . '/../../../../../config/connexions.yml', __DIR__ . '/../../../../../config/connexions.yml.test');
|
|
||||||
rename(__DIR__ . '/../../../../../config/services.yml', __DIR__ . '/../../../../../config/services.yml.test');
|
|
||||||
|
|
||||||
$this->tearDownHandlers[] = function() {
|
$this->tearDownHandlers[] = function() {
|
||||||
rename(__DIR__ . '/../../../../../config/config.yml.test', __DIR__ . '/../../../../../config/config.yml');
|
rename(__DIR__ . '/../../../../../config/configuration.yml.test', __DIR__ . '/../../../../../config/configuration.yml');
|
||||||
rename(__DIR__ . '/../../../../../config/connexions.yml.test', __DIR__ . '/../../../../../config/connexions.yml');
|
};
|
||||||
rename(__DIR__ . '/../../../../../config/services.yml.test', __DIR__ . '/../../../../../config/services.yml');
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function goBackTo31()
|
protected function goBackTo31()
|
||||||
|
@@ -4,9 +4,10 @@ namespace Alchemy\Tests\Phrasea\Setup;
|
|||||||
|
|
||||||
use Alchemy\Phrasea\Setup\Installer;
|
use Alchemy\Phrasea\Setup\Installer;
|
||||||
use Alchemy\Phrasea\Application;
|
use Alchemy\Phrasea\Application;
|
||||||
use Alchemy\Tests\Phrasea\Setup\TestSpecifications;
|
use Alchemy\Phrasea\Core\Configuration\Configuration;
|
||||||
use Alchemy\Phrasea\Core\Configuration;
|
|
||||||
use Symfony\Component\Yaml\Parser;
|
use Symfony\Component\Yaml\Parser;
|
||||||
|
use Symfony\Component\Yaml\Yaml;
|
||||||
|
use Alchemy\Phrasea\Core\Configuration\Compiler;
|
||||||
|
|
||||||
class InstallerTest extends \PHPUnit_Framework_TestCase
|
class InstallerTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
@@ -40,11 +41,16 @@ class InstallerTest extends \PHPUnit_Framework_TestCase
|
|||||||
$app = new Application('test');
|
$app = new Application('test');
|
||||||
|
|
||||||
$parser = new Parser();
|
$parser = new Parser();
|
||||||
$connDatas = $parser->parse(file_get_contents(__DIR__ . '/../../../../../config/connexions.yml'));
|
$connDatas = $parser->parse(file_get_contents(__DIR__ . '/../../../../../config/configuration.yml'));
|
||||||
$credentials = $connDatas['main_connexion'];
|
$credentials = $connDatas['main']['database'];
|
||||||
|
|
||||||
$specifications = new TestSpecifications();
|
$config = __DIR__ . '/configuration.yml';
|
||||||
$app['phraseanet.configuration'] = new Configuration($specifications);
|
$compiled = __DIR__ . '/configuration.yml.php';
|
||||||
|
|
||||||
|
@unlink($config);
|
||||||
|
@unlink($compiled);
|
||||||
|
|
||||||
|
$app['phraseanet.configuration'] = new Configuration(new Yaml(), new Compiler(), $config, $compiled, true);
|
||||||
|
|
||||||
$abConn = new \connection_pdo('abConn', 'localhost', 3306, $credentials['user'], $credentials['password'], 'ab_unitTests');
|
$abConn = new \connection_pdo('abConn', 'localhost', 3306, $credentials['user'], $credentials['password'], 'ab_unitTests');
|
||||||
$dbConn = new \connection_pdo('dbConn', 'localhost', 3306, $credentials['user'], $credentials['password'], 'db_unitTests');
|
$dbConn = new \connection_pdo('dbConn', 'localhost', 3306, $credentials['user'], $credentials['password'], 'db_unitTests');
|
||||||
@@ -57,10 +63,14 @@ class InstallerTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
\User_Adapter::unsetInstances();
|
\User_Adapter::unsetInstances();
|
||||||
|
|
||||||
$this->assertTrue($specifications->isSetup());
|
$this->assertTrue($app['phraseanet.configuration']->isSetup());
|
||||||
$this->assertTrue($app['phraseanet.configuration-tester']->isUpToDate());
|
$this->assertTrue($app['phraseanet.configuration-tester']->isUpToDate());
|
||||||
$confs = $app['phraseanet.configuration']->getConfigurations();
|
$conf = $app['phraseanet.configuration']->getConfig();
|
||||||
$this->assertArrayHasKey('key', $confs);
|
$this->assertArrayHasKey('main', $conf);
|
||||||
$this->assertGreaterThan(10, strlen($confs['key']));
|
$this->assertArrayHasKey('key', $conf['main']);
|
||||||
|
$this->assertGreaterThan(10, strlen($conf['main']['key']));
|
||||||
|
|
||||||
|
@unlink($config);
|
||||||
|
@unlink($compiled);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,43 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Alchemy\Tests\Phrasea\Setup;
|
|
||||||
|
|
||||||
use Alchemy\Phrasea\Core\Configuration\ApplicationSpecification;
|
|
||||||
|
|
||||||
class TestSpecifications extends ApplicationSpecification
|
|
||||||
{
|
|
||||||
private $rootDir;
|
|
||||||
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
parent::__construct();
|
|
||||||
$this->rootDir = sys_get_temp_dir() . '/' . microtime(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function __destruct()
|
|
||||||
{
|
|
||||||
@unlink($this->getConfigurationsPathFile());
|
|
||||||
@unlink($this->getServicesPathFile());
|
|
||||||
@unlink($this->getConnexionsPathFile());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getConfigurationsPathFile()
|
|
||||||
{
|
|
||||||
return $this->rootDir . 'config.yml';
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getConnexionsPathFile()
|
|
||||||
{
|
|
||||||
return $this->rootDir . 'connexions.yml';
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getServicesPathFile()
|
|
||||||
{
|
|
||||||
return $this->rootDir . 'services.yml';
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function getBinariesPathFile()
|
|
||||||
{
|
|
||||||
return $this->rootDir . 'binaries.yml';
|
|
||||||
}
|
|
||||||
}
|
|
@@ -3,10 +3,11 @@
|
|||||||
namespace Alchemy\Tests\Phrasea\Setup\Version\Migration;
|
namespace Alchemy\Tests\Phrasea\Setup\Version\Migration;
|
||||||
|
|
||||||
use Alchemy\Phrasea\Application;
|
use Alchemy\Phrasea\Application;
|
||||||
use Alchemy\Phrasea\Core\Configuration;
|
use Alchemy\Phrasea\Core\Configuration\Configuration;
|
||||||
|
use Alchemy\Phrasea\Core\Configuration\Compiler;
|
||||||
use Alchemy\Phrasea\Setup\Version\Migration\Migration35;
|
use Alchemy\Phrasea\Setup\Version\Migration\Migration35;
|
||||||
use Alchemy\Tests\Phrasea\Setup\TestSpecifications;
|
|
||||||
use Alchemy\Tests\Phrasea\Setup\AbstractSetupTester;
|
use Alchemy\Tests\Phrasea\Setup\AbstractSetupTester;
|
||||||
|
use Symfony\Component\Yaml\Yaml;
|
||||||
|
|
||||||
class Migration35Test extends AbstractSetupTester
|
class Migration35Test extends AbstractSetupTester
|
||||||
{
|
{
|
||||||
@@ -33,7 +34,13 @@ class Migration35Test extends AbstractSetupTester
|
|||||||
|
|
||||||
public function testMigrate()
|
public function testMigrate()
|
||||||
{
|
{
|
||||||
$this->specifications = new TestSpecifications();
|
$config = __DIR__ . '/configuration.yml';
|
||||||
|
$compiled = __DIR__ . '/configuration.yml.php';
|
||||||
|
|
||||||
|
@unlink($config);
|
||||||
|
@unlink($compiled);
|
||||||
|
|
||||||
|
$this->specifications = new Configuration(new Yaml(), new Compiler(), $config, $compiled, true);
|
||||||
$this->assertFalse($this->specifications->isSetup());
|
$this->assertFalse($this->specifications->isSetup());
|
||||||
|
|
||||||
$this->goBackTo35();
|
$this->goBackTo35();
|
||||||
@@ -45,6 +52,9 @@ class Migration35Test extends AbstractSetupTester
|
|||||||
@unlink(__DIR__ . '/../../../../../../config/connexion.inc.old');
|
@unlink(__DIR__ . '/../../../../../../config/connexion.inc.old');
|
||||||
|
|
||||||
$this->assertTrue($this->specifications->isSetup());
|
$this->assertTrue($this->specifications->isSetup());
|
||||||
|
|
||||||
|
@unlink($config);
|
||||||
|
@unlink($compiled);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getMigration(Application $app = null)
|
private function getMigration(Application $app = null)
|
||||||
@@ -52,7 +62,7 @@ class Migration35Test extends AbstractSetupTester
|
|||||||
$app = $app ? : new Application('test');
|
$app = $app ? : new Application('test');
|
||||||
|
|
||||||
if ($this->specifications) {
|
if ($this->specifications) {
|
||||||
$app['phraseanet.configuration'] = new Configuration($this->specifications);
|
$app['phraseanet.configuration'] = $this->specifications;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Migration35($app);
|
return new Migration35($app);
|
||||||
|
@@ -92,13 +92,19 @@ abstract class PhraseanetWebTestCaseAuthenticatedAbstract extends PhraseanetPHPU
|
|||||||
{
|
{
|
||||||
$this->createDatabase();
|
$this->createDatabase();
|
||||||
|
|
||||||
$configuration = self::$DI['app']['phraseanet.configuration'];
|
$connexion = self::$DI['app']['phraseanet.configuration']['main']['database'];
|
||||||
|
|
||||||
$choosenConnexion = $configuration->getPhraseanet()->get('database');
|
|
||||||
$connexion = $configuration->getConnexion($choosenConnexion);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$conn = new \connection_pdo('databox_creation', $connexion->get('host'), $connexion->get('port'), $connexion->get('user'), $connexion->get('password'), 'unit_test_db', array(), false);
|
$conn = new \connection_pdo(
|
||||||
|
'databox_creation',
|
||||||
|
$connexion['host'],
|
||||||
|
$connexion['port'],
|
||||||
|
$connexion['user'],
|
||||||
|
$connexion['password'],
|
||||||
|
'unit_test_db',
|
||||||
|
array(),
|
||||||
|
false
|
||||||
|
);
|
||||||
} catch (\PDOException $e) {
|
} catch (\PDOException $e) {
|
||||||
|
|
||||||
$this->markTestSkipped('Could not reach DB');
|
$this->markTestSkipped('Could not reach DB');
|
||||||
|
@@ -40,7 +40,7 @@ class Session_LoggerTest extends PhraseanetPHPUnitAbstract
|
|||||||
$params = array(
|
$params = array(
|
||||||
':ses_id' => self::$DI['app']['session']->get('session_id')
|
':ses_id' => self::$DI['app']['session']->get('session_id')
|
||||||
, ':usr_id' => self::$DI['app']['authentication']->getUser()->get_id()
|
, ':usr_id' => self::$DI['app']['authentication']->getUser()->get_id()
|
||||||
, ':site' => self::$DI['app']['phraseanet.registry']->get('GV_sit')
|
, ':site' => self::$DI['app']['phraseanet.configuration']['main']['key']
|
||||||
);
|
);
|
||||||
|
|
||||||
$stmt = $this->databox->get_connection()->prepare($sql);
|
$stmt = $this->databox->get_connection()->prepare($sql);
|
||||||
@@ -59,7 +59,7 @@ class Session_LoggerTest extends PhraseanetPHPUnitAbstract
|
|||||||
$params = array(
|
$params = array(
|
||||||
':ses_id' => $ses_id
|
':ses_id' => $ses_id
|
||||||
, ':usr_id' => $usr_id
|
, ':usr_id' => $usr_id
|
||||||
, ':site' => self::$DI['app']['phraseanet.registry']->get('GV_sit')
|
, ':site' => self::$DI['app']['phraseanet.configuration']['main']['key']
|
||||||
);
|
);
|
||||||
|
|
||||||
$stmt = $this->databox->get_connection()->prepare($sql);
|
$stmt = $this->databox->get_connection()->prepare($sql);
|
||||||
|
@@ -17,11 +17,9 @@ class API_V1_resultTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
|||||||
|
|
||||||
self::$DI['app']->register(new \API_V1_Timer());
|
self::$DI['app']->register(new \API_V1_Timer());
|
||||||
|
|
||||||
$conf = self::$DI['app']['phraseanet.configuration'];
|
$conf = self::$DI['app']['phraseanet.configuration']->getConfig();
|
||||||
$confs = $conf->getConfigurations();
|
$conf['main']['api-timers'] = true;
|
||||||
$confs[$conf->getEnvironnement()]['phraseanet']['api-timers'] = true;
|
self::$DI['app']['phraseanet.configuration']->setConfig($conf);
|
||||||
|
|
||||||
self::$DI['app']['phraseanet.configuration']->setConfigurations($confs);
|
|
||||||
|
|
||||||
$this->api = $this->getMock("API_V1_adapter", array("get_version"), array(), "", false);
|
$this->api = $this->getMock("API_V1_adapter", array("get_version"), array(), "", false);
|
||||||
$this->api->expects($this->any())->method("get_version")->will($this->returnValue("my_super_version1.0"));
|
$this->api->expects($this->any())->method("get_version")->will($this->returnValue("my_super_version1.0"));
|
||||||
|
@@ -2,90 +2,6 @@
|
|||||||
|
|
||||||
class patch_3803Test extends PhraseanetPHPUnitAbstract
|
class patch_3803Test extends PhraseanetPHPUnitAbstract
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* @covers patch_3803::apply
|
|
||||||
*/
|
|
||||||
public function testApplyInSphinxEnvironment()
|
|
||||||
{
|
|
||||||
$patch = new patch_3803();
|
|
||||||
|
|
||||||
$appbox = $this->getMockBuilder('appbox')
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$app = self::$DI['app'];
|
|
||||||
|
|
||||||
$app['phraseanet.registry'] = $this->getMock('registryInterface');
|
|
||||||
$app['phraseanet.registry']->expects($this->any())
|
|
||||||
->method('get')
|
|
||||||
->will($this->returnCallback(function ($parameter) {
|
|
||||||
switch ($parameter) {
|
|
||||||
case 'GV_sphinx':
|
|
||||||
return true;
|
|
||||||
case 'GV_sphinx_rt_port':
|
|
||||||
return 5678;
|
|
||||||
case 'GV_sphinx_rt_host':
|
|
||||||
return 'sphinx.rt_host';
|
|
||||||
case 'GV_sphinx_host':
|
|
||||||
return 'sphinx.host';
|
|
||||||
case 'GV_sphinx_port':
|
|
||||||
return 1234;
|
|
||||||
default:
|
|
||||||
throw new \InvalidArgumentException(sprintf('%s is missing, test case not ready', $parameter));
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
$catchConfiguration = $catchSEConf = null;
|
|
||||||
|
|
||||||
$app['phraseanet.configuration'] = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration')
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
$app['phraseanet.configuration']->expects($this->once())
|
|
||||||
->method('getConfigurations')
|
|
||||||
->will($this->returnValue(array('environment' => 'prod', 'prod' => array(), 'dev' => array())));
|
|
||||||
$app['phraseanet.configuration']->expects($this->once())
|
|
||||||
->method('setConfigurations')
|
|
||||||
->will($this->returnCallback(function($configuration) use (&$catchConfiguration) {
|
|
||||||
$catchConfiguration = $configuration;
|
|
||||||
}));
|
|
||||||
|
|
||||||
$panel = $this->getMock('Alchemy\Phrasea\SearchEngine\ConfigurationPanelInterface');
|
|
||||||
$panel->expects($this->once())
|
|
||||||
->method('saveConfiguration')
|
|
||||||
->will($this->returnCallback(function($json) use (&$catchSEConf) {
|
|
||||||
$catchSEConf = $json;
|
|
||||||
}));
|
|
||||||
$panel->expects($this->once())
|
|
||||||
->method('getConfiguration')
|
|
||||||
->will($this->returnValue(array()));
|
|
||||||
|
|
||||||
$app['phraseanet.SE'] = $this->getMock('Alchemy\Phrasea\SearchEngine\SearchEngineInterface');
|
|
||||||
$app['phraseanet.SE']->expects($this->any())
|
|
||||||
->method('getConfigurationPanel')
|
|
||||||
->will($this->returnValue($panel));
|
|
||||||
|
|
||||||
$this->assertTrue($patch->apply($appbox, $app));
|
|
||||||
|
|
||||||
$upgrade = 0;
|
|
||||||
foreach ($catchConfiguration as $env => $conf) {
|
|
||||||
if (in_array($env, array('environment', 'key'))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$this->assertArrayHasKey('search-engine', $conf);
|
|
||||||
$upgrade++;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertEquals(2, $upgrade);
|
|
||||||
$this->assertArrayHasKey('port', $catchSEConf);
|
|
||||||
$this->assertArrayHasKey('host', $catchSEConf);
|
|
||||||
$this->assertArrayHasKey('rt_port', $catchSEConf);
|
|
||||||
$this->assertArrayHasKey('rt_host', $catchSEConf);
|
|
||||||
$this->assertEquals(5678, $catchSEConf['rt_port']);
|
|
||||||
$this->assertEquals('sphinx.rt_host', $catchSEConf['rt_host']);
|
|
||||||
$this->assertEquals(1234, $catchSEConf['port']);
|
|
||||||
$this->assertEquals('sphinx.host', $catchSEConf['host']);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers patch_3803::apply
|
* @covers patch_3803::apply
|
||||||
*/
|
*/
|
||||||
@@ -99,63 +15,11 @@ class patch_3803Test extends PhraseanetPHPUnitAbstract
|
|||||||
|
|
||||||
$app = self::$DI['app'];
|
$app = self::$DI['app'];
|
||||||
|
|
||||||
$app['phraseanet.registry'] = $this->getMock('registryInterface');
|
$app['phraseanet.configuration'] = $this->getMock('Alchemy\Phrasea\Core\Configuration\ConfigurationInterface');
|
||||||
$app['phraseanet.registry']->expects($this->any())
|
|
||||||
->method('get')
|
|
||||||
->will($this->returnCallback(function ($parameter) {
|
|
||||||
switch ($parameter) {
|
|
||||||
case 'GV_sphinx':
|
|
||||||
return false;
|
|
||||||
case 'GV_phrasea_sort':
|
|
||||||
return 'custom-sort';
|
|
||||||
default:
|
|
||||||
throw new \InvalidArgumentException(sprintf('%s is missing, test case not ready', $parameter));
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
|
|
||||||
$catchConfiguration = $catchPhraseaConf = null;
|
|
||||||
|
|
||||||
$app['phraseanet.configuration'] = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration')
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
$app['phraseanet.configuration']->expects($this->once())
|
$app['phraseanet.configuration']->expects($this->once())
|
||||||
->method('getConfigurations')
|
->method('setDefault')
|
||||||
->will($this->returnValue(array('environment' => 'prod', 'prod' => array(), 'dev' => array())));
|
->with('main', 'search-engine');
|
||||||
$app['phraseanet.configuration']->expects($this->once())
|
|
||||||
->method('setConfigurations')
|
|
||||||
->will($this->returnCallback(function($configuration) use (&$catchConfiguration) {
|
|
||||||
$catchConfiguration = $configuration;
|
|
||||||
}));
|
|
||||||
|
|
||||||
$panel = $this->getMock('Alchemy\Phrasea\SearchEngine\ConfigurationPanelInterface');
|
|
||||||
$panel->expects($this->once())
|
|
||||||
->method('saveConfiguration')
|
|
||||||
->will($this->returnCallback(function($json) use (&$catchSEConf) {
|
|
||||||
$catchSEConf = $json;
|
|
||||||
}));
|
|
||||||
$panel->expects($this->once())
|
|
||||||
->method('getConfiguration')
|
|
||||||
->will($this->returnValue(array()));
|
|
||||||
|
|
||||||
$app['phraseanet.SE'] = $this->getMock('Alchemy\Phrasea\SearchEngine\SearchEngineInterface');
|
|
||||||
$app['phraseanet.SE']->expects($this->any())
|
|
||||||
->method('getConfigurationPanel')
|
|
||||||
->will($this->returnValue($panel));
|
|
||||||
|
|
||||||
$this->assertTrue($patch->apply($appbox, $app));
|
$this->assertTrue($patch->apply($appbox, $app));
|
||||||
|
|
||||||
$upgrade = 0;
|
|
||||||
foreach ($catchConfiguration as $env => $conf) {
|
|
||||||
if (in_array($env, array('environment', 'key'))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$this->assertArrayHasKey('search-engine', $conf);
|
|
||||||
$upgrade++;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertEquals(2, $upgrade);
|
|
||||||
|
|
||||||
$this->assertArrayHasKey('default_sort', $catchSEConf);
|
|
||||||
$this->assertEquals('custom-sort', $catchSEConf['default_sort']);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -15,46 +15,11 @@ class patch_3804Test extends PhraseanetPHPUnitAbstract
|
|||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->getMock();
|
->getMock();
|
||||||
|
|
||||||
$catchConfiguration = null;
|
$app['phraseanet.configuration'] = $this->getMock('Alchemy\Phrasea\Core\Configuration\ConfigurationInterface');
|
||||||
|
|
||||||
$app['phraseanet.configuration'] = $this->getMockBuilder('Alchemy\Phrasea\Core\Configuration')
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock();
|
|
||||||
|
|
||||||
$app['phraseanet.configuration']->expects($this->once())
|
$app['phraseanet.configuration']->expects($this->once())
|
||||||
->method('getConfigurations')
|
->method('setDefault')
|
||||||
->will($this->returnValue(array(
|
->with('main', 'task-manager');
|
||||||
'environment' => 'prod',
|
|
||||||
'prod' => array(),
|
|
||||||
'dev' => array()
|
|
||||||
)));
|
|
||||||
$app['phraseanet.configuration']->expects($this->once())
|
|
||||||
->method('setConfigurations')
|
|
||||||
->will($this->returnCallback(function($configuration) use (&$catchConfiguration) {
|
|
||||||
$catchConfiguration = $configuration;
|
|
||||||
}));
|
|
||||||
|
|
||||||
$app['phraseanet.configuration']->expects($this->once())
|
|
||||||
->method('getServices')
|
|
||||||
->will($this->returnValue(array(
|
|
||||||
'SearchEngine' => array(),
|
|
||||||
)));
|
|
||||||
|
|
||||||
$app['phraseanet.configuration']->expects($this->once())
|
|
||||||
->method('resetServices')
|
|
||||||
->with($this->equalTo('TaskManager'));
|
|
||||||
|
|
||||||
$this->assertTrue($patch->apply($appbox, $app));
|
$this->assertTrue($patch->apply($appbox, $app));
|
||||||
|
|
||||||
$upgrade = 0;
|
|
||||||
foreach ($catchConfiguration as $env => $conf) {
|
|
||||||
if (in_array($env, array('environment', 'key'))) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$this->assertArrayHasKey('task-manager', $conf);
|
|
||||||
$upgrade++;
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->assertEquals(2, $upgrade);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
272
tests/classes/patch/3807Test.php
Normal file
272
tests/classes/patch/3807Test.php
Normal file
@@ -0,0 +1,272 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Alchemy\Phrasea\Application;
|
||||||
|
|
||||||
|
class patch_3807Test extends PHPUnit_Framework_TestCase
|
||||||
|
{
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
$this->revert();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tearDown()
|
||||||
|
{
|
||||||
|
$this->revert();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function revert()
|
||||||
|
{
|
||||||
|
foreach (array('binaries.yml.bkp', 'config.yml.bkp', 'connexions.yml.bkp', 'services.yml.bkp') as $backupFile) {
|
||||||
|
if (is_file(__DIR__ . '/fixtures-3807/config/' . $backupFile)) {
|
||||||
|
rename(__DIR__ . '/fixtures-3807/config/' . $backupFile, __DIR__ . '/fixtures-3807/config/' . substr($backupFile, 0, -4));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testApply()
|
||||||
|
{
|
||||||
|
$app = new Application();
|
||||||
|
$app['phraseanet.configuration'] = $this->getMock('Alchemy\Phrasea\Core\Configuration\ConfigurationInterface');
|
||||||
|
$app['root.path'] = __DIR__ . '/fixtures-3807';
|
||||||
|
|
||||||
|
$app['phraseanet.configuration']->expects($this->once())
|
||||||
|
->method('getConfig')
|
||||||
|
->will($this->returnValue($this->getCurrent()));
|
||||||
|
|
||||||
|
$app['phraseanet.configuration']->expects($this->once())
|
||||||
|
->method('setConfig')
|
||||||
|
->with($this->getModified());
|
||||||
|
|
||||||
|
$appbox = $this->getMockBuilder('appbox')
|
||||||
|
->disableOriginalConstructor()
|
||||||
|
->getMock();
|
||||||
|
|
||||||
|
$patch = new patch_3807();
|
||||||
|
$patch->apply($appbox, $app);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getModified()
|
||||||
|
{
|
||||||
|
$modified = $this->getCurrent();
|
||||||
|
|
||||||
|
$modified['main']['key'] = '1234567890';
|
||||||
|
$modified['main']['servername'] = 'http://sub.domain.tld/';
|
||||||
|
$modified['main']['maintenance'] = true;
|
||||||
|
$modified['binaries']['test_binary'] = '/path/to/test/binary/file';
|
||||||
|
$modified['main']['database'] = array_replace($modified['main']['database'], array(
|
||||||
|
'host' => 'sql-host',
|
||||||
|
'port' => '13306',
|
||||||
|
'user' => 'username',
|
||||||
|
'password' => 's3cr3t',
|
||||||
|
'dbname' => 'phrasea_db',
|
||||||
|
));
|
||||||
|
$modified['main']['cache'] = array(
|
||||||
|
'type' => 'MemcacheCache',
|
||||||
|
'options' => array(
|
||||||
|
'host' => 'memcache-host',
|
||||||
|
'port' => 21211,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
$modified['main']['opcodecache'] = array(
|
||||||
|
'type' => 'ApcCache',
|
||||||
|
'options' => array(),
|
||||||
|
);
|
||||||
|
$modified['border-manager']['enabled'] = false;
|
||||||
|
|
||||||
|
return $modified;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getCurrent()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'main' => array(
|
||||||
|
'servername' => 'http://local.phrasea/',
|
||||||
|
'maintenance' => false,
|
||||||
|
'database' => array(
|
||||||
|
'host' => '127.0.0.1',
|
||||||
|
'port' => '3306',
|
||||||
|
'user' => 'root',
|
||||||
|
'password' => '',
|
||||||
|
'dbname' => 'ab_test',
|
||||||
|
'driver' => 'pdo_mysql',
|
||||||
|
'charset' => 'UTF8',
|
||||||
|
),
|
||||||
|
'database-test' => array(
|
||||||
|
'driver' => 'pdo_sqlite',
|
||||||
|
'path' => '/tmp/db.sqlite',
|
||||||
|
'charset' => 'UTF8',
|
||||||
|
),
|
||||||
|
'api-timers' => true,
|
||||||
|
'cache' => array(
|
||||||
|
'type' => 'ArrayCache',
|
||||||
|
'options' => array(
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'opcodecache' => array(
|
||||||
|
'type' => 'ArrayCache',
|
||||||
|
'options' => array(
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'search-engine' => array(
|
||||||
|
'type' => 'Alchemy\Phrasea\SearchEngine\Phrasea\PhraseaEngine',
|
||||||
|
'options' => array(
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'task-manager' => array(
|
||||||
|
'options' => '',
|
||||||
|
),
|
||||||
|
'key' => null,
|
||||||
|
),
|
||||||
|
'binaries' => array(
|
||||||
|
'legacy_binay' => '/path/to/legacy/binary',
|
||||||
|
),
|
||||||
|
'border-manager' => array(
|
||||||
|
'enabled' => true,
|
||||||
|
'checkers' => array(
|
||||||
|
array(
|
||||||
|
'type' => 'Checker\Sha256',
|
||||||
|
'enabled' => true,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'type' => 'Checker\UUID',
|
||||||
|
'enabled' => true,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'type' => 'Checker\Colorspace',
|
||||||
|
'enabled' => false,
|
||||||
|
'options' => array(
|
||||||
|
'colorspaces' => array(
|
||||||
|
'cmyk',
|
||||||
|
'grayscale',
|
||||||
|
'rgb',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'type' => 'Checker\Dimension',
|
||||||
|
'enabled' => false,
|
||||||
|
'options' => array(
|
||||||
|
'width' => 80,
|
||||||
|
'height' => 160,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'type' => 'Checker\Extension',
|
||||||
|
'enabled' => false,
|
||||||
|
'options' => array(
|
||||||
|
'extensions' => array(
|
||||||
|
'jpg',
|
||||||
|
'jpeg',
|
||||||
|
'bmp',
|
||||||
|
'tif',
|
||||||
|
'gif',
|
||||||
|
'png',
|
||||||
|
'pdf',
|
||||||
|
'doc',
|
||||||
|
'odt',
|
||||||
|
'mpg',
|
||||||
|
'mpeg',
|
||||||
|
'mov',
|
||||||
|
'avi',
|
||||||
|
'xls',
|
||||||
|
'flv',
|
||||||
|
'mp3',
|
||||||
|
'mp2',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'type' => 'Checker\Filename',
|
||||||
|
'enabled' => false,
|
||||||
|
'options' => array(
|
||||||
|
'sensitive' => true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'type' => 'Checker\MediaType',
|
||||||
|
'enabled' => false,
|
||||||
|
'options' => array(
|
||||||
|
'mediatypes' => array(
|
||||||
|
'Audio',
|
||||||
|
'Document',
|
||||||
|
'Flash',
|
||||||
|
'Image',
|
||||||
|
'Video',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'authentication' => array(
|
||||||
|
'auto-create' => array(
|
||||||
|
'enabled' => false,
|
||||||
|
'templates' => array(
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'captcha' => array(
|
||||||
|
'enabled' => true,
|
||||||
|
'trials-before-failure' => 9,
|
||||||
|
),
|
||||||
|
'providers' => array(
|
||||||
|
'facebook' => array(
|
||||||
|
'enabled' => false,
|
||||||
|
'options' => array(
|
||||||
|
'app-id' => '',
|
||||||
|
'secret' => '',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'twitter' => array(
|
||||||
|
'enabled' => false,
|
||||||
|
'options' => array(
|
||||||
|
'consumer-key' => '',
|
||||||
|
'consumer-secret' => '',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'google-plus' => array(
|
||||||
|
'enabled' => false,
|
||||||
|
'options' => array(
|
||||||
|
'client-id' => '',
|
||||||
|
'client-secret' => '',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'github' => array(
|
||||||
|
'enabled' => false,
|
||||||
|
'options' => array(
|
||||||
|
'client-id' => '',
|
||||||
|
'client-secret' => '',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'viadeo' => array(
|
||||||
|
'enabled' => false,
|
||||||
|
'options' => array(
|
||||||
|
'client-id' => '',
|
||||||
|
'client-secret' => '',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'linkedin' => array(
|
||||||
|
'enabled' => false,
|
||||||
|
'options' => array(
|
||||||
|
'client-id' => '',
|
||||||
|
'client-secret' => '',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
'registration-fields' => array(
|
||||||
|
array(
|
||||||
|
'name' => 'company',
|
||||||
|
'required' => true,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'name' => 'firstname',
|
||||||
|
'required' => true,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'name' => 'geonameid',
|
||||||
|
'required' => true,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
2
tests/classes/patch/fixtures-3807/config/binaries.yml
Normal file
2
tests/classes/patch/fixtures-3807/config/binaries.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
binaries:
|
||||||
|
test_binary: /path/to/test/binary/file
|
16
tests/classes/patch/fixtures-3807/config/config.yml
Normal file
16
tests/classes/patch/fixtures-3807/config/config.yml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
environment : prod
|
||||||
|
key : 1234567890
|
||||||
|
|
||||||
|
prod:
|
||||||
|
phraseanet:
|
||||||
|
servername: 'http://sub.domain.tld/'
|
||||||
|
maintenance: true
|
||||||
|
debug: false
|
||||||
|
display_errors: false
|
||||||
|
database: main_connexion
|
||||||
|
api-timers: false
|
||||||
|
template_engine: twig
|
||||||
|
orm: doctrine_prod
|
||||||
|
cache: memcache_cache
|
||||||
|
opcodecache: apc_cache
|
||||||
|
border-manager: border_manager
|
13
tests/classes/patch/fixtures-3807/config/connexions.yml
Normal file
13
tests/classes/patch/fixtures-3807/config/connexions.yml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
main_connexion:
|
||||||
|
host: 'sql-host'
|
||||||
|
port: 13306
|
||||||
|
user: username
|
||||||
|
password: s3cr3t
|
||||||
|
dbname: phrasea_db
|
||||||
|
driver: pdo_mysql
|
||||||
|
charset: UTF8
|
||||||
|
|
||||||
|
test_connexion:
|
||||||
|
driver: pdo_sqlite
|
||||||
|
path: '/tmp/db.sqlite'
|
||||||
|
charset: UTF8
|
109
tests/classes/patch/fixtures-3807/config/services.yml
Normal file
109
tests/classes/patch/fixtures-3807/config/services.yml
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
Orm:
|
||||||
|
doctrine_prod:
|
||||||
|
type: Orm\Doctrine
|
||||||
|
options:
|
||||||
|
debug: false
|
||||||
|
dbal: main_connexion
|
||||||
|
cache:
|
||||||
|
query:
|
||||||
|
service: Cache\array_cache
|
||||||
|
result:
|
||||||
|
service: Cache\array_cache
|
||||||
|
metadata:
|
||||||
|
service: Cache\array_cache
|
||||||
|
|
||||||
|
Log:
|
||||||
|
query_logger:
|
||||||
|
type: Log\Doctrine\Monolog
|
||||||
|
options:
|
||||||
|
output: json
|
||||||
|
channel: query-logger
|
||||||
|
handler: rotate
|
||||||
|
max_day: 2
|
||||||
|
filename: doctrine-query.log
|
||||||
|
sql_logger:
|
||||||
|
type: Log\Doctrine\Phpecho
|
||||||
|
|
||||||
|
Cache:
|
||||||
|
array_cache:
|
||||||
|
type: Cache\ArrayCache
|
||||||
|
memcache_cache:
|
||||||
|
type: Cache\MemcacheCache
|
||||||
|
options:
|
||||||
|
host: memcache-host
|
||||||
|
port: 21211
|
||||||
|
apc_cache:
|
||||||
|
type: Cache\ApcCache
|
||||||
|
xcache_cache:
|
||||||
|
type: Cache\XcacheCache
|
||||||
|
wincache_cache:
|
||||||
|
type: Cache\WinCacheCache
|
||||||
|
|
||||||
|
Border:
|
||||||
|
#Define Border service
|
||||||
|
#The border service handles checks validation constraints against incoming files
|
||||||
|
border_manager:
|
||||||
|
type: Border\BorderManager
|
||||||
|
options:
|
||||||
|
#Enable validation on incoming files
|
||||||
|
enabled: false
|
||||||
|
checkers:
|
||||||
|
#Check for duplicated file based on their sha256 check sum
|
||||||
|
-
|
||||||
|
type: Checker\Sha256
|
||||||
|
enabled: true
|
||||||
|
#Check for duplicated file based on their UUID
|
||||||
|
-
|
||||||
|
type: Checker\UUID
|
||||||
|
enabled: true
|
||||||
|
#Check colorspace (if applicable)
|
||||||
|
-
|
||||||
|
type: Checker\Colorspace
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
colorspaces: [cmyk, grayscale, rgb]
|
||||||
|
#Check file dimension (if applicable)
|
||||||
|
-
|
||||||
|
type: Checker\Dimension
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
width: 80
|
||||||
|
height: 160
|
||||||
|
#Check file extension
|
||||||
|
#set to false to enable all file extensions
|
||||||
|
-
|
||||||
|
type: Checker\Extension
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
extensions: [jpg, jpeg, bmp, tif, gif, png, pdf, doc, odt, mpg, mpeg, mov, avi, xls, flv, mp3, mp2]
|
||||||
|
#Check filename
|
||||||
|
-
|
||||||
|
type: Checker\Filename
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
sensitive: true
|
||||||
|
#Check media type
|
||||||
|
#Set to false to enable all mediatype
|
||||||
|
-
|
||||||
|
type: Checker\MediaType
|
||||||
|
enabled: false
|
||||||
|
options:
|
||||||
|
mediatypes: [Audio, Document, Flash, Image, Video]
|
||||||
|
SearchEngine:
|
||||||
|
phrasea:
|
||||||
|
type: SearchEngine\PhraseaEngine
|
||||||
|
sphinxsearch:
|
||||||
|
type: SearchEngine\SphinxSearch
|
||||||
|
options:
|
||||||
|
host: localhost
|
||||||
|
port: 9306
|
||||||
|
rt_host: localhost
|
||||||
|
rt_port: 9308
|
||||||
|
TaskManager:
|
||||||
|
task_manager:
|
||||||
|
type: TaskManager\TaskManager
|
||||||
|
options:
|
||||||
|
# set the threshold for sending task logs to syslog or by mail
|
||||||
|
# values : task_abstract::[LOG_DEBUG | LOG_INFO | LOG_WARNING | LOG_ERROR | LOG_CRITICAL | LOG_ALERT]
|
||||||
|
#syslog_level: task_abstract::LOG_ERROR
|
||||||
|
#maillog_level: task_abstract::LOG_ERROR
|
Reference in New Issue
Block a user