Ticket Details
A way to load the routes while testing a controller
ENHANCEMENT Ticket (pending)
###What's going on
- you write a test for your controller
- and realize that your routes aren't loaded.
####Example
{{{
<?php
namespace app\tests\cases\controllers;
use lithium\action\Request;
use app\controllers\BlogController;
class BlogControllerTest extends \lithium\test\Unit
{
public function test_index()
{
$request = new Request();
$controller = new BlogController(compact('request'));
$response = $controller($request, $request->params);
// …
}
}
}}}
This breaks because, I'm generating some URL into my view and they aren't found because my `app/config/routes.php` wasn't loaded.
####Dirty fix
{{{
require_once LITHIUM_APP_PATH . '/config/routes.php';
}}}
###What was expected
- to either have a way to load and *unload* the routes
- or that the app (and libraries) routes were already loaded.
###Maybe
- maybe these aren't Unit tests and require something better than `\lithium\test\Unit`
- maybe a lot more is required to be able to do proper Controller testing like fixtures, …
TA
Updates
on 04.13.11
by daschl
on 04.13.11
by greut