/usr/share/otrs/scripts/test/AutoResponse.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 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | # --
# AutoResponse.t - AutoResponse 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 Kernel::System::AutoResponse;
use Kernel::System::SystemAddress;
# create local objects
my $AutoResponseObject = Kernel::System::AutoResponse->new( %{$Self} );
my $SystemAddressObject = Kernel::System::SystemAddress->new( %{$Self} );
# add system address
my $SystemAddressNameRand0 = 'unittest' . int rand 1000000;
my $SystemAddressID = $SystemAddressObject->SystemAddressAdd(
Name => $SystemAddressNameRand0 . '@example.com',
Realname => $SystemAddressNameRand0,
ValidID => 1,
QueueID => 1,
Comment => 'Some Comment',
UserID => 1,
);
$Self->True(
$SystemAddressID,
'SystemAddressAdd()',
);
# add auto response
my $AutoResponseNameRand0 = 'unittest' . int rand 1000000;
my $AutoResponseID = $AutoResponseObject->AutoResponseAdd(
Name => $AutoResponseNameRand0,
Subject => 'Some Subject',
Response => 'Some Response',
Comment => 'Some Comment',
AddressID => $SystemAddressID,
TypeID => 1,
Charset => 'iso-8859-1',
ContentType => 'text/plain',
ValidID => 1,
UserID => 1,
);
$Self->True(
$AutoResponseID,
'AutoResponseAdd()',
);
my %AutoResponse = $AutoResponseObject->AutoResponseGet( ID => $AutoResponseID );
$Self->Is(
$AutoResponse{Name} || '',
$AutoResponseNameRand0,
'AutoResponseGet() - Name',
);
$Self->Is(
$AutoResponse{Subject} || '',
'Some Subject',
'AutoResponseGet() - Subject',
);
$Self->Is(
$AutoResponse{Response} || '',
'Some Response',
'AutoResponseGet() - Response',
);
$Self->Is(
$AutoResponse{Comment} || '',
'Some Comment',
'AutoResponseGet() - Comment',
);
# check return charset based on system wide utf8 or not
if ( $Self->{EncodeObject}->EncodeInternalUsed() ) {
$Self->Is(
$AutoResponse{Charset} || '',
'utf-8',
'AutoResponseGet() - Charset',
);
}
else {
$Self->Is(
$AutoResponse{Charset} || '',
'iso-8859-1',
'AutoResponseGet() - Charset',
);
}
$Self->Is(
$AutoResponse{ContentType} || '',
'text/plain',
'AutoResponseGet() - Charset',
);
$Self->Is(
$AutoResponse{AddressID} || '',
$SystemAddressID,
'AutoResponseGet() - AddressID',
);
$Self->Is(
$AutoResponse{ValidID} || '',
1,
'AutoResponseGet() - ValidID',
);
my %AutoResponseList = $AutoResponseObject->AutoResponseList( Valid => 0 );
my $Hit = 0;
for ( sort keys %AutoResponseList ) {
if ( $_ eq $AutoResponseID ) {
$Hit = 1;
}
}
$Self->True(
$Hit eq 1,
'AutoResponseList()',
);
my $AutoResponseUpdate = $AutoResponseObject->AutoResponseUpdate(
ID => $AutoResponseID,
Name => $AutoResponseNameRand0 . '1',
Subject => 'Some Subject1',
Response => 'Some Response1',
Comment => 'Some Comment1',
AddressID => $SystemAddressID,
TypeID => 1,
Charset => 'utf8',
ContentType => 'text/html',
ValidID => 2,
UserID => 1,
);
$Self->True(
$AutoResponseUpdate,
'AutoResponseUpdate()',
);
%AutoResponse = $AutoResponseObject->AutoResponseGet( ID => $AutoResponseID );
$Self->Is(
$AutoResponse{Name} || '',
$AutoResponseNameRand0 . '1',
'AutoResponseGet() - Name',
);
$Self->Is(
$AutoResponse{Subject} || '',
'Some Subject1',
'AutoResponseGet() - Subject',
);
$Self->Is(
$AutoResponse{Response} || '',
'Some Response1',
'AutoResponseGet() - Response',
);
$Self->Is(
$AutoResponse{Comment} || '',
'Some Comment1',
'AutoResponseGet() - Comment',
);
# check return charset based on system wide utf8 or not
if ( $Self->{EncodeObject}->EncodeInternalUsed() ) {
$Self->Is(
$AutoResponse{Charset} || '',
'utf-8',
'AutoResponseGet() - Charset',
);
}
else {
$Self->Is(
$AutoResponse{Charset} || '',
'utf8',
'AutoResponseGet() - Charset',
);
}
$Self->Is(
$AutoResponse{ContentType} || '',
'text/html',
'AutoResponseGet() - Charset',
);
$Self->Is(
$AutoResponse{AddressID} || '',
$SystemAddressID,
'AutoResponseGet() - AddressID',
);
$Self->Is(
$AutoResponse{ValidID} || '',
2,
'AutoResponseGet() - ValidID',
);
my $AutoResponseQueue = $AutoResponseObject->AutoResponseQueue(
QueueID => 1,
AutoResponseIDs => [$AutoResponseID],
UserID => 1,
);
$Self->True(
$AutoResponseQueue,
'AutoResponseQueue()',
);
my %Address = $AutoResponseObject->AutoResponseGetByTypeQueueID(
QueueID => 1,
Type => 'auto reply',
);
$Self->Is(
$Address{Address} || '',
$SystemAddressNameRand0 . '@example.com',
'AutoResponseGetByTypeQueueID() - Address',
);
$Self->Is(
$Address{Realname} || '',
$SystemAddressNameRand0,
'AutoResponseGetByTypeQueueID() - Realname',
);
$AutoResponseQueue = $AutoResponseObject->AutoResponseQueue(
QueueID => 1,
AutoResponseIDs => [],
UserID => 1,
);
1;
|