X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=t%2Fmaypole.t;h=4c07d21b2834f0a044de9b6983beabadc0baa72f;hb=a542064c7699bbb4773d878d9a161f02542b9fbc;hp=a537732db572a608fe8726e04ea4fbe8f9234d3f;hpb=b65ee86d592a4038c2bd7f354a29894145758893;p=maypole.git diff --git a/t/maypole.t b/t/maypole.t index a537732..4c07d21 100755 --- a/t/maypole.t +++ b/t/maypole.t @@ -1,7 +1,7 @@ #!/usr/bin/perl use strict; use warnings; -use Test::More tests => 103; +use Test::More tests => 108; use Test::MockModule; # module compilation @@ -14,6 +14,7 @@ ok($Maypole::VERSION, 'defines $VERSION'); ok($INC{'Maypole/Config.pm'}, 'loads Maypole::Config'); ok($INC{'UNIVERSAL/require.pm'}, 'loads UNIVERSAL::require'); ok($INC{'Maypole/Constants.pm'}, 'loads Maypole::Constants'); +ok($INC{'Maypole/Headers.pm'}, 'loads Maypole::Headers'); ok($INC{'Class/Accessor/Fast.pm'}, 'loads Class::Accessor::Fast'); ok($INC{'Class/Data/Inheritable.pm'}, 'loads Class::Data::Inheritable'); ok(Maypole->can('config'), 'defines a config attribute'); @@ -37,6 +38,8 @@ ok(Maypole->can('error'), 'defines an "error" accessor'); ok(Maypole->can('document_encoding'), 'defines a "document_encoding" accessor'); ok(Maypole->can('content_type'), 'defines a "content_type" accessor'); ok(Maypole->can('table'), 'defines a "table" accessor'); +ok(Maypole->can('headers_in'), 'defines a "headers_in" accessor'); +ok(Maypole->can('headers_out'), 'defines a "headers_out" accessor'); # simple test class that inherits from Maypole package MyDriver; @@ -127,11 +130,13 @@ my ($r, $req); # request objects my $rv = $driver_class->handler(); ok($r && $r->isa($driver_class), '... created $r'); ok($called{get_request}, '... calls get_request()'); - ok($called{get_request}, '... calls parse_location'); - ok($called{get_request}, '... calls handler_guts()'); - ok($called{get_request}, '... call send_output'); + ok($called{parse_location}, '... calls parse_location'); + ok($called{handler_guts}, '... calls handler_guts()'); + ok($called{send_output}, '... call send_output'); is($rv, 0, '... return status (should be ok?)'); ok(!$init, "... doesn't call init() if init_done()"); + ok($r->headers_out && $r->headers_out->isa('Maypole::Headers'), + '... populates headers_out() with a Maypole::Headers object'); # call again, testing other branches $driver_class->init_done(0); $status = -1; @@ -301,8 +306,7 @@ is($r->path, 'frontpage', '... path() defaults to "frontpage"'); $r->path('/table'); $r->parse_path; is($r->table, 'table', '... parses "table" from the first part of path'); -ok(!defined $r->action && @{$r->args} == 0, - '... leaving "action" undefined, and "args" as empty list, if not present'); +ok(@{$r->args} == 0, '... "args" default to empty list'); $r->path('/table/action'); $r->parse_path; @@ -314,6 +318,11 @@ $r->parse_path; is_deeply($r->args, [qw(arg1 arg2)], '... "args" are populated from remaning components'); +# ... action defaults to index +$r->path('/table'); +$r->parse_path; +is($r->action, 'index', '... action defaults to index'); + # get_template_root() can_ok(Maypole => 'get_template_root'); is(Maypole->get_template_root(), '.', '... returns "."');