X-Git-Url: http://erislabs.net/gitweb/?p=libwww-opensearch-perl.git;a=blobdiff_plain;f=t%2F11-url.t;fp=t%2F11-url.t;h=44ccb818a3308df1271aa191132007796ab2f0dc;hp=0000000000000000000000000000000000000000;hb=ec50391b25e981b1b9bae8e42e03c0fc9c218845;hpb=3bea9ee9d57430b70d78dc4bed903b395bb4356a
diff --git a/t/11-url.t b/t/11-url.t
new file mode 100644
index 0000000..44ccb81
--- /dev/null
+++ b/t/11-url.t
@@ -0,0 +1,91 @@
+use strict;
+use warnings;
+
+use Test::More tests => 27;
+
+use_ok( 'WWW::OpenSearch::Description' );
+use_ok( 'WWW::OpenSearch::Url' );
+
+{
+ my $description = q(
+
+
+
+);
+
+ my $osd = WWW::OpenSearch::Description->new( $description );
+ isa_ok( $osd, 'WWW::OpenSearch::Description' );
+ is( $osd->urls, 1 );
+
+ my( $url ) = $osd->urls;
+ isa_ok( $url, 'WWW::OpenSearch::Url' );
+ is( $url->type, 'application/rss+xml' );
+ is( lc $url->method, 'get' );
+ is( $url->template, 'http://example.com/?q=%7BsearchTerms%7D&pw=%7BstartPage%7D&format=rss' );
+}
+
+{
+ my $description = q(
+
+
+
+
+
+
+
+
+
+
+);
+
+ my $osd = WWW::OpenSearch::Description->new( $description );
+ isa_ok( $osd, 'WWW::OpenSearch::Description' );
+ is( $osd->urls, 3 );
+
+ {
+ my $url = $osd->url->[ 0 ];
+ isa_ok( $url, 'WWW::OpenSearch::Url' );
+ is( $url->type, 'application/rss+xml' );
+ is( lc $url->method, 'get' );
+ is( $url->template, 'http://example.com/?q=%7BsearchTerms%7D&pw=%7BstartPage%7D&format=rss' );
+ }
+
+ {
+ my $url = $osd->url->[ 1 ];
+ isa_ok( $url, 'WWW::OpenSearch::Url' );
+ is( $url->type, 'application/atom+xml' );
+ is( lc $url->method, 'get' );
+ is( $url->template, 'http://example.com/?q=%7BsearchTerms%7D&pw=%7BstartPage%7D&format=atom' );
+ }
+
+ {
+ my $url = $osd->url->[ 2 ];
+ isa_ok( $url, 'WWW::OpenSearch::Url' );
+ is( $url->type, 'text/html' );
+ is( lc $url->method, 'post' );
+ is( $url->template, 'https://intranet/search?format=html' );
+ }
+}
+
+{
+ my $description = q(
+
+ http://www.unto.net/aws?q={searchTerms}&searchindex=Electronics&flavor=osrss&itempage={startPage}
+
+);
+
+ my $osd = WWW::OpenSearch::Description->new( $description );
+ isa_ok( $osd, 'WWW::OpenSearch::Description' );
+ is( $osd->urls, 1 );
+
+ my( $url ) = $osd->urls;
+ isa_ok( $url, 'WWW::OpenSearch::Url' );
+ is( lc $url->method, 'get' );
+ is( $url->template, 'http://www.unto.net/aws?q=%7BsearchTerms%7D&searchindex=Electronics&flavor=osrss&itempage=%7BstartPage%7D' );
+}
+