root/HTTP-MobileAgent/trunk/t/01_request.t

Revision 773 (checked in by miyagawa, 18 years ago)

Initial revision

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1 use strict;
2 use Test::More tests => 9;
3
4 BEGIN { use_ok 'HTTP::MobileAgent' }
5
6 # various way to make request
7
8 my $ua = "Mozilla/1.0";
9
10 {
11     my $agent = HTTP::MobileAgent->new($ua);
12     isa_ok $agent, 'HTTP::MobileAgent';
13     is $agent->user_agent, $ua;
14 }
15
16 {
17     local $ENV{HTTP_USER_AGENT} = $ua;
18     my $agent = HTTP::MobileAgent->new($ua);
19     isa_ok $agent, 'HTTP::MobileAgent';
20     is $agent->user_agent, $ua;
21 }
22
23 SKIP: {
24     eval { require HTTP::Headers; };
25     skip "no HTTP::Headers", 2 if $@;
26
27     my $header = HTTP::Headers->new;
28     $header->header('User-Agent' => $ua);
29     my $agent = HTTP::MobileAgent->new($header);
30     isa_ok $agent, 'HTTP::MobileAgent';
31     is $agent->user_agent, $ua;
32 }
33
34 {
35     # mock object
36     package Apache;
37     sub header_in {
38         my($r, $header) = @_;
39         return $r->{$header};
40     }
41
42     package main;
43     my $r = bless { 'User-Agent' => $ua }, 'Apache';
44     my $agent = HTTP::MobileAgent->new($r);
45     isa_ok $agent, 'HTTP::MobileAgent';
46     is $agent->user_agent, $ua;
47 }
Note: See TracBrowser for help on using the browser.