File: unshift_content.t

package info (click to toggle)
libhtml-treebuilder-libxml-perl 0.28-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 264 kB
  • sloc: perl: 533; makefile: 2; sh: 1
file content (23 lines) | stat: -rw-r--r-- 717 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
use strict;
use warnings;
use Test::More;
use Test::Exception;
use HTML::TreeBuilder::LibXML;
use Data::Dumper;


my $tree = HTML::TreeBuilder::LibXML->new_from_content('<div class="foo">STUFF</div>');
my ($el) = $tree->disembowel;


$el->unshift_content('foo', scalar HTML::TreeBuilder::LibXML->new_from_content('<p>baz</p>')->guts, 'bar');
is $el->as_HTML, '<div class="foo">foo<p>baz</p>barSTUFF</div>', 'unshift_content';

my $doc = $el->parent;
isa_ok $doc->{node}, 'XML::LibXML::Document';

$doc->unshift_content(HTML::TreeBuilder::LibXML->new_from_content('<p>cool</p>')->disembowel);
is $doc->as_HTML, '<p>cool</p><div class="foo">foo<p>baz</p>barSTUFF</div>'."\n", 'when node is a document';


done_testing;