Router
Router copied to clipboard
Write tests
Hello !
I want to write tests for Hoa\Router but I don't know how to start :)
Can you help me ? /ping @Hywan
Thx !
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
Having this example https://github.com/hoaproject/Iterator/blob/master/Test/Unit/Append.php helps?
Well, I finally manage to run my own tests but I'm now stuck on "how to test". Here is my first test :
$this
->given(
$r = new CUT(),
$r->get('u', '/hello', function ( ) {
echo 'world!', "\n";
})
)
->when(
$result = $r->route('/hello')
)
->then(
);
but I don't know what to write in the then
part ? Test if a rule matched ? Test the rule ?
Maybe with
->then($rule = $r->getTheRule()):
$this->array($rule)->string[\Hoa\Router::RULE_CALL]->isEqual('...')
Or anything like that, your test its more for test Router + Dispatcher for the test the "ouput" of the route
Just calling getTheRule
is fine I think. And use CUT::RULE_CALL
instead of Hoa\Ruler
by the way ;-).
(but :+1: for @camael24!)