Test-XMLElement
view release on metacpan or search on metacpan
t/03have_child_name.t
t/04childcount.t
t/05isempty.t
t/06hasatt.t
t/07hasnoatt.t
t/08attnum.t
t/09attname.t
t/10attnameval.t
t/11nchild.t
t/12allchild.t
t/13cdata.t
t/14cdesc.t
t/15xpath.t
t/16xpcnt.t
lib/Test/XMLElement.pm
META.yml Module meta-data (added by MakeMaker)
lib/Test/XMLElement.pm view on Meta::CPAN
*{$caller.'::have_child_name'} = \&have_child_name;
*{$caller.'::child_count_is'} = \&child_count_is;
*{$caller.'::is_empty'} = \&is_empty;
*{$caller.'::has_attributes'} = \&has_attributes;
*{$caller.'::has_no_attrib'} = \&has_no_attrib;
*{$caller.'::number_of_attribs'} = \&number_of_attribs;
*{$caller.'::attrib_value'} = \&attrib_value;
*{$caller.'::attrib_name'} = \&attrib_name;
*{$caller.'::nth_child_name'} = \&nth_child_name;
*{$caller.'::all_children_are'} = \&all_children_are;
*{$caller.'::child_has_cdata'} = \&child_has_cdata;
*{$caller.'::is_descendants'} = \&is_descendants;
*{$caller.'::is_xpath'} = \&is_xpath;
*{$caller.'::is_xpath_count'} = \&is_xpath_count;
$Tst->exported_to($caller);
$Tst->plan(@_);
}
lib/Test/XMLElement.pm view on Meta::CPAN
$Tst->ok(scalar(@atts),$msg) ||
$Tst->diag("Element ",$valid_elt->name," do not have any attributes")
) unless (@atts);
return
(
$Tst->is_eq($valid_elt->att($name), $value, $msg) ||
$Tst->diag("Element \'",$valid_elt->name,"\' do not have any attribute named $name")
);
}
sub child_has_cdata {
my ($elt, $msg) = @_;
my $valid_elt = _parse($elt,$msg);
return 0 unless $valid_elt;
my @cdata = grep {$_->is_cdata} $valid_elt->children;
return
(
$Tst->ok(scalar(@cdata),$msg) ||
$Tst->diag("Element ",$valid_elt->name," do not have any CDATA")
)
}
sub is_descendants {
my ($elt, $name, $msg) = @_;
my $valid_elt = _parse($elt,$msg);
return 0 unless $valid_elt;
return
(
lib/Test/XMLElement.pm view on Meta::CPAN
Test passes if the XML string in C<$xml> contains attribute with name C<$name> and its value as C<$value>. Describe or name the test with C<$name>.
=item nth_child_name($xml, $count, $name, $desc);
Test passes if the XML string in C<$xml> contains any direct Nth child element with tag or gi value as C<$name> and location at C<$count>. Name or Describe the test with C<$desc>.
=item all_children_are($xml, $name, $desc);
Test passes if the XML string in C<$xml> contains all direct child element with tag or gi value as C<$name>. Name or Describe the test with C<$desc>.
=item child_has_cdata($xml, $desc);
Test passes if the XML string in C<$xml> contains any CDATA element as its direct child. Name or Describe the test with C<$desc>.
=item is_xpath($xml, $xpath, $desc);
Test passes if the XML string in C<$xml> matches the XPath expression C<$xpath>. Name or Describe the test with C<$desc>.
=item is_xpath_count($xml, $xpath, $count, $desc);
Test passes if the XML string in C<$xml> matches C<$count> number of XPath expression C<$xpath>. Name or Describe the test with C<$desc>.
t/13cdata.t view on Meta::CPAN
use strict;
use warnings;
use Test::Builder::Tester tests => 2;
use Test::XMLElement;
## Test 1
my $desc = "not ok 1 - Child has cdata";
test_out($desc);
test_fail(+2);
test_diag("Element a do not have any CDATA");
child_has_cdata("<a><b/><c/><d/></a>", "Child has cdata"); #FAIL
test_test( "Negative Test Case - Child has cdata");
## Test 2
$desc = "ok 1 - Child has cdata";
test_out($desc);
child_has_cdata("<a><![CDATA[foo < bar]]></a>", "Child has cdata"); #PASS
test_test("Child has cdata");
( run in 0.258 second using v1.01-cache-2.11-cpan-454fe037f31 )