added tests to develop branch.

This commit is contained in:
Taylor Otwell
2012-03-27 15:41:30 -05:00
parent f4258f7759
commit 15fe1d5258
80 changed files with 6510 additions and 0 deletions

59
tests/cases/uri.test.php Normal file
View File

@@ -0,0 +1,59 @@
<?php
class URITest extends PHPUnit_Framework_TestCase {
/**
* Destroy the test environment.
*/
public function tearDown()
{
$_SERVER = array();
URI::$uri = null;
URI::$segments = array();
}
/**
* Test the URI::current method.
*
* @group laravel
* @dataProvider requestUriProvider
*/
public function testCorrectURIIsReturnedByCurrentMethod($uri, $expectation)
{
$_SERVER['REQUEST_URI'] = $uri;
$this->assertEquals($expectation, URI::current());
}
/**
* Test the URI::segment method.
*
* @group laravel
*/
public function testSegmentMethodReturnsAURISegment()
{
$_SERVER['REQUEST_URI'] = 'http://localhost/index.php/user/profile';
$this->assertEquals('user', URI::segment(1));
$this->assertEquals('profile', URI::segment(2));
}
/**
* Data provider for the URI::current test.
*/
public function requestUriProvider()
{
return array(
array('/index.php', '/'),
array('/index.php/', '/'),
array('http://localhost/user', 'user'),
array('http://localhost/user/', 'user'),
array('http://localhost/index.php', '/'),
array('http://localhost/index.php/', '/'),
array('http://localhost/index.php//', '/'),
array('http://localhost/index.php/user', 'user'),
array('http://localhost/index.php/user/', 'user'),
array('http://localhost/index.php/user/profile', 'user/profile'),
);
}
}