summaryrefslogtreecommitdiff
path: root/rt/t/api/transaction.t
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2014-09-15 20:44:48 -0700
committerIvan Kohler <ivan@freeside.biz>2014-09-15 20:44:48 -0700
commited1f84b4e8f626245995ecda5afcf83092c153b2 (patch)
tree3f58bbef5fbf2502e65d29b37b5dbe537519e89d /rt/t/api/transaction.t
parentfe9ea9183e8a16616d6d04a7b5c7498d28e78248 (diff)
RT 4.0.22
Diffstat (limited to 'rt/t/api/transaction.t')
-rw-r--r--rt/t/api/transaction.t52
1 files changed, 52 insertions, 0 deletions
diff --git a/rt/t/api/transaction.t b/rt/t/api/transaction.t
new file mode 100644
index 000000000..22c3cfe72
--- /dev/null
+++ b/rt/t/api/transaction.t
@@ -0,0 +1,52 @@
+
+use strict;
+use warnings;
+use RT;
+use RT::Test tests => undef;
+use Test::Warn;
+
+use_ok ('RT::Transaction');
+
+{
+ my $u = RT::User->new(RT->SystemUser);
+ $u->Load("root");
+ ok ($u->Id, "Found the root user");
+ ok(my $t = RT::Ticket->new(RT->SystemUser));
+ my ($id, $msg) = $t->Create( Queue => 'General',
+ Subject => 'Testing',
+ Owner => $u->Id
+ );
+ ok($id, "Create new ticket $id");
+ isnt($id , 0);
+
+ my $txn = RT::Transaction->new(RT->SystemUser);
+ my ($txn_id, $txn_msg) = $txn->Create(
+ Type => 'AddLink',
+ Field => 'RefersTo',
+ Ticket => $id,
+ NewValue => 'ticket 42', );
+ ok( $txn_id, "Created transaction $txn_id: $txn_msg");
+
+ my $brief;
+ warning_like { $brief = $txn->BriefDescription }
+ qr/Could not determine a URI scheme/,
+ "Caught URI warning";
+
+ is( $brief, 'Reference to ticket 42 added', "Got string description: $brief");
+
+ $txn = RT::Transaction->new(RT->SystemUser);
+ ($txn_id, $txn_msg) = $txn->Create(
+ Type => 'DeleteLink',
+ Field => 'RefersTo',
+ Ticket => $id,
+ OldValue => 'ticket 42', );
+ ok( $txn_id, "Created transaction $txn_id: $txn_msg");
+
+ warning_like { $brief = $txn->BriefDescription }
+ qr/Could not determine a URI scheme/,
+ "Caught URI warning";
+
+ is( $brief, 'Reference to ticket 42 deleted', "Got string description: $brief");
+}
+
+done_testing;