summaryrefslogtreecommitdiff
path: root/rt/t/shredder/01ticket.t
diff options
context:
space:
mode:
authorivan <ivan>2009-12-31 13:16:41 +0000
committerivan <ivan>2009-12-31 13:16:41 +0000
commit63a268637b2d51a8766412617724b9436439deb6 (patch)
treea50f6d4c7829d5c80905e989144317192a44dc90 /rt/t/shredder/01ticket.t
parent65a561e3cd8c1ba94f6282f5d2a1cd9783afbd21 (diff)
parentb4b0c7e72d7eaee2fbfc7022022c9698323203dd (diff)
This commit was generated by cvs2svn to compensate for changes in r8690,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'rt/t/shredder/01ticket.t')
-rw-r--r--rt/t/shredder/01ticket.t86
1 files changed, 86 insertions, 0 deletions
diff --git a/rt/t/shredder/01ticket.t b/rt/t/shredder/01ticket.t
new file mode 100644
index 000000000..5625b985d
--- /dev/null
+++ b/rt/t/shredder/01ticket.t
@@ -0,0 +1,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");