Apache2::Dummy::RequestRec - dummy Apache request record class for testing
version 1.0
Test and debug Apache2 mod_perl handlers without running an apache server.
use JSON; use Test::More; sub catch_stdout { ... } sub unescapeURIString { ... } sub test_http_handler { my ($handler, $exp_res, $cl, $ct, @params) = @_; my $r = Apache2::Dummy::RequestRec->new(ref($params[0]) ? { params => $params[0] } : @params); my $params = ref($params[0]) ? { params => $params[0] } : { @params }; my $ares = catch_stdout(sub { &$handler($r); }); my $body = $r->body; ok($r->headers_out->{'Content-Length'} == $cl, "Content-Length == $cl"); ok($r->headers_out->{'Content-Type'} eq $ct, "Content-Type: '$ct'"); my $result = $ct =~ /json/i ? from_json(unescapeURIString($body)) : $body; ok(Compare($result, $exp_res), "body"); } test_http_handler('My::Apache::Request::handler', { redirect => "https://localhost/" }, 55, 'application/json', login => 'mylogin', password => 'mypasswd');
Apache2::Dummy::RequestRec can be used to test Apache2 mod_perl request handlers without an actual web server running. The difference to other similar modules is, that it uses APR::Table and APR::Pool to act much more like a real Apache.
Jens Fischer <jeff@lipsia.de>
This software is copyright (c) 2021 by Jens Fischer.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Apache2::Dummy::RequestRec, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Apache2::Dummy::RequestRec
CPAN shell
perl -MCPAN -e shell install Apache2::Dummy::RequestRec
For more information on module installation, please visit the detailed CPAN module installation guide.