Changeset 31018

Show
Ignore:
Timestamp:
03/10/09 18:55:34 (4 years ago)
Author:
yappo
Message:

add HTTP::Engine::Test::Request pod

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/HTTP-Engine/trunk/lib/HTTP/Engine/Test/Request.pm

    r31016 r31018  
    81811; 
    8282 
    83  
    8483__END__ 
    8584 
     85=encoding utf8 
    8686 
     87=head1 NAME 
     88 
     89HTTP::Engine::Test::Request - HTTP::Engine request object builder for test 
     90 
     91=head1 SYNOPSIS 
     92 
     93    use HTTP::Engine::Test::Request; 
     94 
     95    # simple query 
     96    my $req = HTTP::Engine::Test::Request->new( 
     97        uri => 'http://example.com/?foo=bar&bar=baz' 
     98    ); 
     99    is $req->method, 'GET', 'GET method'; 
     100    is $req->address, '127.0.0.1', 'remote address'; 
     101    is $req->uri, 'http://example.com/?foo=bar&bar=baz', 'uri'; 
     102    is_deeply $req->parameters, { foo => 'bar', bar => 'baz' }, 'query params'; 
     103 
     104    # use headers 
     105    my $req = HTTP::Engine::Test::Request->new( 
     106        uri     => 'http://example.com/', 
     107        headers => { 
     108            'Content-Type' => 'text/plain', 
     109        }, 
     110    ); 
     111    is $req->header('content-type'), 'text/plain', 'content-type'; 
     112 
     113    # by HTTP::Request object 
     114    my $req = HTTP::Engine::Test::Request->new( 
     115        HTTP::Request->new( 
     116            GET => 'http://example.com/?foo=bar&bar=baz', 
     117            HTTP::Headers::Fast->new( 
     118                'Content-Type' => 'text/plain', 
     119            ), 
     120        ) 
     121    ); 
     122 
     123    is $req->method, 'GET', 'GET method'; 
     124    is $req->address, '127.0.0.1', 'remote address'; 
     125    is $req->uri, 'http://example.com/?foo=bar&bar=baz', 'uri'; 
     126    is_deeply $req->parameters, { foo => 'bar', bar => 'baz' }, 'query params'; 
     127    is $req->header('content-type'), 'text/plain', 'content-type'; 
     128 
     129 
     130=head1 DESCRIPTION 
     131 
     132HTTP::Engine::Test::Request is HTTP::Engine request object builder. 
     133 
     134Please use in a your test. 
     135 
     136=head1 SEE ALSO 
     137 
     138L<HTTP::Engine::Request> 
     139 
     140=head1 AUTHOR 
     141 
     142Kazuhiro Osawa E<lt>ko@yappo.ne.jpE<gt>