Commit | Line | Data |
21e7cc98 |
1 | use strictures 1; |
2 | use Test::More; |
3 | use IO::All; |
4 | use FindBin; |
8a186887 |
5 | use File::Temp; |
6 | use lib "$FindBin::Bin/lib"; |
21e7cc98 |
7 | use aliased 'System::Introspector::Report::Publish::MediaWiki'; |
8 | |
8a186887 |
9 | $ENV{TEST_SI_REPORT_OUT} = my $out_dir = File::Temp->newdir; |
10 | $ENV{TEST_SI_REPORT_IN} = "$FindBin::Bin/data"; |
21e7cc98 |
11 | |
8a186887 |
12 | my %result; |
21e7cc98 |
13 | |
21e7cc98 |
14 | my $wiki = MediaWiki->new( |
f15f1fe1 |
15 | api_uri => 'http://example.com:9999/', |
8a186887 |
16 | connection_class => 'TestConnection', |
f15f1fe1 |
17 | username => 'foo', |
18 | password => 'bar', |
21e7cc98 |
19 | page => { |
20 | foo => { |
21 | report => ['foo:*'], |
22 | }, |
23 | }, |
24 | ); |
25 | |
26 | ok $wiki->publish([ |
27 | { id => [qw( foo a )], |
28 | title => "Foo A", |
29 | rowid => ['bar'], |
30 | columns => [ |
31 | { key => 'bar', label => 'Bar' }, |
32 | { key => 'baz', label => 'Baz' }, |
33 | ], |
34 | rows => [ |
35 | { bar => 231, baz => 421 }, |
36 | { bar => 232, baz => 884 }, |
37 | { bar => 332, baz => 784 }, |
38 | ], |
39 | }, |
40 | { id => [qw( foo b )], |
41 | title => "Foo B", |
42 | rowid => ['bar'], |
43 | columns => [ |
44 | { key => 'bar', label => 'Bar' }, |
45 | { key => 'baz', label => 'Baz' }, |
46 | ], |
47 | rows => [ |
48 | { bar => 231, baz => 421 }, |
49 | { bar => 332, baz => 784 }, |
50 | ], |
51 | }, |
52 | { id => [qw( foo c )], |
53 | title => "Foo C", |
54 | rowid => ['bar'], |
55 | columns => [ |
56 | { key => 'bar', label => 'New Bar' }, |
57 | { key => 'baz', label => 'New Baz' }, |
58 | ], |
59 | rows => [ |
60 | { bar => 232, baz => 884 }, |
61 | { bar => 332, baz => 784 }, |
a57e8790 |
62 | { bar => 989, baz => "foo\nbar" }, |
21e7cc98 |
63 | ], |
64 | }, |
65 | ]), 'publish ok'; |
66 | |
67 | my $_despace = sub { |
68 | my $string = shift; |
69 | $string =~ s{[\s\n]+}{}g; |
70 | return $string; |
71 | }; |
72 | |
73 | ## uncomment to regenerate result file |
8a186887 |
74 | # do { no warnings; io("$out_dir/foo") > io("$FindBin::Bin/data/result/foo.txt"); fail "regenerated" }; |
21e7cc98 |
75 | |
8a186887 |
76 | is scalar(io("$out_dir/foo")->slurp)->$_despace, |
21e7cc98 |
77 | scalar(io("$FindBin::Bin/data/result/foo.txt")->slurp)->$_despace, |
78 | 'resulting page looks correct'; |
79 | |
80 | done_testing; |