X-Git-Url: http://erislabs.net/gitweb/?p=libwww-opensearch-perl.git;a=blobdiff_plain;f=t%2F10-description.t;h=3eacf72bed706353c4e0ca05bfc13c375562cadc;hp=784face2ea4d9dafe8d45dcd15f1c39d95c76bff;hb=1fc70f0d6badbef9bb483990d761d1446d52cbb2;hpb=ec50391b25e981b1b9bae8e42e03c0fc9c218845 diff --git a/t/10-description.t b/t/10-description.t index 784face..3eacf72 100644 --- a/t/10-description.t +++ b/t/10-description.t @@ -1,7 +1,7 @@ use strict; use warnings; -use Test::More tests => 38; +use Test::More tests => 48; use_ok( 'WWW::OpenSearch::Description' ); @@ -20,14 +20,14 @@ use_ok( 'WWW::OpenSearch::Description' ); my $osd = WWW::OpenSearch::Description->new( $description ); isa_ok( $osd, 'WWW::OpenSearch::Description' ); - is( $osd->shortname, 'Web Search' ); - ok( !defined $osd->longname ); - is( $osd->description, 'Use Example.com to search the Web.' ); - is( $osd->tags, 'example web' ); - is( $osd->contact, 'admin@example.com' ); + is( $osd->shortname, 'Web Search', 'shortname' ); + ok( !defined $osd->longname, 'longname' ); + is( $osd->description, 'Use Example.com to search the Web.', 'description' ); + is( $osd->tags, 'example web', 'tags' ); + is( $osd->contact, 'admin@example.com', 'contact' ); # count the urls - is( $osd->urls, 1 ); + is( $osd->urls, 1, 'number of url objects' ); } # complex 1.1 OSD @@ -68,30 +68,39 @@ use_ok( 'WWW::OpenSearch::Description' ); my $osd = WWW::OpenSearch::Description->new( $description ); isa_ok( $osd, 'WWW::OpenSearch::Description' ); - is( $osd->shortname, 'Web Search' ); - is( $osd->longname, 'Example.com Web Search' ); - is( $osd->description, 'Use Example.com to search the Web.' ); - is( $osd->tags, 'example web' ); - is( $osd->contact, 'admin@example.com' ); - is( $osd->developer, 'Example.com Development Team' ); + is( $osd->shortname, 'Web Search', 'shortname' ); + is( $osd->longname, 'Example.com Web Search', 'longname' ); + is( $osd->description, 'Use Example.com to search the Web.', 'description' ); + is( $osd->tags, 'example web', 'tags' ); + is( $osd->contact, 'admin@example.com', 'contact' ); + is( $osd->developer, 'Example.com Development Team', 'developer' ); is( $osd->attribution, ' Search data © 2005, Example.com, Inc., All Rights Reserved - ' ); - is( $osd->inputencoding, 'UTF-8' ); - is( $osd->outputencoding, 'UTF-8' ); - is( $osd->language, 'en-us' ); - is( $osd->adultcontent, 'false' ); - is( $osd->syndicationright, 'open' ); + ', 'attribution' ); + is( $osd->inputencoding, 'UTF-8', 'inputencoding' ); + is( $osd->outputencoding, 'UTF-8', 'outputencoding' ); + is( $osd->language, 'en-us', 'language' ); + is( $osd->adultcontent, 'false', 'adultcontent' ); + is( $osd->syndicationright, 'open', 'syndicationright' ); - TODO: { - local $TODO = 'Test Query and Image'; + my $queries = $osd->query; + is( scalar @$queries, 1, 'number of query objects' ); + is( $queries->[ 0 ]->role, 'example', 'role' ); + is( $queries->[ 0 ]->searchTerms, 'cat', 'searchTerms' ); - is( $osd->query, undef ); - is( $osd->image, undef ); - }; + my $images = $osd->image; + is( scalar @$images, 2, 'number of image objects' ); + is( $images->[ 0 ]->height, 64, 'height' ); + is( $images->[ 0 ]->width, 64, 'width' ); + is( $images->[ 0 ]->type, 'image/png', 'content type' ); + is( $images->[ 0 ]->url, 'http://example.com/websearch.png', 'url' ); + is( $images->[ 1 ]->height, 16, 'height' ); + is( $images->[ 1 ]->width, 16, 'width' ); + is( $images->[ 1 ]->type, 'image/vnd.microsoft.icon', 'content type' ); + is( $images->[ 1 ]->url, 'http://example.com/websearch.ico', 'url' ); # count the urls - is( $osd->urls, 3 ); + is( $osd->urls, 3, 'number of url objects' ); } # 1.0 OSD @@ -118,21 +127,20 @@ use_ok( 'WWW::OpenSearch::Description' ); my $osd = WWW::OpenSearch::Description->new( $description ); isa_ok( $osd, 'WWW::OpenSearch::Description' ); - is( $osd->shortname, 'Electronics' ); - is( $osd->longname, 'Amazon Electronics' ); - is( $osd->description, 'Search for electronics on Amazon.com.' ); - is( $osd->tags, 'amazon electronics' ); - is( $osd->contact, 'dewitt@unto.net' ); - is( $osd->format, 'http://a9.com/-/spec/opensearchrss/1.0/' ); - is( $osd->image, 'http://www.unto.net/search/amazon_electronics.gif' ); - is( $osd->samplesearch, 'ipod' ); - is( $osd->developer, 'DeWitt Clinton' ); + is( $osd->shortname, 'Electronics', 'shortname' ); + is( $osd->longname, 'Amazon Electronics', 'longname' ); + is( $osd->description, 'Search for electronics on Amazon.com.', 'descrpiton' ); + is( $osd->tags, 'amazon electronics', 'tags' ); + is( $osd->contact, 'dewitt@unto.net', 'contact' ); + is( $osd->format, 'http://a9.com/-/spec/opensearchrss/1.0/', 'format' ); + is( $osd->image, 'http://www.unto.net/search/amazon_electronics.gif', 'image' ); + is( $osd->samplesearch, 'ipod', 'samplesearch' ); + is( $osd->developer, 'DeWitt Clinton', 'developer' ); is( $osd->attribution, 'Product and search data © 2005, Amazon, Inc., - All Rights Reserved' ); - is( $osd->syndicationright, 'open' ); - is( $osd->adultcontent, 'false' ); + All Rights Reserved', 'attribution' ); + is( $osd->syndicationright, 'open', 'syndicationright' ); + is( $osd->adultcontent, 'false', 'adultcontent' ); # count the urls - is( $osd->urls, 1 ); + is( $osd->urls, 1, 'urls' ); } -