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