Mock::Apache - mock Apache environment for testing and debugging
use Mock::Apache; my $server = Mock::Apache->setup_server(param => 'value', ...); my $request = $server->new_request(method_name => 'value', ...); $server->
Mock::Apache is a mock framework for testing and debugging mod_perl 1.x applications. Although that version of mod_perl is obsolete, there is still a lot of legacy code that uses it. The framework is intended to assist in understanding such code, by enabling it to be run and debugged outside of the web server environment. The framework provides a tracing facility that prints all methods called, optionally with caller information.
Mock::Apache
Mock::Apache is based on Apache::FakeRequest but goes beyond that module, attempting to provide a relatively comprehensive mocking of the mod_perl environment.
Apache::FakeRequest
NOTE: the module is still very much at an alpha stage, with much of the Apache::* classes missing, and much of the emulation incomplete or probably just wrong.
I am aiming to provide top-level methods to "process a request", by giving the mock apache object enough information about the configuration to identify handlers, etc. Perhaps passing the server_setup method the pathname of an Apache configuration file even and minimally "parsing" it.
localizes elements of the %ENV hash
for emulation of Apache::Table (but this is subclassed to emulate pnotes tables, which can store references)
Apache::Table
to pretend that the Apache::* modules are loaded.
Apache::*
for tieing STDOUT to the Apache response
STDOUT
The intent of this package is to provide an emulation of mod_perl 1.3 that that will allow straightforward handlers to be unit-tested outside the Apache/mod_perl environment. However it will probably never provide perfect emulation.
mod_perl
The package is still in an early alpha stage and is known to be incomplete. Feedback and patches to improve the software are most welcome.
https://github.com/fordmason/Mock-Apache
mod_perl Pocket Reference by Andrew Ford, O'Reilly & Associates, Inc, Sebastapol, 2001, ISBN: 0-596-00047-2
Inspired by Apache::FakeRequest by Doug MacEachern, with contributions from Andrew Ford <andrew@ford-mason.co.uk>.
Andrew Ford <andrew@ford-mason.co.uk>
Copyright (C) 2013 Andrew Ford (<andrew@ford-mason.co.uk>). All rights reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
To install Mock::Apache, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mock::Apache
CPAN shell
perl -MCPAN -e shell install Mock::Apache
For more information on module installation, please visit the detailed CPAN module installation guide.