.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Test::XML::Simple 3pm" .TH Test::XML::Simple 3pm "2017-01-04" "perl v5.24.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Test::XML::Simple \- easy testing for XML .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Test::XML::Simple tests => 8; \& \& # pass string with XML as argument \& xml_valid $xml, "Is valid XML"; \& xml_node $xml, "/xpath/expression", "specified xpath node is present"; \& xml_is, $xml, \*(Aq/xpath/expr\*(Aq, "expected value", "specified text present"; \& xml_like, $xml, \*(Aq/xpath/expr\*(Aq, qr/expected/, "regex text present"; \& xml_is_deeply, $xml, \*(Aq/xpath/expr\*(Aq, $xml2, "structure and contents match"; \& \& # XML::LibXML::Document can be passed as argument too \& # that allow you to test a big documents with several tests \& my $xml_doc = XML::LibXML\->createDocument( \*(Aq1.0\*(Aq ); \& xml_valid $xml_doc, \*(AqIs valid XML\*(Aq; \& xml_node $xml_doc, \*(Aq/xpath/expression\*(Aq, \*(Aqspecified xpath node is present\*(Aq; \& xml_like, $xml_doc, \*(Aq/xpath/expression\*(Aq, qr/expected result/, \*(Aqregex present\*(Aq; \& \& # Not yet implemented: \& # xml_like_deeply would be nice too... .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\f(CW\*(C`Test::XML::Simple\*(C'\fR is a very basic class for testing \s-1XML.\s0 It uses the XPath syntax to locate nodes within the \s-1XML.\s0 You can also check all or part of the structure vs. an \s-1XML\s0 fragment. All routines accept as first argument string with \s-1XML\s0 or XML::LibXML::Document object. .SH "TEST ROUTINES" .IX Header "TEST ROUTINES" .ie n .SS "xml_valid $xml, 'test description'" .el .SS "xml_valid \f(CW$xml\fP, 'test description'" .IX Subsection "xml_valid $xml, 'test description'" Pass an \s-1XML\s0 file or fragment to this test; it succeeds if the \s-1XML \s0(fragment) is valid. .ie n .SS "xml_node $xml, $xpath, 'test description'" .el .SS "xml_node \f(CW$xml\fP, \f(CW$xpath\fP, 'test description'" .IX Subsection "xml_node $xml, $xpath, 'test description'" Checks the supplied \s-1XML\s0 to see if the node described by the supplied XPath expression is present. Test fails if it is not present. .ie n .SS "xml_is_long $xml, $xpath, $value, 'test description'" .el .SS "xml_is_long \f(CW$xml\fP, \f(CW$xpath\fP, \f(CW$value\fP, 'test description'" .IX Subsection "xml_is_long $xml, $xpath, $value, 'test description'" Finds the node corresponding to the supplied XPath expression and compares it to the supplied value. Succeeds if the two values match. Uses Test::More's \f(CW\*(C`is\*(C'\fR function to do the comparison. .ie n .SS "xml_is $xml, $xpath, $value, 'test description'" .el .SS "xml_is \f(CW$xml\fP, \f(CW$xpath\fP, \f(CW$value\fP, 'test description'" .IX Subsection "xml_is $xml, $xpath, $value, 'test description'" Finds the node corresponding to the supplied XPath expression and compares it to the supplied value. Succeeds if the two values match. Uses Test::LongString's \f(CW\*(C`is_string\*(C'\fR function to do the test. .ie n .SS "xml_like_long $xml, $xpath, $regex, 'test description'" .el .SS "xml_like_long \f(CW$xml\fP, \f(CW$xpath\fP, \f(CW$regex\fP, 'test description'" .IX Subsection "xml_like_long $xml, $xpath, $regex, 'test description'" Find the \s-1XML\s0 corresponding to the the XPath expression and check it against the supplied regular expression. Succeeds if they match. Uses Test::More's \f(CW\*(C`like\*(C'\fR function to do the comparison. .ie n .SS "xml_like $xml, $xpath, $regex, 'test description'" .el .SS "xml_like \f(CW$xml\fP, \f(CW$xpath\fP, \f(CW$regex\fP, 'test description'" .IX Subsection "xml_like $xml, $xpath, $regex, 'test description'" Find the \s-1XML\s0 corresponding to the the XPath expression and check it against the supplied regular expression. Succeeds if they match. Uses Test::LongString's \f(CW\*(C`like_string\*(C'\fR function to do the test. .ie n .SS "xml_is_deeply_long $xml, $xpath, $xml2, 'test description'" .el .SS "xml_is_deeply_long \f(CW$xml\fP, \f(CW$xpath\fP, \f(CW$xml2\fP, 'test description'" .IX Subsection "xml_is_deeply_long $xml, $xpath, $xml2, 'test description'" Find the piece of \s-1XML\s0 corresponding to the XPath expression, and compare its structure and contents to the second \s-1XML \&\s0(fragment) supplied. Succeeds if they match in structure and content. Uses Test::More's \f(CW\*(C`is\*(C'\fR function to do the comparison. .ie n .SS "xml_is_deeply $xml, $xpath, $xml2, 'test description'" .el .SS "xml_is_deeply \f(CW$xml\fP, \f(CW$xpath\fP, \f(CW$xml2\fP, 'test description'" .IX Subsection "xml_is_deeply $xml, $xpath, $xml2, 'test description'" Find the piece of \s-1XML\s0 corresponding to the XPath expression, and compare its structure and contents to the second \s-1XML \&\s0(fragment) supplied. Succeeds if they match in structure and content. Uses Test::LongString's \f(CW\*(C`is_string\*(C'\fR function to do the test. .SH "AUTHOR" .IX Header "AUTHOR" Joe McMahon, .SH "LICENSE" .IX Header "LICENSE" Copyright (c) 2005\-2013 by Yahoo! and Joe McMahon .PP This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.6.1 or, at your option, any later version of Perl 5 you may have available. .SH "SEE ALSO" .IX Header "SEE ALSO" XML::LibXML, Test::More, Test::Builder.