mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-12 12:33:26 +00:00
complete configuration testes
This commit is contained in:
@@ -67,8 +67,6 @@ class handlerTest extends \PhraseanetPHPUnitAbstract
|
||||
$this->assertInstanceOf('\Alchemy\Phrasea\Core\Configuration\Parser', $handler->getParser());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function testHandle()
|
||||
{
|
||||
try
|
||||
@@ -135,4 +133,40 @@ class handlerTest extends \PhraseanetPHPUnitAbstract
|
||||
}
|
||||
}
|
||||
|
||||
public function testHandleException()
|
||||
{
|
||||
$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());
|
||||
|
||||
try
|
||||
{
|
||||
$result = $handler->handle('unknowEnv');
|
||||
$this->fail($e->getMessage());
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -22,21 +22,21 @@ use Alchemy\Phrasea\Core\Configuration\Parser\Yaml;
|
||||
*/
|
||||
class parserTest extends \PhraseanetPHPUnitAbstract
|
||||
{
|
||||
|
||||
|
||||
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
|
||||
@@ -44,11 +44,28 @@ class parserTest extends \PhraseanetPHPUnitAbstract
|
||||
$result = $parser->parse($file);
|
||||
$this->fail('An exception shoud have been raised');
|
||||
}
|
||||
catch(Exception $e)
|
||||
catch (Exception $e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function testDumper()
|
||||
{
|
||||
$parser = new Yaml();
|
||||
|
||||
$test = array("hello" => "you");
|
||||
|
||||
try
|
||||
{
|
||||
$result = $parser->dump($test);
|
||||
$this->assertTrue(is_string($result));
|
||||
$this->assertRegexp("#hello: you#", $result);
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user