mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 12:33:26 +00:00
add configuration & service testes
This commit is contained in:
139
lib/unitTest/Core/Configuration/ApplicationTest.php
Normal file
139
lib/unitTest/Core/Configuration/ApplicationTest.php
Normal file
@@ -0,0 +1,139 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
|
||||
|
||||
use Alchemy\Phrasea\Core as PhraseaCore;
|
||||
use Alchemy\Phrasea\Core\Configuration\Application;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class ApplicationTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var \Alchemy\Phrasea\Core\Configuration\Application
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testGetNonExtendablePath()
|
||||
{
|
||||
$app = new Application();
|
||||
$paths = $app->getNonExtendablePath();
|
||||
$this->assertTrue(is_array($paths));
|
||||
foreach ($paths as $path)
|
||||
{
|
||||
$this->assertTrue(is_array($path));
|
||||
foreach ($path as $key)
|
||||
{
|
||||
$this->assertTrue(is_string($key));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetConfFileFromEnvName()
|
||||
{
|
||||
$app = $this->getMock(
|
||||
'\Alchemy\Phrasea\Core\Configuration\Application'
|
||||
, array('getMainConfigurationFile', 'getConfigurationFilePath')
|
||||
);
|
||||
|
||||
$fileName = __DIR__ . '/confTestFiles/good.yml';
|
||||
|
||||
$app->expects($this->any())
|
||||
->method('getMainConfigurationFile')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
new \SplFileObject($fileName)
|
||||
)
|
||||
);
|
||||
$app->expects($this->any())
|
||||
->method('getConfigurationFilePath')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
__DIR__ . '/confTestFiles'
|
||||
)
|
||||
);
|
||||
|
||||
$this->assertInstanceOf('SplFileObject', $app->getConfFileFromEnvName('oneenv'));
|
||||
$this->assertInstanceOf('SplFileObject', $app->getConfFileFromEnvName(Application::EXTENDED_MAIN_KEYWORD));
|
||||
|
||||
try
|
||||
{
|
||||
$app->getConfFileFromEnvName('unknow_env');
|
||||
$this->fail('An exception shoud be raised');
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetConfigurationFilePath()
|
||||
{
|
||||
$app = new Application();
|
||||
$this->assertTrue(is_string($app->getConfigurationFilePath()));
|
||||
}
|
||||
|
||||
public function testGetMainConfigurationFile()
|
||||
{
|
||||
$app = new Application();
|
||||
try
|
||||
{
|
||||
$this->assertInstanceOf('SplFileObject', $app->getMainConfigurationFile());
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
$this->markTestSkipped('Config file config.yml is not present');
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetConfFileExtension()
|
||||
{
|
||||
$app = new Application();
|
||||
$this->assertEquals('yml', $app->getConfFileExtension());
|
||||
}
|
||||
|
||||
public function testIsExtended()
|
||||
{
|
||||
$app = new Application();
|
||||
|
||||
$testExtendedEnv = array('extends' => 'value');
|
||||
$testNonExtendedEnv = array('blabla' => 'blabla');
|
||||
|
||||
$this->assertTrue($app->isExtended($testExtendedEnv));
|
||||
$this->assertFalse($app->isExtended($testNonExtendedEnv));
|
||||
}
|
||||
|
||||
public function testGetExtendedEnvName()
|
||||
{
|
||||
$app = new Application();
|
||||
$testExtendedEnv = array('extends' => 'value');
|
||||
$testNonExtendedEnv = array('blabla' => 'blabla');
|
||||
|
||||
$this->assertEquals('value', $app->getExtendedEnvName($testExtendedEnv));
|
||||
$this->assertNull($app->getExtendedEnvName($testNonExtendedEnv));
|
||||
}
|
||||
|
||||
}
|
174
lib/unitTest/Core/Configuration/ConfigurationTest.php
Normal file
174
lib/unitTest/Core/Configuration/ConfigurationTest.php
Normal file
@@ -0,0 +1,174 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
|
||||
|
||||
use Alchemy\Phrasea\Core as PhraseaCore;
|
||||
use Alchemy\Phrasea\Core\Configuration;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class ConfigurationTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
||||
{
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testInitialization()
|
||||
{
|
||||
$spec = $this->getMock(
|
||||
'\Alchemy\Phrasea\Core\Configuration\Application'
|
||||
, array('getMainConfigurationFile')
|
||||
);
|
||||
|
||||
$fileName = __DIR__ . '/confTestFiles/good.yml';
|
||||
|
||||
$spec->expects($this->any())
|
||||
->method('getMainConfigurationFile')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
new \SplFileObject($fileName)
|
||||
)
|
||||
);
|
||||
|
||||
$handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml());
|
||||
|
||||
$environnement = 'main';
|
||||
$configuration = new PhraseaCore\Configuration($environnement, $handler);
|
||||
|
||||
$this->assertEquals($environnement, $configuration->getEnvironnement());
|
||||
$this->assertTrue($configuration->isInstalled());
|
||||
$this->assertInstanceOf(
|
||||
'Alchemy\Phrasea\Core\Configuration\Parameter'
|
||||
, $configuration->getConfiguration()
|
||||
);
|
||||
$this->assertFalse($configuration->isDebug());
|
||||
$this->assertFalse($configuration->displayErrors());
|
||||
$this->assertTrue(is_array($configuration->getPhraseanet()));
|
||||
$this->assertTrue(is_array($configuration->getDoctrine()));
|
||||
}
|
||||
|
||||
public function testInstalled()
|
||||
{
|
||||
$spec = $this->getMock(
|
||||
'\Alchemy\Phrasea\Core\Configuration\Application'
|
||||
, array('getMainConfigurationFile')
|
||||
);
|
||||
|
||||
$spec->expects($this->any())
|
||||
->method('getMainConfigurationFile')
|
||||
->will($this->throwException(new \Exception()));
|
||||
|
||||
$handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml());
|
||||
|
||||
$environnement = 'main';
|
||||
$configuration = new PhraseaCore\Configuration($environnement, $handler);
|
||||
|
||||
$this->assertFalse($configuration->isInstalled());
|
||||
$this->assertTrue(is_array($configuration->getPhraseanet()));
|
||||
$this->assertTrue(is_array($configuration->getDoctrine()));
|
||||
}
|
||||
|
||||
public function testGetAvailableLogger()
|
||||
{
|
||||
$spec = $this->getMock('\Alchemy\Phrasea\Core\Configuration\Application');
|
||||
$handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml());
|
||||
|
||||
$environnement = 'main';
|
||||
$configuration = new PhraseaCore\Configuration($environnement, $handler);
|
||||
|
||||
$availableLogger = $configuration->getAvailableDoctrineLogger();
|
||||
|
||||
$this->assertTrue(is_array($availableLogger));
|
||||
$this->assertContains('monolog', $availableLogger);
|
||||
$this->assertContains('echo', $availableLogger);
|
||||
}
|
||||
|
||||
public function testGetHandler()
|
||||
{
|
||||
$spec = $this->getMock('\Alchemy\Phrasea\Core\Configuration\Application');
|
||||
$handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml());
|
||||
|
||||
$environnement = 'main';
|
||||
$configuration = new PhraseaCore\Configuration($environnement, $handler);
|
||||
|
||||
$this->assertInstanceOf('\Alchemy\Phrasea\Core\Configuration\Handler', $configuration->getConfigurationHandler());
|
||||
}
|
||||
|
||||
public function testSetHandler()
|
||||
{
|
||||
$spec = $this->getMock('\Alchemy\Phrasea\Core\Configuration\Application');
|
||||
$handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml());
|
||||
|
||||
$environnement = 'main';
|
||||
$configuration = new PhraseaCore\Configuration($environnement, $handler);
|
||||
|
||||
$spec2 = $this->getMock('\Alchemy\Phrasea\Core\Configuration\Application');
|
||||
|
||||
$spec2->expects($this->any())
|
||||
->method('getMainConfigurationFile')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
'test'
|
||||
)
|
||||
);
|
||||
|
||||
$newHandler = new Configuration\Handler($spec2, new Configuration\Parser\Yaml());
|
||||
|
||||
$configuration->setConfigurationHandler($newHandler);
|
||||
|
||||
$this->assertEquals('test', $configuration->getConfigurationHandler()->getSpecification()->getMainConfigurationFile());
|
||||
}
|
||||
|
||||
public function testBadDoctrineLogger()
|
||||
{
|
||||
$spec = $this->getMock(
|
||||
'\Alchemy\Phrasea\Core\Configuration\Application'
|
||||
, array('getMainConfigurationFile')
|
||||
);
|
||||
|
||||
$fileName = __DIR__ . '/confTestFiles/bad_doctrine_logger.yml';
|
||||
|
||||
$spec->expects($this->any())
|
||||
->method('getMainConfigurationFile')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
new \SplFileObject($fileName)
|
||||
)
|
||||
);
|
||||
|
||||
$handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml());
|
||||
|
||||
$environnement = 'main';
|
||||
$configuration = new PhraseaCore\Configuration($environnement, $handler);
|
||||
|
||||
try
|
||||
{
|
||||
$configuration->getDoctrine();
|
||||
$this->fail('An exception should be raised');
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
164
lib/unitTest/Core/Configuration/HandlerTest.php
Normal file
164
lib/unitTest/Core/Configuration/HandlerTest.php
Normal file
@@ -0,0 +1,164 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
|
||||
|
||||
use Alchemy\Phrasea\Core\Configuration;
|
||||
use Alchemy\Phrasea\Core\Configuration\Application;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class handlerTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
||||
{
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testGetSpec()
|
||||
{
|
||||
$spec = $this->getMock(
|
||||
'\Alchemy\Phrasea\Core\Configuration\Application'
|
||||
, array('getMainConfigurationFile')
|
||||
);
|
||||
|
||||
$fileName = __DIR__ . '/confTestFiles/good.yml';
|
||||
|
||||
$spec->expects($this->any())
|
||||
->method('getMainConfigurationFile')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
new \SplFileObject($fileName)
|
||||
)
|
||||
);
|
||||
|
||||
$handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml());
|
||||
|
||||
$this->assertInstanceOf('\Alchemy\Phrasea\Core\Configuration\Specification', $handler->getSpecification());
|
||||
}
|
||||
|
||||
public function testGetParser()
|
||||
{
|
||||
$spec = $this->getMock(
|
||||
'\Alchemy\Phrasea\Core\Configuration\Application'
|
||||
, array('getMainConfigurationFile')
|
||||
);
|
||||
|
||||
$fileName = __DIR__ . '/confTestFiles/good.yml';
|
||||
|
||||
$spec->expects($this->any())
|
||||
->method('getMainConfigurationFile')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
new \SplFileObject($fileName)
|
||||
)
|
||||
);
|
||||
|
||||
$handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml());
|
||||
|
||||
$this->assertInstanceOf('\Alchemy\Phrasea\Core\Configuration\Parser', $handler->getParser());
|
||||
}
|
||||
|
||||
public function testRetrieveExtendedEnvFromFile()
|
||||
{
|
||||
|
||||
$handler = new Configuration\Handler(new Application(), new Configuration\Parser\Yaml());
|
||||
|
||||
$fileName = __DIR__ . '/confTestFiles/config_test.yml';
|
||||
$file = new \SplFileObject($fileName);
|
||||
|
||||
$envs = $handler->retrieveExtendedEnvFromFile($file);
|
||||
|
||||
$this->assertEquals(3, count($envs));
|
||||
}
|
||||
|
||||
public function testRetrieveExtendedEnvFromFileNonExisting()
|
||||
{
|
||||
|
||||
$handler = new Configuration\Handler(new Application(), new Configuration\Parser\Yaml());
|
||||
|
||||
$fileName = __DIR__ . '/confTestFiles/extends_non_existing_file.yml';
|
||||
$file = new \SplFileObject($fileName);
|
||||
|
||||
try
|
||||
{
|
||||
$envs = $handler->retrieveExtendedEnvFromFile($file);
|
||||
$this->fail('An exception should have been raised');
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function testHandle()
|
||||
{
|
||||
$spec = $this->getMock(
|
||||
'\Alchemy\Phrasea\Core\Configuration\Application'
|
||||
, array('getConfigurationFilePath')
|
||||
);
|
||||
|
||||
$spec->expects($this->any())
|
||||
->method('getConfigurationFilePath')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
__DIR__ . '/confTestFiles'
|
||||
)
|
||||
);
|
||||
|
||||
$handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml());
|
||||
|
||||
$result = $handler->handle('test');
|
||||
|
||||
$this->assertTrue(is_array($result));
|
||||
}
|
||||
|
||||
public function testHandleDataNotfound()
|
||||
{
|
||||
$spec = $this->getMock(
|
||||
'\Alchemy\Phrasea\Core\Configuration\Application'
|
||||
, array('getConfigurationFilePath', 'getNonExtendablePath')
|
||||
);
|
||||
|
||||
$spec->expects($this->any())
|
||||
->method('getConfigurationFilePath')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
__DIR__ . '/confTestFiles'
|
||||
)
|
||||
);
|
||||
|
||||
$spec->expects($this->any())
|
||||
->method('getNonExtendablePath')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
array(array('NON', 'EXISTING', 'VALUE'))
|
||||
)
|
||||
);
|
||||
|
||||
$handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml());
|
||||
|
||||
$result = $handler->handle('test');
|
||||
|
||||
$this->assertTrue(is_array($result));
|
||||
}
|
||||
|
||||
}
|
64
lib/unitTest/Core/Configuration/ParserTest.php
Normal file
64
lib/unitTest/Core/Configuration/ParserTest.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
|
||||
|
||||
use Alchemy\Phrasea\Core as PhraseaCore;
|
||||
use Alchemy\Phrasea\Core\Configuration\Parser\Yaml;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class parserTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
||||
{
|
||||
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testParser()
|
||||
{
|
||||
$parser = new Yaml();
|
||||
|
||||
$filename = $fileName = __DIR__ . '/confTestFiles/good.yml';
|
||||
|
||||
$file = new SplFileObject($filename);
|
||||
|
||||
$result = $parser->parse($file);
|
||||
|
||||
$this->assertTrue(is_array($result));
|
||||
|
||||
$filename = $fileName = __DIR__ . '/confTestFiles/test.json';
|
||||
|
||||
$file = new SplFileObject($filename);
|
||||
|
||||
try
|
||||
{
|
||||
$result = $parser->parse($file);
|
||||
$this->fail('An exception shoud have been raised');
|
||||
}
|
||||
catch(Exception $e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,60 @@
|
||||
## YAML Template.
|
||||
---
|
||||
phraseanet:
|
||||
servername: http://dev.phrasea.net/
|
||||
maintenance: false
|
||||
debug: false
|
||||
display_errors: false
|
||||
|
||||
# Twig Configuration
|
||||
twig:
|
||||
debug: false
|
||||
strict_variables: true
|
||||
|
||||
# Doctrine Configuration
|
||||
doctrine:
|
||||
dbal:
|
||||
driver: pdo_mysql
|
||||
host: localhost
|
||||
port: 3306
|
||||
dbname: ab_trunk
|
||||
user: root
|
||||
password: nicolas007
|
||||
charset: UTF8
|
||||
|
||||
orm:
|
||||
auto_generate_proxy_classes: %phraseanet.debug%
|
||||
auto_mapping: true
|
||||
cache:
|
||||
query: array
|
||||
result: array
|
||||
metadata: array
|
||||
|
||||
log:
|
||||
enable: true
|
||||
type: bad_logger
|
||||
handler: rotate
|
||||
output: json
|
||||
filename: doctrine-query.log
|
||||
max_day: 10
|
||||
|
||||
# Monolog LOG Configuration
|
||||
monolog:
|
||||
output: yaml
|
||||
handlers:
|
||||
main:
|
||||
type: stream
|
||||
level: debug
|
||||
rotate:
|
||||
type: rotatingFile
|
||||
level: debug
|
||||
max_day: 10
|
||||
|
||||
# Memchache Configuration
|
||||
memcached:
|
||||
host: 11211
|
||||
|
||||
|
||||
|
||||
|
||||
|
60
lib/unitTest/Core/Configuration/confTestFiles/config.yml
Normal file
60
lib/unitTest/Core/Configuration/confTestFiles/config.yml
Normal file
@@ -0,0 +1,60 @@
|
||||
## YAML Template.
|
||||
---
|
||||
phraseanet:
|
||||
servername: http://dev.phrasea.net/
|
||||
maintenance: false
|
||||
debug: false
|
||||
display_errors: false
|
||||
|
||||
# Twig Configuration
|
||||
twig:
|
||||
debug: false
|
||||
strict_variables: true
|
||||
|
||||
# Doctrine Configuration
|
||||
doctrine:
|
||||
dbal:
|
||||
driver: pdo_mysql
|
||||
host: localhost
|
||||
port: 3306
|
||||
dbname: ab_trunk
|
||||
user: root
|
||||
password: nicolas007
|
||||
charset: UTF8
|
||||
|
||||
orm:
|
||||
auto_generate_proxy_classes: %phraseanet.debug%
|
||||
auto_mapping: true
|
||||
cache:
|
||||
query: array
|
||||
result: array
|
||||
metadata: array
|
||||
|
||||
log:
|
||||
enable: false
|
||||
type: monolog
|
||||
handler: rotate
|
||||
output: json
|
||||
filename: doctrine-query.log
|
||||
max_day: 10
|
||||
|
||||
# Monolog LOG Configuration
|
||||
monolog:
|
||||
output: yaml
|
||||
handlers:
|
||||
main:
|
||||
type: stream
|
||||
level: debug
|
||||
rotate:
|
||||
type: rotatingFile
|
||||
level: debug
|
||||
max_day: 10
|
||||
|
||||
# Memchache Configuration
|
||||
memcached:
|
||||
host: 11211
|
||||
|
||||
|
||||
|
||||
|
||||
|
19
lib/unitTest/Core/Configuration/confTestFiles/config_dev.yml
Normal file
19
lib/unitTest/Core/Configuration/confTestFiles/config_dev.yml
Normal file
@@ -0,0 +1,19 @@
|
||||
## YAML Template.
|
||||
---
|
||||
extends: main
|
||||
|
||||
phraseanet:
|
||||
debug: true
|
||||
|
||||
|
||||
doctrine:
|
||||
orm:
|
||||
cache:
|
||||
query: array
|
||||
result: array
|
||||
metadata: array
|
||||
log:
|
||||
enable: true
|
||||
output: json
|
||||
rotate:
|
||||
max_day: 2
|
@@ -0,0 +1,2 @@
|
||||
## YAML Template.
|
||||
---
|
@@ -0,0 +1,12 @@
|
||||
## YAML Template.
|
||||
---
|
||||
|
||||
# Doctrine Configuration
|
||||
doctrine:
|
||||
orm:
|
||||
cache:
|
||||
query: apc
|
||||
result: memcached
|
||||
metadata: apc
|
||||
log:
|
||||
enable: true
|
@@ -0,0 +1,10 @@
|
||||
## YAML Template.
|
||||
---
|
||||
|
||||
extends: dev
|
||||
|
||||
doctrine:
|
||||
dbal:
|
||||
driver: pdo_sqlite
|
||||
path: /Users/nicolasl/workspace/phraseanet/lib/unitTest/tests.sqlite
|
||||
charset: UTF8
|
@@ -0,0 +1,5 @@
|
||||
## YAML Template.
|
||||
---
|
||||
|
||||
|
||||
extends: unknow
|
60
lib/unitTest/Core/Configuration/confTestFiles/good.yml
Normal file
60
lib/unitTest/Core/Configuration/confTestFiles/good.yml
Normal file
@@ -0,0 +1,60 @@
|
||||
## YAML Template.
|
||||
---
|
||||
phraseanet:
|
||||
servername: http://dev.phrasea.net/
|
||||
maintenance: false
|
||||
debug: false
|
||||
display_errors: false
|
||||
|
||||
# Twig Configuration
|
||||
twig:
|
||||
debug: false
|
||||
strict_variables: true
|
||||
|
||||
# Doctrine Configuration
|
||||
doctrine:
|
||||
dbal:
|
||||
driver: pdo_mysql
|
||||
host: localhost
|
||||
port: 3306
|
||||
dbname: ab_trunk
|
||||
user: root
|
||||
password: nicolas007
|
||||
charset: UTF8
|
||||
|
||||
orm:
|
||||
auto_generate_proxy_classes: %phraseanet.debug%
|
||||
auto_mapping: true
|
||||
cache:
|
||||
query: array
|
||||
result: array
|
||||
metadata: array
|
||||
|
||||
log:
|
||||
enable: true
|
||||
type: monolog
|
||||
handler: rotate
|
||||
output: json
|
||||
filename: doctrine-query.log
|
||||
max_day: 10
|
||||
|
||||
# Monolog LOG Configuration
|
||||
monolog:
|
||||
output: yaml
|
||||
handlers:
|
||||
main:
|
||||
type: stream
|
||||
level: debug
|
||||
rotate:
|
||||
type: rotatingFile
|
||||
level: debug
|
||||
max_day: 10
|
||||
|
||||
# Memchache Configuration
|
||||
memcached:
|
||||
host: 11211
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -0,0 +1,59 @@
|
||||
## YAML Template.
|
||||
---
|
||||
phraseanet:
|
||||
servername: http://dev.phrasea.net/
|
||||
maintenance: false
|
||||
debug: false
|
||||
display_errors: false
|
||||
|
||||
# Twig Configuration
|
||||
twig:
|
||||
debug: false
|
||||
strict_variables: true
|
||||
|
||||
# Doctrine Configuration
|
||||
doctrine:
|
||||
dbal:
|
||||
driver: pdo_mysql
|
||||
host: localhost
|
||||
port: 3306
|
||||
dbname: ab_trunk
|
||||
user: root
|
||||
password: nicolas007
|
||||
charset: UTF8
|
||||
|
||||
orm:
|
||||
auto_generate_proxy_classes: %phraseanet.debug%
|
||||
auto_mapping: true
|
||||
cache:
|
||||
query: array
|
||||
result: array
|
||||
metadata: array
|
||||
|
||||
log:
|
||||
enable: true
|
||||
type: monolog
|
||||
handler: rotate
|
||||
filename: doctrine-query.log
|
||||
max_day: 10
|
||||
|
||||
# Monolog LOG Configuration
|
||||
monolog:
|
||||
output: yaml
|
||||
handlers:
|
||||
main:
|
||||
type: stream
|
||||
level: debug
|
||||
rotate:
|
||||
type: rotatingFile
|
||||
level: debug
|
||||
max_day: 10
|
||||
|
||||
# Memchache Configuration
|
||||
memcached:
|
||||
host: 11211
|
||||
|
||||
|
||||
|
||||
|
||||
|
@@ -0,0 +1,59 @@
|
||||
## YAML Template.
|
||||
---
|
||||
phraseanet:
|
||||
servername: http://dev.phrasea.net/
|
||||
maintenance: false
|
||||
debug: false
|
||||
display_errors: false
|
||||
|
||||
# Twig Configuration
|
||||
twig:
|
||||
debug: false
|
||||
strict_variables: true
|
||||
|
||||
# Doctrine Configuration
|
||||
doctrine:
|
||||
dbal:
|
||||
driver: pdo_mysql
|
||||
host: localhost
|
||||
port: 3306
|
||||
dbname: ab_trunk
|
||||
user: root
|
||||
password: nicolas007
|
||||
charset: UTF8
|
||||
|
||||
orm:
|
||||
auto_generate_proxy_classes: %phraseanet.debug%
|
||||
auto_mapping: true
|
||||
cache:
|
||||
query: array
|
||||
result: array
|
||||
metadata: array
|
||||
|
||||
log:
|
||||
enable: true
|
||||
type: monolog
|
||||
handler: rotate
|
||||
filename: doctrine-query.log
|
||||
max_day: 10
|
||||
|
||||
# Monolog LOG Configuration
|
||||
monolog:
|
||||
output: yaml
|
||||
handlers:
|
||||
main:
|
||||
type: stream
|
||||
level: debug
|
||||
rotate:
|
||||
type: rotatingFile
|
||||
level: debug
|
||||
max_day: 10
|
||||
|
||||
# Memchache Configuration
|
||||
memcached:
|
||||
host: 11211
|
||||
|
||||
|
||||
|
||||
|
||||
|
12
lib/unitTest/Core/Configuration/confTestFiles/test.json
Normal file
12
lib/unitTest/Core/Configuration/confTestFiles/test.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"meta": {
|
||||
"api_version": "1.0",
|
||||
"request": "GET /api/v1/feeds/288/content/",
|
||||
"response_time": "2011-07-27T15:52:04+02:00",
|
||||
"http_code": 200,
|
||||
"error_message": null,
|
||||
"error_details": null,
|
||||
"charset": "UTF-8"
|
||||
},
|
||||
"response": {}
|
||||
}
|
87
lib/unitTest/Core/Service/DoctrineTest.php
Normal file
87
lib/unitTest/Core/Service/DoctrineTest.php
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../../PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
|
||||
|
||||
use Alchemy\Phrasea\Core\Service\Doctrine;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Alchemy\Phrasea\Core as PhraseaCore;
|
||||
use Alchemy\Phrasea\Core\Configuration;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class DoctrineTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var \Alchemy\Phrasea\Core\Configuration\Application
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testInitialize()
|
||||
{
|
||||
try
|
||||
{
|
||||
$spec = $this->getMock(
|
||||
'\Alchemy\Phrasea\Core\Configuration\Application'
|
||||
, array('getMainConfigurationFile')
|
||||
);
|
||||
|
||||
$fileName = __DIR__ . '/../Configuration/confTestFiles/good.yml';
|
||||
|
||||
$spec->expects($this->any())
|
||||
->method('getMainConfigurationFile')
|
||||
->will(
|
||||
$this->returnValue(
|
||||
new SplFileObject($fileName)
|
||||
)
|
||||
);
|
||||
|
||||
$handler = new Configuration\Handler($spec, new Configuration\Parser\Yaml());
|
||||
|
||||
$environnement = 'main';
|
||||
$configuration = new PhraseaCore\Configuration($environnement, $handler);
|
||||
|
||||
$doctrineService = new Doctrine();
|
||||
$doctrineService = new Doctrine($configuration->getDoctrine());
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
$this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public function testGetVersion()
|
||||
{
|
||||
$doctrineService = new Doctrine();
|
||||
$this->assertTrue(is_string($doctrineService->getVersion()));
|
||||
}
|
||||
|
||||
public function testGetEntityManager()
|
||||
{
|
||||
$doctrineService = new Doctrine();
|
||||
$this->assertInstanceOf('\Doctrine\ORM\EntityManager', $doctrineService->getEntityManager());
|
||||
}
|
||||
|
||||
}
|
48
lib/unitTest/Core/VersionTest.php
Normal file
48
lib/unitTest/Core/VersionTest.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of Phraseanet
|
||||
*
|
||||
* (c) 2005-2010 Alchemy
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
require_once __DIR__ . '/../PhraseanetPHPUnitAuthenticatedAbstract.class.inc';
|
||||
|
||||
use Alchemy\Phrasea\Core\Version;
|
||||
|
||||
/**
|
||||
*
|
||||
* @package
|
||||
* @license http://opensource.org/licenses/gpl-3.0 GPLv3
|
||||
* @link www.phraseanet.com
|
||||
*/
|
||||
class VersionTest extends PhraseanetPHPUnitAuthenticatedAbstract
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var \Alchemy\Phrasea\Core\Configuration\Application
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
{
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testGetNumber()
|
||||
{
|
||||
$this->assertTrue(is_string(Version::getName()));
|
||||
}
|
||||
|
||||
public function testGetName()
|
||||
{
|
||||
$this->assertTrue(is_string(Version::getNumber()));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user