Navigation Menu

Skip to content

Commit

Permalink
Unit test for #3017
Browse files Browse the repository at this point in the history
  • Loading branch information
zombor committed Jul 7, 2010
1 parent 08d27e4 commit e56e921
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/kohana/RequestTest.php
Expand Up @@ -126,6 +126,50 @@ function testAcceptLang($params, $expected, $enviroment)
Request::accept_lang($params)
);
}

/**
* Provides test data for Request::url()
* @return array
*/
public function provider_url()
{
return array(
array(
'foo/bar',
array(),
'http',
TRUE,
'http://localhost/foo/bar'
),
array(
'foo',
array('action' => 'bar'),
'http',
TRUE,
'http://localhost/foo/bar'
),
);
}

/**
* Tests Request::url()
*
* @test
* @dataProvider provider_url
* @param string $route the route to use
* @param array $params params to pass to route::uri
* @param string $protocol the protocol to use
* @param array $expected The string we expect
*/
public function test_url($uri, $params, $protocol, $is_cli, $expected)
{
$this->setEnvironment(array(
'_SERVER' => array('HTTP_HOST' => 'localhost', 'argc' => $_SERVER['argc']),
'Kohana::$is_cli' => $is_cli,
));

$this->assertEquals(Request::instance($uri)->url($params, $protocol), $expected);
}
}

class Controller_Foo extends Controller {
Expand Down

0 comments on commit e56e921

Please sign in to comment.