5 use RT::Test tests => 20;
13 ok(my $testqueue = RT::Queue->new(RT->SystemUser), 'Instantiate RT::Queue');
14 ok($testqueue->Create( Name => 'reminders tests'), 'Create new queue: reminders tests');
15 isnt($testqueue->Id , 0, 'Success creating queue');
17 ok($testqueue->Create( Name => 'reminders tests 2'), 'Create new queue: reminders tests 2');
18 isnt($testqueue->Id , 0, 'Success creating queue');
23 my $u = RT::User->new(RT->SystemUser);
25 ok ($u->Id, "Found the root user");
26 ok(my $t = RT::Ticket->new(RT->SystemUser), 'Instantiate RT::Ticket');
27 ok(my ($id, $msg) = $t->Create( Queue => $testqueue->Id,
30 ), 'Create sample ticket');
31 isnt($id , 0, 'Success creating ticket');
34 my $due_obj = RT::Date->new( RT->SystemUser );
36 ok(my ( $add_id, $add_msg, $txnid ) = $t->Reminders->Add(
37 Subject => 'TestReminder',
42 # Check that the new Reminder is here
43 my $reminders = $t->Reminders->Collection;
44 ok($reminders, 'Loading reminders for this ticket');
46 while ( my $reminder = $reminders->Next ) {
47 next unless $found == 0;
48 $found = 1 if ( $reminder->Subject =~ m/TestReminder/ );
51 is($found, 1, 'Reminder successfully added');
54 ok (my ($move_val, $move_msg) = $t->SetQueue('reminders tests 2'), 'Moving ticket from queue "reminders tests" to "reminders tests 2"');
56 is ($t->QueueObj->Name, 'reminders tests 2', 'Ticket successfully moved');
58 # Check that the new reminder is still there and moved to the new queue
59 $reminders = $t->Reminders->Collection;
60 ok($reminders, 'Loading reminders for this ticket');
63 while ( my $reminder = $reminders->Next ) {
64 next unless $found == 0;
65 if ( $reminder->Subject =~ m/TestReminder/ ) {
67 $ok_queue = 1 if ( $reminder->QueueObj->Name eq 'reminders tests 2' );
70 is($found, 1, 'Reminder successfully added');
72 is($ok_queue, 1, 'Reminder automatically moved to new queue');
76 while ( my $reminder = $reminders->Next ) {
77 if ( $reminder->Subject =~ m/TestReminder/ ) {
78 if ( $reminder->Status ne 'resolved' ) {
79 $t->Reminders->Resolve($reminder);
80 $r_resolved = 1 if ( $reminder->Status eq 'resolved' );
85 is($r_resolved, 1, 'Reminder resolved');