Commit 71d300f7 authored by Eric Faerber's avatar Eric Faerber

Fixing bootstrap file for tests and changing ConfigTest to use the static...

Fixing bootstrap file for tests and changing ConfigTest to use the static methods for the Config class.
parent 938c6f4d
...@@ -2,73 +2,42 @@ ...@@ -2,73 +2,42 @@
class ConfigTest extends PHPUnit_Framework_TestCase { class ConfigTest extends PHPUnit_Framework_TestCase {
public static function setUpBeforeClass() public function testHasMethodReturnsTrueWhenItemExists()
{ {
IoC::container()->singletons = array(); Config::set('hasvalue', true);
}
public function tearDown()
{
IoC::container()->singletons = array();
}
/**
* @dataProvider getGetMocker
*/
public function testHasMethodReturnsTrueWhenItemExists($mock, $mocker)
{
$mocker->will($this->returnValue('value'));
$this->assertTrue($mock->has('something'));
}
/**
* @dataProvider getGetMocker
*/
public function testHasMethodReturnsFalseWhenItemDoesntExist($mock, $mocker)
{
$mocker->will($this->returnValue(null));
$this->assertFalse($mock->has('something')); $this->assertTrue(Config::has('hasvalue'));
} }
public function getGetMocker() public function testHasMethodReturnsFalseWhenItemDoesntExist()
{ {
$mock = $this->getMock('Laravel\\Config', array('get'), array(null)); $this->assertFalse(Config::has('something'));
return array(array($mock, $mock->expects($this->any())->method('get')));
} }
public function testConfigClassCanRetrieveItems() public function testConfigClassCanRetrieveItems()
{ {
$config = IoC::container()->resolve('laravel.config'); $this->assertTrue(is_array(Config::get('application')));
$this->assertEquals(Config::get('application.url'), 'http://localhost');
$this->assertTrue(is_array($config->get('application')));
$this->assertEquals($config->get('application.url'), 'http://localhost');
} }
public function testGetMethodReturnsDefaultWhenItemDoesntExist() public function testGetMethodReturnsDefaultWhenItemDoesntExist()
{ {
$config = IoC::container()->resolve('laravel.config'); $this->assertNull(Config::get('config.item'));
$this->assertEquals(Config::get('config.item', 'test'), 'test');
$this->assertNull($config->get('config.item')); $this->assertEquals(Config::get('config.item', function() {return 'test';}), 'test');
$this->assertEquals($config->get('config.item', 'test'), 'test');
$this->assertEquals($config->get('config.item', function() {return 'test';}), 'test');
} }
public function testConfigClassCanSetItems() public function testConfigClassCanSetItems()
{ {
$config = IoC::container()->resolve('laravel.config'); Config::set('application.names.test', 'test');
Config::set('application.url', 'test');
$config->set('application.names.test', 'test'); Config::set('session', array());
$config->set('application.url', 'test'); Config::set('test', array());
$config->set('session', array());
$config->set('test', array());
$this->assertEquals($config->get('application.names.test'), 'test'); $this->assertEquals(Config::get('application.names.test'), 'test');
$this->assertEquals($config->get('application.url'), 'test'); $this->assertEquals(Config::get('application.url'), 'test');
$this->assertEquals($config->get('session'), array()); $this->assertEquals(Config::get('session'), array());
$this->assertEquals($config->get('test'), array()); $this->assertEquals(Config::get('test'), array());
} }
} }
\ No newline at end of file
...@@ -23,4 +23,4 @@ $storage = 'storage'; ...@@ -23,4 +23,4 @@ $storage = 'storage';
$public = 'public'; $public = 'public';
require realpath($laravel).'/core.php'; require realpath($laravel).'/bootstrap/core.php';
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment