APR-Emulate-PSGI
view release on metacpan or search on metacpan
t/10_psgi.t view on Meta::CPAN
use strict;
use warnings;
use Test::More;
use APR::Emulate::PSGI;
use IO::File;
plan('tests' => 21);
# Set up filehandles needed in the PSGI environment.
my $error_string;
my $request_body = 'hello=world';
my $response_body = 'howdy';
open my $fh_in, '<', \do { $request_body };
open my $fh_errors, '>', \$error_string;
# Set up PSGI environment.
my $psgi_env = {
'REMOTE_ADDR' => '192.168.1.1',
'REQUEST_METHOD' => 'POST',
'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
'CONTENT_LENGTH' => length($request_body),
'HTTP_HOK' => 'gahaha',
'psgi.errors' => $fh_errors,
'psgi.input' => $fh_in,
};
# Create instance.
my $r = APR::Emulate::PSGI->new($psgi_env);
isa_ok(
$r,
'APR::Emulate::PSGI',
'Object is instantiated.',
);
# Verify that data is going in as expected (request).
SKIP: {
skip(
'Not yet implemented: $r->connection()',
1,
) unless $r->can('connection');
is(
$r->connection()->remote_ip(),
'192.168.1.1',
'Remote address is available.',
);
}
is(
$r->method(),
'POST',
'Request method is available.',
);
is(
$r->headers_in()->header('CONTENT_TYPE'),
'application/x-www-form-urlencoded',
'Content-type is available.',
);
is(
$r->headers_in()->header('CONTENT_LENGTH'),
length($request_body),
'Content length is available.',
);
( run in 0.586 second using v1.01-cache-2.11-cpan-39bf76dae61 )