0ae6ead5be9c5c816158bd1de8331427bc57e9ef
[freeside.git] / rt / t / web / compilation_errors.t
1 use strict;
2 use warnings;
3 use Test::More;
4 use File::Find;
5 BEGIN {
6     sub wanted {
7         -f && /\.html$/ && $_ !~ /Logout.html$/ && $File::Find::dir !~ /RichText/;
8     }
9     my $tests = 8;
10     find( sub { wanted() and $tests += 4 }, 'share/html/' );
11     plan tests => $tests + 1; # plus one for warnings check
12 }
13
14
15 use HTTP::Request::Common;
16 use HTTP::Cookies;
17 use LWP;
18 use Encode;
19
20 my $cookie_jar = HTTP::Cookies->new;
21
22 use RT::Test;
23 my ($baseurl, $agent) = RT::Test->started_ok;
24
25 # give the agent a place to stash the cookies
26 $agent->cookie_jar($cookie_jar);
27
28 # get the top page
29 my $url = $agent->rt_base_url;
30 $agent->get($url);
31
32 is($agent->status, 200, "Loaded a page");
33
34 # follow the link marked "Login"
35 $agent->login(root => 'password');
36 is($agent->status, 200, "Fetched the page ok");
37 $agent->content_contains('Logout', "Found a logout link");
38
39
40 find ( sub { wanted() and test_get($agent, $File::Find::name) } , 'share/html/');
41
42 TODO: {
43     local $TODO = "we spew *lots* of undef warnings";
44     $agent->no_warnings_ok;
45 };
46
47 sub test_get {
48     my $agent = shift;
49         my $file = shift;
50
51         $file =~ s#^share/html/##;
52         diag( "testing $url/$file" );
53
54         $agent->get_ok("$url/$file");
55         is($agent->status, 200, "Loaded $file");
56         $agent->content_lacks('Not logged in', "Still logged in for  $file");
57         $agent->content_lacks('raw error', "Didn't get a Mason compilation error on $file") or do {
58             if (my ($error) = $agent->content =~ /<pre>(.*?line.*?)$/s) {
59                 diag "$file: $error";
60             }
61         };
62 }
63