refactoring test structure.

This commit is contained in:
Taylor Otwell
2011-07-13 23:14:51 -05:00
parent d3398db56f
commit 537139a2ca
10 changed files with 197 additions and 150 deletions

View File

@@ -75,6 +75,12 @@ class InputTest extends PHPUnit_Framework_TestCase {
$this->assertFalse(System\Input::has('name'));
}
public function testHasMethodReturnsFalseIfItemIsInInputButIsEmptyString()
{
System\Input::$input = array('name' => '');
$this->assertFalse(System\Input::has('name'));
}
public function testGetMethodReturnsItemByInputKey()
{
System\Input::$input = array('name' => 'taylor');
@@ -87,6 +93,7 @@ class InputTest extends PHPUnit_Framework_TestCase {
$this->assertNull(System\Input::get('name'));
$this->assertEquals(System\Input::get('name', 'test'), 'test');
$this->assertEquals(System\Input::get('name', function() {return 'test';}), 'test');
$this->assertTrue(is_array(System\Input::get()) and count(System\Input::get()) == 0);
}
@@ -108,6 +115,15 @@ class InputTest extends PHPUnit_Framework_TestCase {
$this->assertEquals(System\Input::file('test.size'), 500);
}
public function testAllMethodReturnsBothGetAndFileArrays()
{
$_GET['name'] = 'test';
$_FILES['picture'] = array();
$this->assertArrayHasKey('name', System\Input::all());
$this->assertArrayHasKey('picture', System\Input::all());
}
/**
* @expectedException Exception
*/
@@ -132,6 +148,17 @@ class InputTest extends PHPUnit_Framework_TestCase {
$this->assertEquals(System\Input::old('name'), 'taylor');
}
public function testOldMethodReturnsDefaultValueWhenItemDoesntExist()
{
System\Config::set('session.driver', 'test');
System\Session::$session['data']['laravel_old_input'] = array();
$this->assertNull(System\Input::old('name'));
$this->assertEquals(System\Input::old('name', 'test'), 'test');
$this->assertEquals(System\Input::old('name', function() {return 'test';}), 'test');
$this->assertTrue(is_array(System\Input::old()) and count(System\Input::old()) == 0);
}
public function testHadMethodReturnsTrueIfItemIsPresentInOldInputData()
{
System\Config::set('session.driver', 'test');