5 $ENV{RT_TEST_WEB_HANDLER} = 'plack+rt-server';
11 my $dbname = 'rt4test_install_xxx';
12 my $rtname = 'rttestname';
13 my $domain = 'rttes.com';
14 my $password = 'newpass';
15 my $correspond = 'reply@example.com';
16 my $comment = 'comment@example.com';
18 # use bin/rt to fake sendmail to make sure the file exists
19 my $sendmail = File::Spec->catfile( $RT::BinPath, 'rt' );
20 my $owner = 'root@localhost';
22 unlink File::Spec->catfile( $RT::VarPath, $dbname );
24 my ( $url, $m ) = RT::Test->started_ok;
25 $m->warning_like(qr/If this is a new installation of RT/,
26 "Got startup warning");
28 my ($port) = $url =~ /:(\d+)/;
31 is( $m->uri, $url . '/Install/index.html', 'install page' );
32 $m->select( 'Lang', 'zh-cn' );
33 $m->click('ChangeLang');
34 $m->content_contains( Encode::decode("UTF-8",'语言'), 'select chinese' );
37 $m->content_contains( Encode::decode("UTF-8",'数据库'), 'select db type in chinese' );
40 $m->select( 'Lang', 'en' );
41 $m->click('ChangeLang');
42 $m->content_contains( 'Select another language', 'back to english' );
46 is( $m->uri, $url . '/Install/DatabaseType.html', 'db type page' );
47 my $select_type = $m->current_form->find_input('DatabaseType');
48 my @possible_types = $select_type->possible_values;
49 ok( @possible_types, 'we have at least 1 db type' );
52 skip 'no mysql found', 7 unless grep { /mysql/ } @possible_types;
53 $m->select( 'DatabaseType', 'mysql' );
55 for my $field (qw/Name Host Port Admin AdminPassword User Password/) {
56 ok( $m->current_form->find_input("Database$field"),
57 "db mysql has field Database$field" );
63 skip 'no pg found', 8 unless grep { /Pg/ } @possible_types;
64 $m->select( 'DatabaseType', 'Pg' );
67 qw/Name Host Port Admin AdminPassword User Password/)
69 ok( $m->current_form->find_input("Database$field"),
70 "db Pg has field Database$field" );
75 $m->select( 'DatabaseType', 'SQLite' );
78 is( $m->uri, $url . '/Install/DatabaseDetails.html', 'db details page' );
79 $m->field( 'DatabaseName' => $dbname );
80 $m->submit_form( fields => { DatabaseName => $dbname } );
81 $m->content_contains( 'Connection succeeded', 'succeed msg' );
83 qq{$dbname already exists, but does not contain RT's tables or metadata. The 'Initialize Database' step later on can insert tables and metadata into this existing database. if this is acceptable, click 'Customize Basic' below to continue customizing RT.},
88 is( $m->uri, $url . '/Install/Basics.html', 'basics page' );
91 'You must enter an Administrative password',
92 "got password can't be empty error"
95 for my $field (qw/rtname WebDomain WebPort Password/) {
96 ok( $m->current_form->find_input($field), "has field $field" );
98 is( $m->value('WebPort'), $port, 'default port' );
99 $m->field( 'rtname' => $rtname );
100 $m->field( 'WebDomain' => $domain );
101 $m->field( 'Password' => $password );
104 is( $m->uri, $url . '/Install/Sendmail.html', 'mail page' );
105 for my $field (qw/SendmailPath OwnerEmail/) {
106 ok( $m->current_form->find_input($field), "has field $field" );
109 $m->field( 'OwnerEmail' => '' );
111 $m->content_contains( "doesn't look like an email address",
114 $m->field( 'SendmailPath' => '/fake/path/sendmail' );
116 $m->content_contains( "/fake/path/sendmail doesn't exist",
117 'got sendmail error' );
119 $m->field( 'SendmailPath' => $sendmail );
120 $m->field( 'OwnerEmail' => $owner );
123 is( $m->uri, $url . '/Install/Global.html', 'global page' );
124 for my $field (qw/CommentAddress CorrespondAddress/) {
125 ok( $m->current_form->find_input($field), "has field $field" );
129 is( $m->uri, $url . '/Install/Initialize.html', 'init db page' );
132 is( $m->uri, $url . '/Install/Global.html', 'global page' );
133 $m->field( 'CorrespondAddress' => 'reply' );
135 $m->content_contains( "doesn't look like an email address",
137 $m->field( 'CommentAddress' => 'comment' );
139 $m->content_contains( "doesn't look like an email address",
142 $m->field( 'CorrespondAddress' => 'reply@example.com' );
143 $m->field( 'CommentAddress' => 'comment@example.com' );
146 is( $m->uri, $url . '/Install/Initialize.html', 'init db page' );
149 is( $m->uri, $url . '/Install/Finish.html', 'finish page' );
152 is( $m->uri, $url . '/', 'home page' );
153 $m->login( 'root', $password );
154 $m->content_contains( 'RT at a glance', 'logged in with newpass' );
157 my $config = RT->Config;
159 is( $config->Get('DatabaseType'), 'SQLite', 'DatabaseType in config' );
160 is( $config->Get('DatabaseName'), $dbname, 'DatabaseName in config' );
161 is( $config->Get('rtname'), $rtname, 'rtname in config' );
162 is( $config->Get('WebDomain'), $domain, 'WebDomain email in config' );
163 is( $config->Get('WebPort'), $port, 'WebPort email in config' );
164 is( $config->Get('SendmailPath'), $sendmail, 'SendmailPath in config' );
165 is( $config->Get('OwnerEmail'), $owner, 'OwnerEmail in config' );
166 is( $config->Get('CorrespondAddress'),
167 $correspond, 'correspond address in config' );
168 is( $config->Get('CommentAddress'), $comment, 'comment address in config' );
170 unlink File::Spec->catfile( $RT::VarPath, $dbname );