perl/modules/WebService/Validator/Feed/t WebService-Validator-Feed-W3C.t,1.1,1.2

Update of /sources/public/perl/modules/WebService/Validator/Feed/t
In directory hutz:/tmp/cvs-serv27024/t

Modified Files:
	WebService-Validator-Feed-W3C.t 
Log Message:
using POST instead of GET as a workaround for 'Request-URI Too Large' issue + test suite improvements, both courtesy of Stephen Rushe

Index: WebService-Validator-Feed-W3C.t
===================================================================
RCS file: /sources/public/perl/modules/WebService/Validator/Feed/t/WebService-Validator-Feed-W3C.t,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- WebService-Validator-Feed-W3C.t	18 Nov 2005 08:03:16 -0000	1.1
+++ WebService-Validator-Feed-W3C.t	23 Jan 2009 20:46:00 -0000	1.2
@@ -3,22 +3,63 @@
 
 #########################
 
-# change 'tests => 3' to 'tests => last_test_to_print';
-
+use lib qw(../lib);
 use Test;
-BEGIN { plan tests => 3 };
+BEGIN { plan tests => 10 }
 use WebService::Validator::Feed::W3C;
-ok(1); # If we made it this far, we're ok.
- my $val = WebService::Validator::Feed::W3C->new;
-ok(2);
-my $success = $val->validate(uri => 'http://www.w3.org/2003/05/Software/Overview.rss');
-printf "  * %s\n", $_->{message}
-        foreach $val->errors;
-ok(3);
-my $som = $val->som;
-print $som;
-#########################
+# Test new
+my $val = WebService::Validator::Feed::W3C->new;
+ok(ref($val), 'WebService::Validator::Feed::W3C',
+  "The object should be a WebService::Validator::Feed::W3C but isn't");
 
-# Insert your test code below, the Test::More module is use()ed here so read
-# its man page ( perldoc Test::More ) for help writing this test script.
+# Test a simple validate succeeds in the hitting the server
+{
+  ok($val->validate(uri => 'http://www.w3.org/2003/05/Software/Overview.rss'));
+}
 
+# Test that a valid feed send through "string" is regarded as valid
+{
+  my $content = <<'VALID';
+<rss version="2.0">
+<channel>
+<title>Valid link</title>
+<description>valid item link (http)</description>
+<link>http://purl.org/rss/2.0/</link>
+<item>
+<title>Valid link</title>
+<link>http://purl.org/rss/2.0/#item</link>
+</item>
+</channel>
+</rss>
+VALID
+
+  ok($val->validate(string => $content));
+  ok($val->is_valid);
+  ok(scalar $val->errors, undef, "No errors were returned");
+  ok(ref $val->warnings, 'HASH', "Warnings were returned");
+}
+
+# Test that an invalid feed send through "string" is regarded as invalid
+{
+  sleep(1); # Be nice to the validator
+ 
+  my $content = <<'INVALID';
+  <rss version="2.0">
+  <channel>
+  <title>Invalid link</title>
+  <description>item link must be full URL, including protocol</description>
+  <link>http://purl.org/rss/2.0/</link>
+  <item>
+  <title>Invalid link</title>
+  <link>purl.org/rss/2.0/#item</link>
+  </item>
+  </channel>
+  </rss>
+INVALID
+  
+  ok($val->validate(string => $content));
+  
+  ok(!$val->is_valid);
+  ok(scalar $val->errors > 0);
+  ok(scalar $val->warnings > 0);
+}

Received on Friday, 23 January 2009 20:46:18 UTC