12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- class ConfigTest extends PHPUnit_Framework_TestCase {
- public function setUp()
- {
- IoC::container()->singletons = array();
- }
-
- public function testHasMethodReturnsTrueWhenItemExists($mock, $mocker)
- {
- $mocker->will($this->returnValue('value'));
- $this->assertTrue($mock->has('something'));
- }
-
- public function testHasMethodReturnsFalseWhenItemDoesntExist($mock, $mocker)
- {
- $mocker->will($this->returnValue(null));
- $this->assertFalse($mock->has('something'));
- }
- public function getGetMocker()
- {
- $mock = $this->getMock('Laravel\\Config', array('get'), array(null));
- return array(array($mock, $mock->expects($this->any())->method('get')));
- }
- public function testConfigClassCanRetrieveItems()
- {
- $config = IoC::container()->config;
- $this->assertTrue(is_array($config->get('application')));
- $this->assertEquals($config->get('application.url'), 'http://localhost');
- }
- public function testGetMethodReturnsDefaultWhenItemDoesntExist()
- {
- $config = IoC::container()->config;
- $this->assertNull($config->get('config.item'));
- $this->assertEquals($config->get('config.item', 'test'), 'test');
- $this->assertEquals($config->get('config.item', function() {return 'test';}), 'test');
- }
- public function testConfigClassCanSetItems()
- {
- $config = IoC::container()->config;
- $config->set('application.names.test', 'test');
- $config->set('application.url', 'test');
- $config->set('session', array());
- $config->set('test', array());
- $this->assertEquals($config->get('application.names.test'), 'test');
- $this->assertEquals($config->get('application.url'), 'test');
- $this->assertEquals($config->get('session'), array());
- $this->assertEquals($config->get('test'), array());
- }
- }
|