in reply to Where can I buy an $r with which to test Apache2::Cookie?

UPDATE: maybe solved. Thanks to everyone for the help.

Having chosen Door Number 3, it seems at least some of it is easier than I'd feared. This, for example, seems to work, except for the last test:

use strict; use warnings; use Test::More tests => 5; use CGI; use Test::MockObject; use Apache2::Cookie 2.08; # This gets me started. my $r = Test::MockObject->new(); $r->mock( pool => sub { return APR::Pool->new; } ); # This part looks good. my $c = Apache2::Cookie->new( $r, # mocked -name => 'mycookie', -value => 'whatever' ) or die "no cookie for you"; isa_ok( $c, 'Apache2::Cookie' ); is( $c->value, 'whatever', "value" ); # This works for some values, but doing random # stuff via chr() can break it. I need to write # more tests to figure out whether that's my fault. my $val = "über die Straße"; my $c2 = Apache2::Cookie->new( $r, # mocked -name => 'mycookie', -value => $val ) or die "no cookie for you"; like( $c2->as_string, qr/[a-zA-Z0-9%=]+/, "as_string encoded" ); is( $c2->value, $val, "value not encoded" ); # Uh-oh, this is busted. I think I can live # without it, but it's annoying. eval { $c2->raw_value(); }; is( $@, '', "raw_value() doesn't die" );

That last test gets me this error:

Can't locate auto/Apache2/Cookie/raw_value.al in @INC

Joy. If it's just a case of the docs being wrong, yet the code working, then I'm OK with that. I can file a documentation bug, with a test and a patch, if I can prove it.

I'm sure I have the right version installed, and as I built it from source I'm also sure all its non-skipped tests.

Replies are listed 'Best First'.
Re^2: Where can I buy an $r with which to test Apache2::Cookie?
by dbooth (Novice) on Jan 04, 2012 at 03:55 UTC

    FYI, I was trying to use Test::MockObject with mod_perl2, but discovered a bug that causes an apache2 child segmentation fault after several successful HTTP requests when running a shell command from the response handler (such as with backticks or system()). Here is a minimal response handler that reproduces the problem:

    #! /usr/bin/perl -w package MyApache2::Chain; use strict; use Apache2::Const -compile => qw(:common); use Apache2::SubRequest (); # for $r->internal_redirect ### Comment out the following line and the Apache2 child ### segmentation fault no longer occurs: use Test::MockObject; sub handler { my $r = shift || die; my $f = $ENV{DOCUMENT_ROOT} . "/date.txt"; system("date >> $f 2> /dev/null"); $r->internal_redirect("/date.txt"); return Apache2::Const::OK; } ##### DO NOT DELETE THE FOLLOWING LINE! ##### 1;

    See my bug report at https://rt.cpan.org/Public/Bug/Display.html?id=73723