-
Notifications
You must be signed in to change notification settings - Fork 37
/
13_search.t
37 lines (27 loc) · 830 Bytes
/
13_search.t
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
#!perl
use warnings;
use strict;
use Test::More;
use lib qw(t/lib);
eval 'use TestUA';
plan skip_all => 'LWP::UserAgent 5.819 required' if $@;
plan tests => 3;
use Net::Twitter;
my $nt = Net::Twitter->new(traits => [qw/API::Search/]);
my $request;
my %args;
my $response = HTTP::Response->new(200, 'OK');
$response->content('{"test":"success"}');
$nt->ua->add_handler(request_send => sub {
$request = shift;
$response->request($request);
%args = $request->uri->query_form;
return $response;
});
my $search_term = "intelligent life";
my $r = $nt->search($search_term);
isa_ok $r, 'HASH', "result is expected type";
is $args{q}, $search_term, "param q has search term";
# additional args in a HASH ref
$r = $nt->search($search_term, { page => 2 });
is $args{page}, 2, "page parameter set";