Commit e05b05a3 authored by Taylor Otwell's avatar Taylor Otwell

added route loader tests.

parent 0a2587d2
<?php use Laravel\Routing\Loader;
class RouteLoaderTest extends PHPUnit_Framework_TestCase {
public function test_loader_can_load_base_routes()
{
$loader = $this->getLoader();
$routes = $loader->load('/');
$this->assertEquals(count($routes), 2);
$this->assertTrue(array_key_exists('GET /', $routes));
$this->assertTrue(array_key_exists('GET /root', $routes));
}
public function test_loader_can_load_single_nested_routes()
{
$loader = $this->getLoader();
$routes = $loader->load('user');
$this->assertEquals(count($routes), 4);
$this->assertTrue(array_key_exists('GET /user', $routes));
$this->assertTrue(array_key_exists('GET /user/profile', $routes));
}
public function test_loader_can_load_multi_nested_routes()
{
$loader = $this->getLoader();
$routes = $loader->load('admin/panel');
$this->assertEquals(count($routes), 4);
$this->assertTrue(array_key_exists('GET /admin/panel/show', $routes));
$this->assertTrue(array_key_exists('GET /admin/panel/update', $routes));
}
public function test_everything_loads_all_routes()
{
$loader = $this->getLoader();
$routes = $loader->everything();
$this->assertEquals(count($routes), 6);
}
private function getLoader()
{
return new Loader(FIXTURE_PATH.'RouteLoader/', FIXTURE_PATH.'RouteLoader/routes/');
}
}
<?php
return array(
'GET /' => function()
{
return 'GET /';
},
'GET /root' => function()
{
return 'GET /root';
},
);
\ No newline at end of file
<?php
return array(
'GET /admin/panel/show' => function()
{
return 'GET /admin/panel/show';
},
'GET /admin/panel/update' => function()
{
return 'GET /admin/panel/update';
},
);
\ No newline at end of file
<?php
return array(
'GET /user' => function()
{
return 'GET /user';
},
'GET /user/profile' => function()
{
return 'GET /user/profile';
},
);
\ No newline at end of file
......@@ -23,4 +23,18 @@ $storage = '../storage';
$public = '../public';
/*
|--------------------------------------------------------------------------
| Test Path Constants
|--------------------------------------------------------------------------
*/
define('FIXTURE_PATH', realpath('Fixtures').'/');
/*
|--------------------------------------------------------------------------
| Bootstrap The Laravel Core
|--------------------------------------------------------------------------
*/
require realpath($laravel).'/bootstrap/core.php';
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment