root/lang/perl/Moxy/branches/CC/t/Plugins/FlashUseImgTag.t @ 9927

Revision 9927, 1.5 kB (checked in by tokuhirom, 5 years ago)

added tests for FlashUseImgTag?

Line 
1use strict;
2use warnings;
3use Moxy;
4use HTTP::Request;
5use Test::Base;
6use FindBin;
7use File::Spec::Functions;
8use HTTP::Response;
9
10plan tests => 1*blocks;
11
12my $m = Moxy->new(
13    {
14        global => {
15            assets_path => catfile( $FindBin::Bin, '..', 'assets' ),
16            storage => {
17                module    => 'DBM_File',
18                file      => 't/testing.ndbm',
19                dbm_class => 'NDBM_File',
20            },
21        },
22        plugins => [
23            { module => 'Filter::FlashUseImgTag' },
24        ],
25    }
26);
27
28filters {
29    input    => [qw/response response_filter fetch_content remove_space/],
30    expected => [qw/remove_space/],
31};
32
33sub response {
34    my $html = shift;
35    my $res = HTTP::Response->new(200);
36    $res->header('Content-Type' => 'text/html');
37    $res->content($html);
38    $res;
39}
40
41sub response_filter {
42    my $res = shift;
43    $m->run_hook('response_filter_E', { response => $res });
44    $res;
45}
46
47sub fetch_content {
48    my $res = shift;
49    $res->content;
50}
51
52sub remove_space { my $x = shift; $x =~ s/^\s+//mg; $x =~ s/\n//g; $x }
53
54run_is input => 'expected';
55
56__END__
57
58===
59--- input
60<html><img src="http://example.com/hoge.swf" width="30" height="40" /></html>
61--- expected
62<html>
63   <object data="http://example.com/hoge.swf" width="30" height="40"
64           type="application/x-shockwave-flash">
65       <param name="bgcolor" value="#ffffff" />
66       <param name="loop" value="off" />
67       <param name="quality" value="high" />
68       <param name="salign" value="t" />
69   </object>
70</html>
71
Note: See TracBrowser for help on using the browser.