NAME
Test::Mock::Apache2 - Mock mod_perl2 objects when running outside of Apache
VERSION
version 0.05
SYNOPSIS
use Test::Mock::Apache2;
my $r = Apache2::RequestUtil->request();
my $apr_req = APR::Request::Apache2->handle($r);
...
# Add configuration data that $r->dir_config() later can supply
use Test::Mock::Apache2 { MyAppSetting => "foo", MyPort => 1233 };
my $r = Apache2::RequestUtil->request();
my $port = $r->dir_config('MyPort'); # 1233
DESCRIPTION
Allows to work with Apache2::*
objects without a running modperl server.
The purpose of this class is to be able to run some minimal unit tests for a code base that's hopelessly entangled with the Apache internals.
Current state is, to say the least, very incomplete. Will be hopefully expanded as the unit test suite grows.
METHODS
ap2_server
Return a mock Apache2::ServerRec empty object, with the following methods: server_hostname
.
To set the hostname, set a server_hostname
key in the configuration block when using the module.
use Test::Mock::Apache2 { server_hostname => 'localhost.localdomain' };
Default server_hostname
is localhost
.
ap2_request
Return a mock Apache2::RequestRec empty object, with the following methods: hostname
, dir_config
, server
.
ap2_request_ap2
Return a mock APR::Request::Apache2 empty object with the following methods: new
, jar
, param
, handle
.
ap2_requestutil
Mocks the Apache2::RequestUtil> module to fake the +GlobalRequest
option, so you can execute code like:
my $r = Apache2::RequestUtil->request();
and get back an Apache2::RequestRec object. Uses "ap2_request". Supplies the following methods: new
, request
, dir_config
.
init_mocked_objects
Creates the initial instances of the mocked objects for the various Apache2::*
classes.
AUTHOR
Cosimo Streppone <cosimo@opera.com>
COPYRIGHT AND LICENSE
This software is Copyright (c) 2012 by Opera Software ASA.
This is free software, licensed under:
The (three-clause) BSD License