add strictures commit (out of order)
[catagits/HTML-Zoom.git] / t / synopsis / filterbuilder.t
CommitLineData
1cf03540 1use strictures 1;
0d8f057e 2use Test::More qw(no_plan);
3
a42917f6 4
5
0d8f057e 6use HTML::Zoom;
7my $root = HTML::Zoom
8 ->from_html(<<MAIN);
9<html>
10 <head>
11 <title>Default Title</title>
12 </head>
a42917f6 13 <body bad_attr='junk'>
0d8f057e 14 Default Content
15 </body>
16</html>
17MAIN
18
a42917f6 19
20
21$root = $root
22 ->select('body')
23 ->set_attribute(class=>'main');
24
25
26
27$root = $root
28 ->select('body')
29 ->add_to_attribute(class=>'one-column');
30
31
32
33$root = $root
34 ->select('title')
35 ->replace_content('Hello World');
36
37
38
0d8f057e 39my $body = HTML::Zoom
40 ->from_html(<<BODY);
41<div id="stuff">
adb30a8a 42 <p>Well Now</p>
f8ad684d 43 <p id="p2">Is the Time</p>
0d8f057e 44</div>
45BODY
46
a42917f6 47$root = $root
f8ad684d 48 ->select('body')
a42917f6 49 ->replace_content($body);
50
51
52
53$root = $root
f8ad684d 54 ->select('p')
a42917f6 55 ->set_attribute(class=>'para');
56
57
58
59$root = $root
60 ->select('body')
61 ->remove_attribute('bad_attr');
0d8f057e 62
63
a42917f6 64my $output = $root->to_html;
0d8f057e 65my $expect = <<HTML;
66<html>
67 <head>
68 <title>Hello World</title>
69 </head>
a42917f6 70 <body class="main one-column"><div id="stuff">
adb30a8a 71 <p class="para">Well Now</p>
a42917f6 72 <p id="p2" class="para">Is the Time</p>
0d8f057e 73</div>
74</body>
75</html>
76HTML
77is($output, $expect, 'Synopsis code works ok');
78