/usr/share/otrs/scripts/test/StandardTemplate.t is in otrs2 3.3.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | # --
# StandardTemplate.t - StandardTemplate tests
# Copyright (C) 2001-2014 OTRS AG, http://otrs.com/
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --
use strict;
use warnings;
use vars (qw($Self));
use utf8;
use Kernel::System::StandardTemplate;
use Kernel::System::UnitTest::Helper;
my $HelperObject = Kernel::System::UnitTest::Helper->new(
%{$Self},
UnitTestObject => $Self,
RestoreSystemConfiguration => 0,
);
my $StandardTemplateObject = Kernel::System::StandardTemplate->new( %{$Self} );
my $RandomID = $HelperObject->GetRandomID();
# tests
my @Tests = (
{
Name => 'text',
Add => {
Name => 'text' . $RandomID,
ValidID => 1,
Template => 'Template text',
ContentType => 'text/plain; charset=iso-8859-1',
TemplateType => 'Answer',
Comment => 'some comment',
UserID => 1,
},
AddGet => {
Name => 'text' . $RandomID,
ValidID => 1,
Template => 'Template text',
ContentType => 'text/plain; charset=iso-8859-1',
TemplateType => 'Answer',
Comment => 'some comment',
},
Update => {
Name => 'text2' . $RandomID,
ValidID => 1,
Template => 'Template text\'2',
ContentType => 'text/plain; charset=utf-8',
TemplateType => 'Forward',
Comment => 'some comment2',
UserID => 1,
},
UpdateGet => {
Name => 'text2' . $RandomID,
ValidID => 1,
Template => 'Template text\'2',
ContentType => 'text/plain; charset=utf-8',
TemplateType => 'Forward',
Comment => 'some comment2',
},
},
);
for my $Test (@Tests) {
# add
my $ID = $StandardTemplateObject->StandardTemplateAdd(
%{ $Test->{Add} },
);
$Self->True(
$ID,
"StandardTemplateAdd()",
);
my %Data = $StandardTemplateObject->StandardTemplateGet(
ID => $ID,
);
for my $Key ( sort keys %{ $Test->{AddGet} } ) {
$Self->Is(
$Test->{AddGet}->{$Key},
$Data{$Key},
"StandardTemplateGet() - $Key",
);
}
# lookup by ID
my $Name = $StandardTemplateObject->StandardTemplateLookup(
StandardTemplateID => $ID
);
$Self->Is(
$Name,
$Test->{Add}->{Name},
"StandardTemplateLookup()",
);
# lookup by Name
my $LookupID = $StandardTemplateObject->StandardTemplateLookup(
StandardTemplate => $Test->{Add}->{Name},
);
$Self->Is(
$ID,
$LookupID,
"StandardTemplateLookup()",
);
# update
my $Update = $StandardTemplateObject->StandardTemplateUpdate(
ID => $ID,
%{ $Test->{Update} },
);
$Self->True(
$ID,
"StandardTemplateUpdate()",
);
%Data = $StandardTemplateObject->StandardTemplateGet(
ID => $ID,
);
for my $Key ( sort keys %{ $Test->{UpdateGet} } ) {
$Self->Is(
$Test->{UpdateGet}->{$Key},
$Data{$Key},
"StandardTemplateGet() - $Key",
);
}
# test StandardTemplateList()
my %StandardTemplates = $StandardTemplateObject->StandardTemplateList();
my %AnswerStandardTemplates = $StandardTemplateObject->StandardTemplateList( Type => 'Answer' );
my %ForwardStandardTemplates
= $StandardTemplateObject->StandardTemplateList( Type => 'Forward' );
$Self->IsNotDeeply(
\%StandardTemplates,
\%AnswerStandardTemplates,
'StandardTemplateList() - Full vs just Answer type should be different',
);
$Self->IsNotDeeply(
\%StandardTemplates,
\%ForwardStandardTemplates,
'StandardTemplateList() - Full vs just Forward type should be different',
);
$Self->IsNotDeeply(
\%AnswerStandardTemplates,
\%ForwardStandardTemplates,
'StandardTemplateList() - Answer vs Forward type should be different',
);
# test with not only valid templates
my %AllStandardTemplates = $StandardTemplateObject->StandardTemplateList( Valid => 0 );
$Self->IsNotDeeply(
\%AllStandardTemplates,
{},
'StandardTemplateList() - All templates is not an empty hash',
);
my %AllAnswerStandardTemplatess = $StandardTemplateObject->StandardTemplateList(
Valid => 0,
Type => 'Answer',
);
$Self->IsNotDeeply(
\%AllAnswerStandardTemplatess,
{},
'StandardTemplateList() - All Answer is not an empty hash',
);
# delete
my $Delete = $StandardTemplateObject->StandardTemplateDelete(
ID => $ID,
);
$Self->True(
$ID,
"StandardTemplateDelete()",
);
}
1;
|