rt 4.0.6
[freeside.git] / rt / t / web / command_line_link_to_articles.t
1 use strict;
2 use warnings;
3 use Test::Expect;
4 use RT::Test tests => 12, actual_server => 1;
5
6 my $class = RT::Class->new( RT->SystemUser );
7 my ( $class_id, $msg ) = $class->Create( Name => 'foo' );
8 ok( $class_id, $msg );
9
10 my $article = RT::Article->new( RT->SystemUser );
11 ( my $article_id, $msg ) =
12   $article->Create( Class => 'foo', Summary => 'article summary' );
13 ok( $article_id, $msg );
14
15 my ( $baseurl, $m ) = RT::Test->started_ok;
16 my $rt_tool_path = "$RT::BinPath/rt";
17
18 $ENV{'RTUSER'}   = 'root';
19 $ENV{'RTPASSWD'} = 'password';
20 $RT::Logger->debug(
21     "Connecting to server at " . RT->Config->Get('WebBaseURL') );
22 $ENV{'RTSERVER'} = RT->Config->Get('WebBaseURL');
23 $ENV{'RTDEBUG'}  = '1';
24 $ENV{'RTCONFIG'} = '/dev/null';
25
26 expect_run(
27     command => "$rt_tool_path shell",
28     prompt  => 'rt> ',
29     quit    => 'quit',
30 );
31 expect_send( q{create -t ticket set subject='new ticket'},
32     "creating a ticket..." );
33
34 expect_like( qr/Ticket \d+ created/, "created the ticket" );
35 expect_handle->before() =~ /Ticket (\d+) created/;
36 my $ticket_id = $1;
37 expect_send(
38     "link $ticket_id RefersTo a:$article_id",
39     "link $ticket_id RefersTo a:$article_id"
40 );
41 expect_like( qr/Created link $ticket_id RefersTo a:$article_id/,
42     'created link' );
43 expect_send( "show -s ticket/$ticket_id/links", "show ticket links" );
44 expect_like( qr|RefersTo: fsck\.com-article://example\.com/article/$article_id|,
45     "found new created link" );
46
47 expect_quit();
48