1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
#!/usr/bin/perl -w
use strict;
use warnings;
use Test::Deep;
use File::Spec;
use Test::More tests => 15;
use RT::Test ();
BEGIN {
my $shredder_utils = RT::Test::get_relocatable_file('utils.pl',
File::Spec->curdir());
require $shredder_utils;
}
init_db();
create_savepoint('clean');
use RT::Ticket;
use RT::Tickets;
{
my $ticket = RT::Ticket->new( $RT::SystemUser );
my ($id) = $ticket->Create( Subject => 'test', Queue => 1 );
ok( $id, "created new ticket" );
$ticket->Delete;
is( $ticket->Status, 'deleted', "successfuly changed status" );
my $tickets = RT::Tickets->new( $RT::SystemUser );
$tickets->{'allow_deleted_search'} = 1;
$tickets->LimitStatus( VALUE => 'deleted' );
is( $tickets->Count, 1, "found one deleted ticket" );
my $shredder = shredder_new();
$shredder->PutObjects( Objects => $tickets );
$shredder->WipeoutAll;
}
cmp_deeply( dump_current_and_savepoint('clean'), "current DB equal to savepoint");
{
my $parent = RT::Ticket->new( $RT::SystemUser );
my ($pid) = $parent->Create( Subject => 'test', Queue => 1 );
ok( $pid, "created new ticket" );
create_savepoint('parent_ticket');
my $child = RT::Ticket->new( $RT::SystemUser );
my ($cid) = $child->Create( Subject => 'test', Queue => 1 );
ok( $cid, "created new ticket" );
my ($status, $msg) = $parent->AddLink( Type => 'MemberOf', Target => $cid );
ok( $status, "Added link between tickets") or diag("error: $msg");
my $shredder = shredder_new();
$shredder->PutObjects( Objects => $child );
$shredder->WipeoutAll;
cmp_deeply( dump_current_and_savepoint('parent_ticket'), "current DB equal to savepoint");
$shredder->PutObjects( Objects => $parent );
$shredder->WipeoutAll;
}
cmp_deeply( dump_current_and_savepoint('clean'), "current DB equal to savepoint");
{
my $parent = RT::Ticket->new( $RT::SystemUser );
my ($pid) = $parent->Create( Subject => 'test', Queue => 1 );
ok( $pid, "created new ticket" );
my ($status, $msg) = $parent->Delete;
ok( $status, 'deleted parent ticket');
create_savepoint('parent_ticket');
my $child = RT::Ticket->new( $RT::SystemUser );
my ($cid) = $child->Create( Subject => 'test', Queue => 1 );
ok( $cid, "created new ticket" );
($status, $msg) = $parent->AddLink( Type => 'DependsOn', Target => $cid );
ok( $status, "Added link between tickets") or diag("error: $msg");
my $shredder = shredder_new();
$shredder->PutObjects( Objects => $child );
$shredder->WipeoutAll;
cmp_deeply( dump_current_and_savepoint('parent_ticket'), "current DB equal to savepoint");
$shredder->PutObjects( Objects => $parent );
$shredder->WipeoutAll;
}
cmp_deeply( dump_current_and_savepoint('clean'), "current DB equal to savepoint");
|