Merge branch 'master' of git.freeside.biz:/home/git/freeside
[freeside.git] / rt / t / api / template.t
1
2 use warnings;
3 use strict;
4
5 use RT;
6 use RT::Test tests => 10;
7
8 my $queue = RT::Test->load_or_create_queue( Name => 'Templates' );
9 ok $queue && $queue->id, "loaded or created a queue";
10
11 {
12     my $template = RT::Template->new( RT->SystemUser );
13     isa_ok($template, 'RT::Template');
14     my ($val,$msg) = $template->Create(
15         Queue => $queue->id,
16         Name => 'InsertTest',
17         Content => 'This is template content'
18     );
19     ok $val, "created a template" or diag "error: $msg";
20     ok my $id = $template->id, "id is defined";
21     is $template->Name, 'InsertTest';
22     is $template->Content, 'This is template content', "We created the object right";
23
24     ($val, $msg) = $template->SetContent( 'This is new template content');
25     ok $val, "changed content" or diag "error: $msg";
26
27     is $template->Content, 'This is new template content', "We managed to _Set_ the content";
28
29     ($val, $msg) = $template->Delete;
30     ok $val, "deleted template";
31
32     $template->Load($id);
33     ok !$template->id, "can not load template after deletion";
34 }