Files
spa-api/tests/Cases/ConfigTest.php

41 lines
1.3 KiB
PHP
Raw Normal View History

2011-10-10 22:17:22 -05:00
<?php namespace Laravel; use PHPUnit_Framework_TestCase;
2011-09-04 23:55:28 -05:00
class ConfigTest extends PHPUnit_Framework_TestCase {
2011-10-10 22:17:22 -05:00
public function test_has_method_indicates_if_configuration_item_exists()
2011-09-06 23:29:19 -05:00
{
Config::set('hasvalue', true);
$this->assertTrue(Config::has('hasvalue'));
2011-09-06 23:29:19 -05:00
}
2011-10-10 22:17:22 -05:00
public function test_has_method_returns_false_when_item_doesnt_exist()
2011-09-04 23:55:28 -05:00
{
$this->assertFalse(Config::has('something'));
2011-09-04 23:55:28 -05:00
}
2011-10-10 22:17:22 -05:00
public function test_config_get_can_retrieve_item_from_configuration()
2011-09-04 23:55:28 -05:00
{
$this->assertTrue(is_array(Config::get('application')));
$this->assertEquals(Config::get('application.url'), 'http://localhost');
2011-09-04 23:55:28 -05:00
}
2011-10-10 22:17:22 -05:00
public function test_get_method_returns_default_when_requested_item_doesnt_exist()
2011-09-04 23:55:28 -05:00
{
$this->assertNull(Config::get('config.item'));
$this->assertEquals(Config::get('config.item', 'test'), 'test');
$this->assertEquals(Config::get('config.item', function() {return 'test';}), 'test');
2011-09-04 23:55:28 -05:00
}
2011-10-10 22:17:22 -05:00
public function test_config_set_can_set_configuration_items()
2011-09-04 23:55:28 -05:00
{
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());
2011-09-04 23:55:28 -05:00
}
}