4 use Test::More tests => 27;
6 use_ok( 'WWW::OpenSearch::Description' );
7 use_ok( 'WWW::OpenSearch::Url' );
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 </OpenSearchDescription>
17 my $osd = WWW::OpenSearch::Description->new( $description );
18 isa_ok( $osd, 'WWW::OpenSearch::Description' );
21 my( $url ) = $osd->urls;
22 isa_ok( $url, 'WWW::OpenSearch::Url' );
23 is( $url->type, 'application/rss+xml' );
24 is( lc $url->method, 'get' );
25 is( $url->template, 'http://example.com/?q=%7BsearchTerms%7D&pw=%7BstartPage%7D&format=rss' );
29 my $description = q(<?xml version="1.0" encoding="UTF-8"?>
30 <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
31 <Url type="application/rss+xml"
32 template="http://example.com/?q={searchTerms}&pw={startPage}&format=rss"/>
33 <Url type="application/atom+xml"
34 template="http://example.com/?q={searchTerms}&pw={startPage?}&format=atom"/>
37 template="https://intranet/search?format=html">
38 <Param name="s" value="{searchTerms}"/>
39 <Param name="o" value="{startIndex?}"/>
40 <Param name="c" value="{itemsPerPage?}"/>
41 <Param name="l" value="{language?}"/>
43 </OpenSearchDescription>
46 my $osd = WWW::OpenSearch::Description->new( $description );
47 isa_ok( $osd, 'WWW::OpenSearch::Description' );
51 my $url = $osd->url->[ 0 ];
52 isa_ok( $url, 'WWW::OpenSearch::Url' );
53 is( $url->type, 'application/rss+xml' );
54 is( lc $url->method, 'get' );
55 is( $url->template, 'http://example.com/?q=%7BsearchTerms%7D&pw=%7BstartPage%7D&format=rss' );
59 my $url = $osd->url->[ 1 ];
60 isa_ok( $url, 'WWW::OpenSearch::Url' );
61 is( $url->type, 'application/atom+xml' );
62 is( lc $url->method, 'get' );
63 is( $url->template, 'http://example.com/?q=%7BsearchTerms%7D&pw=%7BstartPage%7D&format=atom' );
67 my $url = $osd->url->[ 2 ];
68 isa_ok( $url, 'WWW::OpenSearch::Url' );
69 is( $url->type, 'text/html' );
70 is( lc $url->method, 'post' );
71 is( $url->template, 'https://intranet/search?format=html' );
76 my $description = q(<?xml version="1.0" encoding="UTF-8"?>
77 <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearchdescription/1.0/">
78 <Url>http://www.unto.net/aws?q={searchTerms}&searchindex=Electronics&flavor=osrss&itempage={startPage}</Url>
79 </OpenSearchDescription>
82 my $osd = WWW::OpenSearch::Description->new( $description );
83 isa_ok( $osd, 'WWW::OpenSearch::Description' );
86 my( $url ) = $osd->urls;
87 isa_ok( $url, 'WWW::OpenSearch::Url' );
88 is( lc $url->method, 'get' );
89 is( $url->template, 'http://www.unto.net/aws?q=%7BsearchTerms%7D&searchindex=Electronics&flavor=osrss&itempage=%7BstartPage%7D' );