import rt 3.8.7
[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$/;
9     }
10     my $tests = 7;
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 diag "Base URL is '$url'" if $ENV{TEST_VERBOSE};
32 $agent->get($url);
33
34 is ($agent->{'status'}, 200, "Loaded a page");
35
36 # {{{ test a login
37
38 # follow the link marked "Login"
39
40 ok($agent->{form}->find_input('user'));
41
42 ok($agent->{form}->find_input('pass'));
43 like ($agent->{'content'} , qr/username:/i);
44 $agent->field( 'user' => 'root' );
45 $agent->field( 'pass' => 'password' );
46 # the field isn't named, so we have to click link 0
47 $agent->click(0);
48 is($agent->{'status'}, 200, "Fetched the page ok");
49 like( $agent->{'content'} , qr/Logout/i, "Found a logout link");
50
51
52 find ( sub { wanted() and test_get($File::Find::name) } , 'share/html/');
53
54 sub test_get {
55         my $file = shift;
56
57         $file =~ s#^share/html/##;
58         diag( "testing $url/$file" ) if $ENV{TEST_VERBOSE};
59         ok ($agent->get("$url/$file", "GET $url/$file"), "Can Get $url/$file");
60         is ($agent->{'status'}, 200, "Loaded $file");
61 #        ok( $agent->{'content'} =~ /Logout/i, "Found a logout link on $file ");
62         ok( $agent->{'content'} !~ /Not logged in/i, "Still logged in for  $file");
63         ok( $agent->{'content'} !~ /raw error/i, "Didn't get a Mason compilation error on $file");
64 }
65
66 # }}}
67
68 1;