stas 2003/01/28 17:25:46 Added: t/hooks push_handlers.t t/hooks/TestHooks push_handlers.pm Log: - add a test to exercise push_handlers in different ways - prepare for supporting anon handlers Revision Changes Path 1.1 modperl-2.0/t/hooks/push_handlers.t Index: push_handlers.t =================================================================== use strict; use warnings FATAL => 'all'; use Apache::Test; use Apache::TestUtil; use Apache::TestRequest; plan tests => 1; my @refs = qw(coderef full_coderef coderef1 coderef2 coderef3); my @anon = qw(anonymous anonymous1 coderef4 anonymous3); my @strings = @refs; # XXX: anon-handlers unsupported yet # push @strings, @anon my $location = "/TestHooks::push_handlers"; my $expected = join "\n", @strings, ''; my $received = GET_BODY $location; ok t_cmp($expected, $received, "push_handlers ways"); 1.1 modperl-2.0/t/hooks/TestHooks/push_handlers.pm Index: push_handlers.pm =================================================================== package TestHooks::push_handlers; # test various ways to push handlers use strict; use warnings FATAL => 'all'; use Apache::RequestRec (); use Apache::RequestIO (); use Apache::Const -compile => qw(OK DECLINED DONE); sub handler { my $r = shift; $r->handler("modperl"); $r->push_handlers(PerlResponseHandler => \&start); $r->push_handlers(PerlResponseHandler => \&coderef); $r->push_handlers(PerlResponseHandler => \&TestHooks::push_handlers::full_coderef); $r->push_handlers(PerlResponseHandler => [\&coderef1, \&coderef2, \&coderef3]); # XXX: anon-handlers unsupported yet # $r->push_handlers(PerlResponseHandler => # sub { return say(shift, "anonymous") }); # $r->push_handlers(PerlResponseHandler => # [sub { return say(shift, "anonymous1") }, # \&coderef4, # sub { return say(shift, "anonymous3") }, # ]); $r->push_handlers(PerlResponseHandler => \&end); return Apache::DECLINED; } sub start { shift->content_type('text/plain'); return Apache::OK } sub end { return Apache::DONE } sub say { shift->print(shift,"\n"); return Apache::OK } sub coderef { return say(shift, "coderef") } sub coderef1 { return say(shift, "coderef1") } sub coderef2 { return say(shift, "coderef2") } sub coderef3 { return say(shift, "coderef3") } sub coderef4 { return say(shift, "coderef4") } sub full_coderef { return say(shift, "full_coderef") } 1; __DATA__ <NoAutoConfig> <Location /TestHooks::push_handlers> SetHandler modperl PerlHeaderParserHandler TestHooks::push_handlers </Location> </NoAutoConfig>