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
|
# --
# Copyright (C) 2021 Znuny GmbH, https://znuny.org/
# --
# 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 utf8;
use vars (qw($Self));
$Kernel::OM->ObjectParamAdd(
'Kernel::System::UnitTest::Helper' => {
RestoreDatabase => 1,
},
);
my $AppointmentObject = $Kernel::OM->Get('Kernel::System::Calendar::Appointment');
my $CalendarObject = $Kernel::OM->Get('Kernel::System::Calendar');
my $GroupObject = $Kernel::OM->Get('Kernel::System::Group');
my $HelperObject = $Kernel::OM->Get('Kernel::System::UnitTest::Helper');
my $TicketObject = $Kernel::OM->Get('Kernel::System::Ticket');
my $ZnunyHelperObject = $Kernel::OM->Get('Kernel::System::ZnunyHelper');
my $DynamicFieldObject = $Kernel::OM->Get('Kernel::System::DynamicField');
my $BackendObject = $Kernel::OM->Get('Kernel::System::DynamicField::Backend');
my $TransitionActionObject = $Kernel::OM->Get('Kernel::System::ProcessManagement::TransitionAction::AppointmentRemove');
my $GroupID = $GroupObject->GroupLookup(
Group => 'users',
);
my $CalendarName = 'Calendar ' . $HelperObject->GetRandomNumber();
my %Calendar = $CalendarObject->CalendarCreate(
CalendarName => $CalendarName,
GroupID => $GroupID,
Color => '#FF7700',
UserID => 1,
ValidID => 1,
);
my @DynamicFields = (
{
Name => 'AppointmentID',
Label => 'AppointmentID',
ObjectType => 'Ticket',
FieldType => 'Text',
Config => {
DefaultValue => '',
Link => '',
},
},
);
$ZnunyHelperObject->_DynamicFieldsCreate(@DynamicFields);
my $TicketID = $HelperObject->TicketCreate(
Queue => 'Raw',
);
my %Ticket = $TicketObject->TicketGet(
TicketID => $TicketID,
DynamicFields => 1,
UserID => 1,
);
my $AppointmentID = $AppointmentObject->AppointmentCreate(
UserID => 1,
CalendarID => $Calendar{CalendarID},
Title => 'Webinar',
StartTime => '2021-01-01',
EndTime => '2021-01-02',
DynamicField_AppointmentID => 'AppointmentID',
UserID => 1,
);
my %Appointment = $AppointmentObject->AppointmentGet(
AppointmentID => $AppointmentID,
CalendarID => $Calendar{CalendarID},
);
$Self->Is(
$Appointment{Title},
'Webinar',
'Appointment got created successfully',
);
my $DynamicFieldConfig = $DynamicFieldObject->DynamicFieldGet(
Name => 'AppointmentID',
);
$BackendObject->ValueSet(
DynamicFieldConfig => $DynamicFieldConfig,
ObjectID => $TicketID,
Value => $AppointmentID,
UserID => 1,
);
%Ticket = $TicketObject->TicketGet(
TicketID => $TicketID,
DynamicFields => 1,
UserID => 1,
);
$Self->True(
$Ticket{DynamicField_AppointmentID},
'DynamicField_AppointmentID got filled correctly',
);
my $TransitionActionResult = $TransitionActionObject->Run(
UserID => 1,
Ticket => \%Ticket,
ProcessEntityID => 'P123',
ActivityEntityID => 'A123',
TransitionEntityID => 'T123',
TransitionActionEntityID => 'TA123',
Config => {
AppointmentID => '<OTRS_TICKET_DynamicField_AppointmentID>',
UserID => 1,
},
);
$Self->True(
$TransitionActionResult,
'TransitionActionObject->Run()',
);
my %DeletedAppointment = $AppointmentObject->AppointmentGet(
AppointmentID => $Ticket{DynamicField_AppointmentID},
CalendarID => $Calendar{CalendarID},
);
$Self->False(
$DeletedAppointment{AppointmentID},
'Appointment got deleted successfully',
);
1;
|