removed application and resolver classes. added phpunit tests.

This commit is contained in:
Taylor Otwell
2011-09-04 23:19:14 -05:00
parent d35e2abd77
commit cb8e8194ce
14 changed files with 146 additions and 88 deletions

51
tests/ArrTest.php Normal file
View File

@@ -0,0 +1,51 @@
<?php
class ArrTest extends PHPUnit_Framework_TestCase {
/**
* @dataProvider getArray
*/
public function testGetMethodReturnsItemsFromArray($array)
{
$this->assertEquals(Arr::get($array, 'email'), $array['email']);
$this->assertEquals(Arr::get($array, 'names.uncle'), $array['names']['uncle']);
}
/**
* @dataProvider getArray
*/
public function testGetMethodReturnsDefaultWhenItemDoesntExist($array)
{
$this->assertNull(Arr::get($array, 'names.aunt'));
$this->assertEquals(Arr::get($array, 'names.aunt', 'Tammy'), 'Tammy');
$this->assertEquals(Arr::get($array, 'names.aunt', function() {return 'Tammy';}), 'Tammy');
}
/**
* @dataProvider getArray
*/
public function testSetMethodSetsItemsInArray($array)
{
Arr::set($array, 'name', 'Taylor');
Arr::set($array, 'names.aunt', 'Tammy');
Arr::set($array, 'names.friends.best', 'Abigail');
$this->assertEquals($array['name'], 'Taylor');
$this->assertEquals($array['names']['aunt'], 'Tammy');
$this->assertEquals($array['names']['friends']['best'], 'Abigail');
}
public function getArray()
{
return array(array(
array(
'email' => 'taylorotwell@gmail.com',
'names' => array(
'uncle' => 'Mike',
),
)
));
}
}

34
tests/bootstrap.php Normal file
View File

@@ -0,0 +1,34 @@
<?php
/**
* Laravel - A clean and classy framework for PHP web development.
*
* @package Laravel
* @version 2.0.0
* @author Taylor Otwell <taylorotwell@gmail.com>
* @link http://laravel.com
*/
/*
|--------------------------------------------------------------------------
| Installation Paths
|--------------------------------------------------------------------------
|
| Here you may specify the location of the various Laravel framework
| directories for your installation.
|
| Of course, these are already set to the proper default values, so you do
| not need to change them if you have not modified the directory structure.
|
*/
$application = 'application';
$laravel = 'laravel';
$packages = 'packages';
$storage = 'storage';
$public = 'public';
require realpath($laravel).'/bootstrap.php';