Apache2-ASP
view release on metacpan or search on metacpan
lib/Apache2/ASP/ErrorHandler.pm view on Meta::CPAN
use strict;
use warnings 'all';
use base 'Apache2::ASP::ErrorHandler';
use vars __PACKAGE__->VARS;
sub run {
my ($s, $context) = @_;
my $error = $Stash->{error};
# $error looks like this:
$VAR1 = {
title => 'Cannot call execute with a reference',
file => '/tmp/PAGE_CACHE/mysite/index_asp.pm',
line => 45,
stacktrace => # Output from Carp::confess,
};
# Do something here about the error.
}
lib/Apache2/ASP/Test/Fixtures.pm view on Meta::CPAN
=head2 as_hash( )
Returns a hash or hashref or your test fixture data, depending on the context in which
this method is called.
=head1 PUBLIC PROPERTIES
Each top-level node in your YAML file is assigned a public accessor.
So if your YAML looks something like this
---
message:
greeting:
english: Hello
spanish: Hola
french: Bonjour
You would get an object with a public accessor named C<message> with an accessor named C<greeting>
with accessors named C<english>, C<spanish> and C<french>.
t/010-coverage/070-response.t view on Meta::CPAN
# Set Status after headers have been sent:
#{
# eval {
# $api->context->response->Status( 200 );
# };
# ok( $@, 'threw an exception' );
# like
# $@,
# qr/Response\.Status cannot be changed after headers have been sent/,
# 'exception looks correct';
# is(
# $api->context->response->Status => 200
# );
#}
# ContentType:
{
local $api->context->{_did_send_headers};
t/010-coverage/070-response.t view on Meta::CPAN
ok( my $val = $api->context->response->Redirect('/other.asp'), 'redirected' );
is( $val => 302, 'response.redirect returns 302' );
eval {
$api->context->response->Redirect('/fail.asp');
};
ok( $@, 'respons.redirect again threw exception' );
like $@,
qr/Response\.Redirect cannot be called after headers have been sent/,
'exception looks right';
}
# Include after the request ended:
{
# Should NOT throw exception:
eval {
$api->context->response->Include( $api->context->server->MapPath('/inc.asp' ) );
};
ok( ! $@, 'no exception thrown' );
t/010-coverage/070-response.t view on Meta::CPAN
# TrapInclude(2):
{
local $api->context->{did_end};
ok(
my $res = $api->context->response->TrapInclude( $api->context->server->MapPath('/inc.asp' ) ),
'got response.trapinclude content'
);
like $res,
qr/\s+Included\! 1\:2\:3\:4\:5\:6\:7\:8\:9\:10\s+/,
'TrapInclude content looks right';
}
# Cookies:
{
is( $api->context->response->Cookies => undef, 'response.cookies starts out undef' );
$api->context->response->AddCookie(
'test-cookie' => '123'
);
like(
$api->context->response->Cookies, qr/test\-cookie\=123; path\=\/; expires\=.*?\s+GMT/i,
'response.Cookies looks right after adding a single cookie'
);
$api->context->response->AddCookie(
'another-cookie' => 'foobar'
);
# Now we should have an arrayref of cookies:
is(
ref($api->context->response->Cookies) => 'ARRAY',
'two cookies makes an array'
);
t/010-coverage/070-response.t view on Meta::CPAN
$api->context->response->Cookies->[1], qr/another\-cookie\=foobar; path\=\/; expires\=.*?\s+GMT/i,
'The second cookie is in the second position'
);
# Test out the other options:
$api->context->response->AddCookie(
'path-cookie' => 'pathtest' => '/path/'
);
like(
$api->context->response->Cookies->[2], qr/path\-cookie\=pathtest; path\=\/path\/; expires\=.*?\s+GMT/i,
'Path cookie looks right and is in the correct position'
);
my $five_minutes = time2str( time() + 300 );
$api->context->response->AddCookie(
'expire-cookie' => 'expiretest' => '/expires/' => time() + 300
);
is(
$api->context->response->Cookies->[3], "expire-cookie=expiretest; path=/expires/; expires=$five_minutes",
'Expiration cookie looks right and is in the correct position'
);
}
# DeleteHeader:
{
$api->context->response->AddHeader( 'removable' => 'test' );
( run in 0.747 second using v1.01-cache-2.11-cpan-64827b87656 )