"Fossies" - the Fresh Open Source Software Archive

Member "rt-5.0.2/t/shredder/02cfs.t" (14 Sep 2021, 2171 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. See also the last Fossies "Diffs" side-by-side code changes report for "02cfs.t": 4.4.3_vs_4.4.4.

    1 
    2 use strict;
    3 use warnings;
    4 
    5 use Test::Deep;
    6 use File::Spec;
    7 use RT::Test::Shredder tests => undef;
    8 my $test = "RT::Test::Shredder";
    9 
   10 $test->create_savepoint('clean');
   11 
   12 my $cf = RT::Test->load_or_create_custom_field(
   13     Name        => "Favorite Color",
   14     LookupType  => "RT::Queue-RT::Ticket",
   15     Type        => "FreeformSingle",
   16 );
   17 ok $cf->id, "Created ticket CF";
   18 $test->create_savepoint('clean_with_cf');
   19 
   20 diag 'global ticket custom field';
   21 {
   22     my $global_queue = RT::Queue->new(RT->SystemUser);
   23     my ($ok, $msg) = $cf->AddToObject($global_queue);
   24     ok $ok, "Added ticket CF globally: $msg";
   25 
   26     my $shredder = $test->shredder_new();
   27     $shredder->PutObjects( Objects => $cf );
   28     $shredder->WipeoutAll;
   29     cmp_deeply( $test->dump_current_and_savepoint('clean'), "current DB equal to savepoint");
   30 }
   31 
   32 diag 'queue-specific ticket custom field';
   33 {
   34     $test->restore_savepoint('clean_with_cf');
   35     my $general = RT::Test->load_or_create_queue( Name => 'General' );
   36     my ($ok, $msg) = $cf->AddToObject($general);
   37     ok $ok, "Added ticket CF to General queue: $msg";
   38 
   39     my $shredder = $test->shredder_new();
   40     $shredder->PutObjects( Objects => $cf );
   41     $shredder->WipeoutAll;
   42     cmp_deeply( $test->dump_current_and_savepoint('clean'), "current DB equal to savepoint");
   43 }
   44 
   45 diag 'global ticket custom field + ticket';
   46 {
   47     $test->restore_savepoint('clean');
   48     my $ticket = RT::Test->create_ticket( Queue => 'General', Subject => 'test ticket' );
   49     $test->create_savepoint('clean_with_ticket');
   50 
   51     my $cf = RT::Test->load_or_create_custom_field(
   52         Name       => "Favorite Color",
   53         LookupType => "RT::Queue-RT::Ticket",
   54         Type       => "FreeformSingle",
   55     );
   56     my $global_queue = RT::Queue->new(RT->SystemUser);
   57     my ($ok, $msg) = $cf->AddToObject($global_queue);
   58     ok $ok, "Added ticket CF globally: $msg";
   59 
   60     $ticket->AddCustomFieldValue( Field => $cf->Name, Value => 'foo' );
   61 
   62     my $shredder = $test->shredder_new();
   63     $shredder->PutObjects( Objects => $cf );
   64     $shredder->WipeoutAll;
   65     cmp_deeply( $test->dump_current_and_savepoint('clean_with_ticket'), "current DB equal to savepoint");
   66 }
   67 
   68 done_testing;