| Server IP : 45.40.142.9 / Your IP : 216.73.216.66 Web Server : Apache System : Linux s45-40-142-9.secureserver.net 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64 User : bayspec ( 506) PHP Version : 5.6.40 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /.cpanm/work/1494616241.5243/HTTP-Tiny-0.070/t/ |
Upload File : |
#!perl
use strict;
use warnings;
use Test::More tests => 4;
use lib 't';
use SimpleCookieJar;
use BrokenCookieJar;
use HTTP::Tiny;
### a couple tests to ensure that:
### * by default there is no cookie jar defined
### * the correct cookie jar is returned when specified
### * error when cookie jar does not support the add and cookie_header methods
my $default = undef;
my $jar = SimpleCookieJar->new();
my $mug = BrokenCookieJar->new();
my $dog = BrokenCookieJar2->new();
{
my $ua = HTTP::Tiny->new();
is $ua->cookie_jar, $default, 'default cookie jar is as expected';
}
{
my $ua = HTTP::Tiny->new(cookie_jar => $jar);
is $ua->cookie_jar, $jar, 'cookie_jar is as expected';
}
{
my $ua = eval { HTTP::Tiny->new(cookie_jar => $mug) };
my $err = $@;
like( $err, qr/must provide .* 'add' method/
=> 'invalid jar does not support add method' );
$ua = eval { HTTP::Tiny->new(cookie_jar => $dog) };
$err = $@;
like( $err, qr/must provide .* 'cookie_header' method/
=> 'invalid jar does not support cookie_header method' );
}