complete configuration testes

This commit is contained in:
Nicolas Le Goff
2012-01-23 18:57:44 +01:00
parent 86cc4febdd
commit 86c85cfaa7
2 changed files with 62 additions and 11 deletions

View File

@@ -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)
{
}
}
}

View File

@@ -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)
{
}
}
}