"Fossies" - the Fresh Open Source Software Archive

Member "rt-5.0.2/t/shredder/01ticket.t" (14 Sep 2021, 3039 Bytes) of package /linux/misc/rt-5.0.2.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

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