fix ticketing system error on bootstrap of new install
[freeside.git] / rt / t / ticket / circular_links.t
1 use strict;
2 use warnings;
3
4 use RT::Test tests => undef;
5
6 my ( $foo, $bar, $baz ) = RT::Test->create_tickets(
7     { Queue   => 'General' },
8     { Subject => 'foo' },
9     { Subject => 'bar' },
10     { Subject => 'baz' }
11 );
12
13 diag "test circular DependsOn";
14 my ( $status, $msg ) = $foo->AddLink( Type => 'DependsOn', Target => $bar->id );
15 ok( $status, "foo depends on bar" );
16 ( $status, $msg ) = $foo->AddLink( Type => 'DependsOn', Base => $bar->id );
17 ok( !$status, "foo can't be depended on bar" );
18 ( $status, $msg ) = $bar->AddLink( Type => 'DependsOn', Target => $foo->id );
19 ok( !$status, "bar can't depend on foo back" );
20 ( $status, $msg ) = $bar->AddLink( Type => 'DependsOn', Target => $baz->id );
21 ok( $status, "bar depends on baz" );
22 ( $status, $msg ) = $baz->AddLink( Type => 'DependsOn', Target => $foo->id );
23 ok( !$status, "baz can't depend on foo back" );
24
25
26 diag "test circular MemberOf";
27 ( $status, $msg ) = $foo->AddLink( Type => 'MemberOf', Target => $bar->id );
28 ok( $status, "foo is a member of bar" );
29 ( $status, $msg ) = $foo->AddLink( Type => 'MemberOf', Base => $bar->id );
30 ok( !$status, "foo can't have member bar" );
31 ( $status, $msg ) = $bar->AddLink( Type => 'MemberOf', Target => $foo->id );
32 ok( !$status, "bar can't be a member of foo" );
33 ( $status, $msg ) = $bar->AddLink( Type => 'MemberOf', Target => $baz->id );
34 ok( $status, "baz is a member of bar" );
35 ( $status, $msg ) = $baz->AddLink( Type => 'DependsOn', Target => $foo->id );
36 ok( !$status, "baz can't be a member of foo" );
37
38
39 diag "test circular RefersTo";
40 ( $status, $msg ) = $foo->AddLink( Type => 'RefersTo', Target => $bar->id );
41 ok( $status, "foo refers to bar" );
42 ( $status, $msg ) = $foo->AddLink( Type => 'RefersTo', Base => $bar->id );
43 ok( $status, "foo can be referred to by bar" );
44
45 done_testing;