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