=== t/items-are-0.t
==================================================================
--- t/items-are-0.t (/local/XML-RSS/tags/before-work-on-items-that-are-0) (revision 346)
+++ t/items-are-0.t (/local/XML-RSS/local-trunk) (revision 346)
@@ -0,0 +1,64 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 4;
+
+use XML::RSS;
+
+sub create_rss_1
+{
+ my $args = shift;
+ # my $rss = new XML::RSS (version => '0.9');
+ my $rss = new XML::RSS (version => $args->{version});
+
+ $rss->channel(
+ title => "freshmeat.net",
+ link => "
http://freshmeat.net",
+ description => "the one-stop-shop for all your Linux software needs",
+ );
+
+ $rss->image(
+ title => "freshmeat.net",
+ url => "0",
+ link => "
http://freshmeat.net/"
+ );
+
+ $rss->add_item(
+ title => "GTKeyboard 0.85",
+ link => "
http://freshmeat.net/news/1999/06/21/930003829.html"
+ );
+
+ return $rss;
+}
+
+{
+ my $rss = create_rss_1({version => "0.9"});
+ # TEST
+ like ($rss->as_string, qr{<image>.*?<title>freshmeat.net</title>.*?<url>0</url>.*?<link>
http://freshmeat.net/</link>.*?</image>}s,
+ "Checking for image in RSS 0.9");
+}
+
+{
+ my $rss = create_rss_1({version => "0.91"});
+ # TEST
+ like ($rss->as_string, qr{<image>.*?<title>freshmeat.net</title>.*?<url>0</url>.*?<link>
http://freshmeat.net/</link>.*?</image>}s,
+ "Checking for image in RSS 0.9.1");
+}
+
+# TODO :
+# Test other elements within the <image> tag for zero-ness.
+{
+ my $rss = create_rss_1({version => "1.0"});
+ # TEST
+ like ($rss->as_string, qr{<image rdf:about="0">.*?<title>freshmeat.net</title>.*?<url>0</url>.*?<link>
http://freshmeat.net/</link>.*?</image>}s,
+ "Checking for image in RSS 1.0");
+}
+
+{
+ my $rss = create_rss_1({version => "2.0"});
+ # TEST
+ like ($rss->as_string, qr{<image>.*?<title>freshmeat.net</title>.*?<url>0</url>.*?<link>
http://freshmeat.net/</link>.*?</image>}s,
+ "Checking for image in RSS 2.0");
+}
=== t/test_manifest
==================================================================
--- t/test_manifest (/local/XML-RSS/tags/before-work-on-items-that-are-0) (revision 346)
+++ t/test_manifest (/local/XML-RSS/local-trunk) (revision 346)
@@ -12,4 +12,5 @@
encode-output.t
enclosures.t
auto_add_modules.t
+items-are-0.t
rss2-gt-encoding.t
=== MANIFEST
==================================================================
--- MANIFEST (/local/XML-RSS/tags/before-work-on-items-that-are-0) (revision 346)
+++ MANIFEST (/local/XML-RSS/local-trunk) (revision 346)
@@ -44,6 +44,7 @@
t/enclosures.t
t/encode-output.t
t/encoding.t
+t/items-are-0.t
t/load.t
t/pod.t
t/rss2-gt-encoding.t
=== lib/XML/RSS.pm
==================================================================
--- lib/XML/RSS.pm (/local/XML-RSS/tags/before-work-on-items-that-are-0) (revision 346)
+++ lib/XML/RSS.pm (/local/XML-RSS/local-trunk) (revision 346)
@@ -632,7 +632,7 @@
#################
# image element #
#################
- if ($self->{image}->{url}) {
+ if (defined($self->{image}->{url})) {
$output .= '<image>'."\n";
# title
@@ -757,7 +757,7 @@
#################
# image element #
#################
- if ($self->{image}->{url}) {
+ if (defined($self->{image}->{url})) {
$output .= '<image>'."\n";
# title
@@ -953,9 +953,9 @@
if ( exists( $rdf_resource_fields{ $url } ) and
exists( $rdf_resource_fields{ $url }{ $el }) )
{
- $output .= qq!<$prefix:$el rdf:resource="! .
+ $output .= qq{<$prefix:$el rdf:resource="} .
$self->encode($value) .
- qq!" />\n!;
+ qq{" />\n};
}
else {
$output .= "<$prefix:$el>". $self->encode($value) ."</$prefix:$el>\n";
@@ -985,7 +985,7 @@
#################
# image element #
#################
- if ($self->{image}->{url}) {
+ if (defined($self->{image}->{url})) {
$output .= '<image rdf:about="'. $self->encode($self->{image}->{url}) .'">'."\n";
# title
@@ -1023,9 +1023,9 @@
if ( exists( $rdf_resource_fields{ $url } ) and
exists( $rdf_resource_fields{ $url }{ $el }) )
{
- $output .= qq!<$prefix:$el rdf:resource="! .
+ $output .= qq{<$prefix:$el rdf:resource="} .
$self->encode($value) .
- qq!" />\n!;
+ qq{" />\n};
}
else {
$output .= "<$prefix:$el>". $self->encode($value) ."</$prefix:$el>\n";
@@ -1212,7 +1212,7 @@
#################
# image element #
#################
- if ($self->{image}->{url}) {
+ if (defined($self->{image}->{url})) {
$output .= '<image>'."\n";
# title