1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
#!/usr/bin/perl
use strict;
use warnings;
use Test::More 1.001013;
use Test::Path::Router;
use Path::Router;
my $router = Path::Router->new;
$router->add_route('/wiki/?:page' => (
defaults => {
controller => 'wiki',
page => 'HomePage',
}
));
$router->add_route('/css/:style' => (
defaults => {
controller => 'css'
}
));
is(
$router->uri_for(page => 'whatever'),
'wiki/whatever',
'... got the right URI'
);
is(
$router->uri_for(style => 'mystyle'),
'css/mystyle',
'... got the right URI'
);
is(
$router->uri_for(style => 'wiki'),
'css/wiki',
'... got the right URI'
);
is(
$router->uri_for(controller => 'wiki'),
'wiki',
'defaults correctly excluded (no trailing slash)',
);
done_testing;
|