import rt 3.8.9
[freeside.git] / rt / lib / t / regression / 03web_compiliation_errors.t
1 #!/usr/bin/perl
2
3 use strict;
4 use Test::More qw/no_plan/;
5 use WWW::Mechanize;
6 use HTTP::Request::Common;
7 use HTTP::Cookies;
8 use LWP;
9 use Encode;
10
11 my $cookie_jar = HTTP::Cookies->new;
12 my $agent = WWW::Mechanize->new();
13
14 # give the agent a place to stash the cookies
15 $agent->cookie_jar($cookie_jar);
16
17 use RT;
18 RT::LoadConfig();
19
20 # get the top page
21 my $url = $RT::WebURL;
22 diag "Base URL is '$url'" if $ENV{TEST_VERBOSE};
23 $agent->get($url);
24
25 is ($agent->{'status'}, 200, "Loaded a page");
26
27 # {{{ test a login
28
29 # follow the link marked "Login"
30
31 ok($agent->{form}->find_input('user'));
32
33 ok($agent->{form}->find_input('pass'));
34 ok ($agent->{'content'} =~ /username:/i);
35 $agent->field( 'user' => 'root' );
36 $agent->field( 'pass' => 'password' );
37 # the field isn't named, so we have to click link 0
38 $agent->click(0);
39 is($agent->{'status'}, 200, "Fetched the page ok");
40 ok( $agent->{'content'} =~ /Logout/i, "Found a logout link");
41
42
43 use File::Find;
44 find ( \&wanted , 'html/');
45
46 sub wanted {
47         -f  && /\.html$/ && $_ !~ /Logout.html$/ && test_get($File::Find::name);
48 }       
49
50 sub test_get {
51         my $file = shift;
52
53         $file =~ s#^html/##;
54         diag( "testing $url/$file" ) if $ENV{TEST_VERBOSE};
55         ok ($agent->get("$url/$file", "GET $url/$file"));
56         is ($agent->{'status'}, 200, "Loaded $file");
57 #        ok( $agent->{'content'} =~ /Logout/i, "Found a logout link on $file ");
58         ok( $agent->{'content'} !~ /Not logged in/i, "Still logged in for  $file");
59         ok( $agent->{'content'} !~ /raw error/i, "Didn't get a Mason compilation error on $file");
60 }
61
62 # }}}
63
64 1;