summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorGianni Ceccarelli <dakkar@dechirico.(none)>2009-03-20 15:54:44 +0100
committerGianni Ceccarelli <dakkar@dechirico.(none)>2009-03-20 15:54:44 +0100
commitbd5e373db0ee7b496fe1827a767567f2f26064a8 (patch)
tree42ffbdfb4d73d414b53cc2f46f216e939c520bb0 /t
parentit's now possible to change the XPath engine for each transformer (diff)
downloadTree-Transform-XSLTish-bd5e373db0ee7b496fe1827a767567f2f26064a8.tar.gz
Tree-Transform-XSLTish-bd5e373db0ee7b496fe1827a767567f2f26064a8.tar.bz2
Tree-Transform-XSLTish-bd5e373db0ee7b496fe1827a767567f2f26064a8.zip
skip compatibility tests if required modules are not present
added LibXML test
Diffstat (limited to 't')
-rw-r--r--t/05-html-tree.t6
-rw-r--r--t/06-libxml.t37
2 files changed, 41 insertions, 2 deletions
diff --git a/t/05-html-tree.t b/t/05-html-tree.t
index a562aba..c025251 100644
--- a/t/05-html-tree.t
+++ b/t/05-html-tree.t
@@ -13,10 +13,12 @@ package HtmlTransform;{
}
package main;
-use Test::Most qw(no_plan die);
+use Test::Most 'die';
use strict;
use warnings;
-use HTML::TreeBuilder::XPath;
+eval 'use XML::XPathEngine;use HTML::TreeBuilder::XPath;';
+plan skip_all => 'XML::XPathEngine and HTML::TreeBuilder::XPath needed for this test' if $@;
+plan tests=> 1;
sub HTML::TreeBuilder::XPath::Root::getRootNode { return $_[0] }
diff --git a/t/06-libxml.t b/t/06-libxml.t
new file mode 100644
index 0000000..2377738
--- /dev/null
+++ b/t/06-libxml.t
@@ -0,0 +1,37 @@
+#!perl
+package XmlTransform;{
+ use Tree::Transform::XSLTish;
+ use strict;
+ use warnings;
+
+ default_rules;
+
+ tree_rule match => 'img[@alt="pick"]', action => sub {
+ return $_[0]->it->findvalue('@src');
+ };
+
+}
+
+package main;
+use Test::Most 'die';
+use strict;
+use warnings;
+eval 'use XML::LibXML;use XML::LibXML::XPathContext;';
+plan skip_all => 'XML::LibXML and XML::LibXML::XPathContext needed for this test' if $@;
+plan tests=>1;
+
+my $tree=XML::LibXML->new->parse_string(<<'XML');
+<html>
+ <body>
+ <p>test</p>
+ <img src="nothing" />
+ <img src="this one" alt="pick" />
+ </body>
+</html>
+XML
+
+{
+my $trans=XmlTransform->new(engine=>XML::LibXML::XPathContext->new());
+my @results=$trans->transform($tree);
+is_deeply \@results,['this one'],'XML example';
+}