File: cookie_jar.t

package info (click to toggle)
libwww-perl 6.78-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,008 kB
  • sloc: perl: 4,148; makefile: 10; sh: 6
file content (42 lines) | stat: -rw-r--r-- 1,154 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!perl

use strict;
use warnings;

use Test::More;
use Test::Fatal qw( exception );

use_ok 'LWP::UserAgent';

my $ua = LWP::UserAgent->new( cookie_jar => {} );
isa_ok $ua->cookie_jar, 'HTTP::Cookies';

$ua = LWP::UserAgent->new;
is $ua->cookie_jar, undef, 'no cookie_jar by default';
$ua->cookie_jar( {} );
note '... but setting one from hash uses default cookie_jar_class';
isa_ok $ua->cookie_jar, 'HTTP::Cookies';

$ua = LWP::UserAgent->new( cookie_jar_class => 'HTTP::CookieJar::LWP' );
$ua->cookie_jar( {} );
isa_ok $ua->cookie_jar, 'HTTP::CookieJar::LWP';

$ua = LWP::UserAgent->new( cookie_jar_class => 'HTTP::CookieJar::LWP' );
is $ua->cookie_jar, undef,
    'no cookie jar by default despite cookie_jar_class being set';

$ua = LWP::UserAgent->new(
    cookie_jar_class => 'HTTP::CookieJar::LWP',
    cookie_jar       => {}
);
note 'cookie_jar and cookie_jar_class can be ued together';
isa_ok $ua->cookie_jar, 'HTTP::CookieJar::LWP';

ok exception {
    LWP::UserAgent->new(
        cookie_jar_class => 'HTTP::CookieMonster::WasHere',
        cookie_jar       => {},
    )
}, 'dies when the cookie_jar_class cannot be loaded';

done_testing();