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" );