RT 4.0.22
[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
19 my $cookie_jar = HTTP::Cookies->new;
20
21 use RT::Test;
22 my ($baseurl, $agent) = RT::Test->started_ok;
23
24 # give the agent a place to stash the cookies
25 $agent->cookie_jar($cookie_jar);
26
27 # get the top page
28 my $url = $agent->rt_base_url;
29 $agent->get($url);
30
31 is($agent->status, 200, "Loaded a page");
32
33 # follow the link marked "Login"
34 $agent->login(root => 'password');
35 is($agent->status, 200, "Fetched the page ok");
36 $agent->content_contains('Logout', "Found a logout link");
37
38
39 find ( sub { wanted() and test_get($agent, $File::Find::name) } , 'share/html/');
40
41 TODO: {
42     local $TODO = "we spew *lots* of undef warnings";
43     $agent->no_warnings_ok;
44 };
45
46 sub test_get {
47     my $agent = shift;
48         my $file = shift;
49
50         $file =~ s#^share/html/##;
51         diag( "testing $url/$file" );
52
53         $agent->get_ok("$url/$file");
54         is($agent->status, 200, "Loaded $file");
55         $agent->content_lacks('Not logged in', "Still logged in for  $file");
56         $agent->content_lacks('raw error', "Didn't get a Mason compilation error on $file") or do {
57             if (my ($error) = $agent->content =~ /<pre>(.*?line.*?)$/s) {
58                 diag "$file: $error";
59             }
60         };
61 }
62