Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
best-practical
rt-extension-sla
Commits
1c705369
Commit
1c705369
authored
May 05, 2009
by
Ruslan Zakirov
Browse files
new test file, basics of reporting
parent
2d90ba67
Changes
1
Hide whitespace changes
Inline
Side-by-side
t/reporting/basic.t
0 → 100644
View file @
1c705369
#!/usr/bin/perl
use
strict
;
use
warnings
;
use
Test::
MockTime
qw(set_fixed_time)
;
use
Test::
More
tests
=>
72
;
require
'
t/utils.pl
';
use_ok
'
RT
';
RT::
LoadConfig
();
$
RT::
LogToScreen
=
$ENV
{'
TEST_VERBOSE
'}
?
'
debug
':
'
warning
';
RT::
Init
();
use_ok
'
RT::Ticket
';
use_ok
'
RT::Extension::SLA::Report
';
my
$root
=
RT::
User
->
new
(
$
RT::
SystemUser
);
$root
->
LoadByEmail
('
root@localhost
');
ok
$root
->
id
,
'
loaded root user
';
diag
'';
{
%
RT::
ServiceAgreements
=
(
Default
=>
'
2
',
Levels
=>
{
'
2
'
=>
{
Response
=>
{
RealMinutes
=>
60
*
2
}
},
},
);
set_fixed_time
('
2009-05-05T10:00:00Z
');
my
$time
=
time
;
# requestor creates
my
$id
;
{
my
$ticket
=
RT::
Ticket
->
new
(
$root
);
(
$id
)
=
$ticket
->
Create
(
Queue
=>
'
General
',
Subject
=>
'
xxx
',
Requestor
=>
$root
->
id
);
ok
$id
,
"
created ticket #
$id
";
is
$ticket
->
FirstCustomFieldValue
('
SLA
'),
'
2
',
'
default sla
';
my
$due
=
$ticket
->
DueObj
->
Unix
;
is
$due
,
$time
+
2
*
60
*
60
,
'
Due date is two hours from "now"
';
}
set_fixed_time
('
2009-05-05T11:00:00Z
');
# non-requestor reply
{
my
$ticket
=
RT::
Ticket
->
new
(
$
RT::
SystemUser
);
$ticket
->
Load
(
$id
);
ok
$ticket
->
id
,
"
loaded ticket #
$id
";
$ticket
->
Correspond
(
Content
=>
'
we are working on this.
'
);
}
my
$ticket
=
RT::
Ticket
->
new
(
$
RT::
SystemUser
);
$ticket
->
Load
(
$id
);
my
$report
=
RT::Extension::SLA::
Report
->
new
(
Ticket
=>
$ticket
)
->
Run
;
is_deeply
$report
->
Stats
,
[
{
type
=>
'
Response
',
owner
=>
$
RT::
Nobody
->
id
,
owner_act
=>
0
,
failed
=>
0
,
shift
=>
-
3600
}
],
'
correct stats
'
;
}
diag
'';
{
%
RT::
ServiceAgreements
=
(
Default
=>
'
2
',
Levels
=>
{
'
2
'
=>
{
Response
=>
{
RealMinutes
=>
60
*
2
}
},
},
);
set_fixed_time
('
2009-05-05T10:00:00Z
');
my
$time
=
time
;
# requestor creates
my
$id
;
{
my
$ticket
=
RT::
Ticket
->
new
(
$root
);
(
$id
)
=
$ticket
->
Create
(
Queue
=>
'
General
',
Subject
=>
'
xxx
',
Requestor
=>
$root
->
id
);
ok
$id
,
"
created ticket #
$id
";
is
$ticket
->
FirstCustomFieldValue
('
SLA
'),
'
2
',
'
default sla
';
my
$due
=
$ticket
->
DueObj
->
Unix
;
is
$due
,
$time
+
2
*
60
*
60
,
'
Due date is two hours from "now"
';
}
set_fixed_time
('
2009-05-05T11:00:00Z
');
# non-requestor reply
{
my
$ticket
=
RT::
Ticket
->
new
(
$
RT::
SystemUser
);
$ticket
->
Load
(
$id
);
ok
$ticket
->
id
,
"
loaded ticket #
$id
";
$ticket
->
Correspond
(
Content
=>
'
we are working on this.
'
);
}
my
$ticket
=
RT::
Ticket
->
new
(
$
RT::
SystemUser
);
$ticket
->
Load
(
$id
);
my
$report
=
RT::Extension::SLA::
Report
->
new
(
Ticket
=>
$ticket
)
->
Run
;
is_deeply
$report
->
Stats
,
[
{
type
=>
'
Response
',
owner
=>
$
RT::
Nobody
->
id
,
owner_act
=>
0
,
failed
=>
0
,
shift
=>
-
3600
}
],
'
correct stats
'
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment