import rt 3.4.6
[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
16 $agent->cookie_jar($cookie_jar);
17
18 use RT;
19 RT::LoadConfig;
20
21 # get the top page
22 my $url = $RT::WebURL;
23 $agent->get($url);
24
25 is ($agent->{'status'}, 200, "Loaded a page");
26
27
28 # {{{ test a login
29
30 # follow the link marked "Login"
31
32 ok($agent->{form}->find_input('user'));
33
34 ok($agent->{form}->find_input('pass'));
35 ok ($agent->{'content'} =~ /username:/i);
36 $agent->field( 'user' => 'root' );
37 $agent->field( 'pass' => 'password' );
38 # the field isn't named, so we have to click link 0
39 $agent->click(0);
40 is($agent->{'status'}, 200, "Fetched the page ok");
41 ok( $agent->{'content'} =~ /Logout/i, "Found a logout link");
42
43
44 use File::Find;
45 find ( \&wanted , 'html/');
46
47 sub wanted {
48         -f  && /\.html$/ && $_ !~ /Logout.html$/  && test_get($File::Find::name);
49 }       
50
51 sub test_get {
52         my $file = shift;
53
54
55         $file =~ s#^html/##; 
56         ok ($agent->get("$url/$file", "GET $url/$file"));
57         is ($agent->{'status'}, 200, "Loaded $file");
58 #        ok( $agent->{'content'} =~ /Logout/i, "Found a logout link on $file ");
59         ok( $agent->{'content'} !~ /Not logged in/i, "Still logged in for  $file");
60         ok( $agent->{'content'} !~ /System error/i, "Didn't get a Mason compilation error on $file");
61         
62 }
63
64 # }}}
65
66 1;