This repository has been archived on 2018-10-11. You can view files and clone it, but cannot push or open issues or pull requests.
sleepy/tests/Core/ConfigTest.php

60 lines
940 B
PHP
Raw Permalink Normal View History

<?php
use Sleepy\Core\Config;
class ConfigTest extends Sleepy_Testcase {
public function setUp()
{
parent::setUp();
$this->config = new MockConfig();
$this->config->setData([
'foo' => [
'bar' => 'baz',
'x' => '-y',
'p !=' => 'np'
],
'apple' => [1,3,5,7,9]
]);
}
public function dataGet()
{
return [
'single value' => [
'file' => 'foo',
'key' => 'x',
'expected' => '-y'
],
'whole array' => [
'file' => 'apple',
'key' => NULL,
'expected' => [1,3,5,7,9]
]
];
}
/**
* @dataProvider dataGet
*/
public function testGet($file, $key, $expected)
{
$res = $this->config->get($file, $key);
$this->assertEquals($expected, $res);
}
public function testBadGet()
{
try
{
$this->config->get('bleucheese');
}
catch (\InvalidArgumentException $e)
{
$this->assertTrue(TRUE, "Proper exception was caught");
}
}
}
// End of ConfigTest.php