1 use Test::More tests => 9;
6 use_ok( 'WWW::OpenSearch::Description' );
7 use_ok( 'WWW::OpenSearch::Request' );
10 my $description = q(<?xml version="1.0" encoding="UTF-8"?>
11 <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
12 <Url type="application/rss+xml"
13 template="http://example.com/?q={searchTerms}&pw={startPage}&format=rss"/>
14 <Url type="application/atom+xml"
15 template="http://example.com/?q={searchTerms}&pw={startPage?}&format=atom"/>
18 template="https://intranet/search?format=html">
19 <Param name="s" value="{searchTerms}"/>
20 <Param name="o" value="{startIndex?}"/>
21 <Param name="c" value="{itemsPerPage?}"/>
22 <Param name="l" value="{language?}"/>
24 </OpenSearchDescription>
27 my $osd = WWW::OpenSearch::Description->new( $description );
30 my $req = WWW::OpenSearch::Request->new( $osd->url->[ 2 ], { searchTerms => 'iPod' } );
31 isa_ok( $req, 'WWW::OpenSearch::Request' );
32 is( lc $req->method, 'post', 'method' );
33 is( $req->uri, 'https://intranet/search?format=html', 'uri' );
34 is( $req->content, 'l=*&c=&s=iPod&o=1', 'content' );
38 my $req = WWW::OpenSearch::Request->new( $osd->url->[ 1 ], { searchTerms => 'iPod' } );
39 isa_ok( $req, 'WWW::OpenSearch::Request' );
40 is( lc $req->method, 'get', 'method' );
41 is( $req->uri, 'http://example.com/?q=iPod&pw=1&format=atom', 'uri' );