Source

perl-XML-LibXML / t / 41xinclude.t

#!/usr/bin/perl -w
use strict;
use warnings;
use XML::LibXML;
use Test::More tests => 7;

# tests for bug #24953: External entities not expanded in included file (XInclude)

my $parser = XML::LibXML->new;
my $file = 'test/xinclude/test.xml';
{
  $parser->expand_xinclude(0);
  $parser->expand_entities(1);
  # TEST
  ok (scalar ($parser->parse_file($file)->toString() !~  /IT WORKS/), ' TODO : Add test name');
}
{
  $parser->expand_xinclude(1);
  $parser->expand_entities(0);
  # TEST
  ok (scalar($parser->parse_file($file)->toString() !~  /IT WORKS/), ' TODO : Add test name');
}
{
  $parser->expand_xinclude(1);
  $parser->expand_entities(1);
  # TEST
  ok (scalar($parser->parse_file($file)->toString() =~  /IT WORKS/), ' TODO : Add test name');
}
{
  $parser->expand_xinclude(0);
  my $doc = $parser->parse_file($file);
  # TEST
  ok( $doc->process_xinclude({expand_entities=>0}), ' TODO : Add test name' );
  # TEST
  ok( scalar($doc->toString() !~ /IT WORKS/), ' TODO : Add test name' );
}
{
  my $doc = $parser->parse_file($file);
  # TEST
  ok( $doc->process_xinclude({expand_entities=>1}), ' TODO : Add test name' );
  # TEST
  ok( scalar($doc->toString() =~ /IT WORKS/), ' TODO : Add test name' );
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.