File: time-worked.t

package info (click to toggle)
request-tracker5 5.0.3%2Bdfsg-3~deb12u3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 77,648 kB
  • sloc: javascript: 187,930; perl: 79,061; sh: 1,302; makefile: 471; python: 37; php: 15
file content (80 lines) | stat: -rw-r--r-- 2,223 bytes parent folder | download | duplicates (10)
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
use strict;
use warnings;

use RT::Test tests => 27;

my $queue = RT::Test->load_or_create_queue( Name => 'General' );
ok $queue && $queue->id, "loaded or created a queue";

note 'set on Create';
{
    my $ticket = RT::Test->create_ticket(
        Queue => $queue->id, TimeWorked => 10,
    );
    is $ticket->TimeWorked, 10, 'correct value';

    my $txn = RT::Transaction->new( RT->SystemUser );
    $txn->LoadByCols(
        ObjectType => 'RT::Ticket', ObjectId => $ticket->id,
        Type => 'Create',
    );
    ok $txn->id, 'found transaction';
    is $txn->TimeTaken, 10, 'correct value';
}

note 'set on Comment';
{
    my $ticket = RT::Test->create_ticket( Queue => $queue->id );
    ok !$ticket->TimeWorked, 'correct value';
    $ticket->Comment( Content => 'test', TimeTaken => 10 );
    is $ticket->TimeWorked, 10, 'correct value';

    my $txn = RT::Transaction->new( RT->SystemUser );
    $txn->LoadByCols(
        ObjectType => 'RT::Ticket', ObjectId => $ticket->id,
        Type => 'Comment',
    );
    ok $txn->id, 'found transaction';
    is $txn->TimeTaken, 10, 'correct value';
}

note 'update';
{
    my $ticket = RT::Test->create_ticket( Queue => $queue->id );
    ok !$ticket->TimeWorked, 'correct value';
    $ticket->SetTimeWorked( 10 );
    is $ticket->TimeWorked, 10, 'correct value';

    my $txn = RT::Transaction->new( RT->SystemUser );
    $txn->LoadByCols(
        ObjectType => 'RT::Ticket', ObjectId => $ticket->id,
        Type => 'Set', Field => 'TimeWorked',
    );
    ok $txn->id, 'found transaction';
    is $txn->TimeTaken, 10, 'correct value';
}

note 'on Merge';
{
    my $ticket = RT::Test->create_ticket(
        Queue => $queue->id, TimeWorked => 7,
    );
    {
        my $tmp = RT::Test->create_ticket(
            Queue => $queue->id, TimeWorked => 13,
        );
        my ($status, $msg) = $tmp->MergeInto( $ticket->id );
        ok $status, "merged tickets";
    }
    $ticket->Load( $ticket->id );
    is $ticket->TimeWorked, 20, 'correct value';
}

sub dump_txns {
    my $ticket = shift;
    my $txns = $ticket->Transactions;
    while ( my $txn = $txns->Next ) {
        diag sprintf "#%d\t%s\t%s\t%d", map $txn->$_() // '', qw(id Type Field TimeTaken);
    }
}