diff --git a/Kernel/System/Ticket/Article/Backend/Base.pm b/Kernel/System/Ticket/Article/Backend/Base.pm index e380616e5f..5a4e333af6 100644 --- a/Kernel/System/Ticket/Article/Backend/Base.pm +++ b/Kernel/System/Ticket/Article/Backend/Base.pm @@ -2,7 +2,7 @@ # OTOBO is a web-based ticketing system for service organisations. # -- # Copyright (C) 2001-2020 OTRS AG, https://otrs.com/ -# Copyright (C) 2019-2022 Rother OSS GmbH, https://otobo.de/ +# Copyright (C) 2019-2023 Rother OSS GmbH, https://otobo.de/ # -- # This program is free software: you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software @@ -522,6 +522,7 @@ Returns: ChangeBy => ..., ); +Returns an empty list when no article was found. =cut @@ -539,12 +540,12 @@ sub _MetaArticleGet { } # Use ArticleList() internally to benefit from its ticket-level cache. - my @MetaArticleIndex = $Kernel::OM->Get('Kernel::System::Ticket::Article')->ArticleList( + my ($FirstMetaArticle) = $Kernel::OM->Get('Kernel::System::Ticket::Article')->ArticleList( TicketID => $Param{TicketID}, ArticleID => $Param{ArticleID}, ); - return %{ $MetaArticleIndex[0] // {} }; + return %{ $FirstMetaArticle // {} }; } =head2 _MetaArticleDelete() diff --git a/Kernel/System/Ticket/Article/Backend/Invalid.pm b/Kernel/System/Ticket/Article/Backend/Invalid.pm index 31c1ddd587..d32576a96f 100644 --- a/Kernel/System/Ticket/Article/Backend/Invalid.pm +++ b/Kernel/System/Ticket/Article/Backend/Invalid.pm @@ -2,7 +2,7 @@ # OTOBO is a web-based ticketing system for service organisations. # -- # Copyright (C) 2001-2020 OTRS AG, https://otrs.com/ -# Copyright (C) 2019-2022 Rother OSS GmbH, https://otobo.de/ +# Copyright (C) 2019-2023 Rother OSS GmbH, https://otobo.de/ # -- # This program is free software: you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software @@ -98,9 +98,10 @@ sub ArticleGet { my %MetaArticle = $Self->_MetaArticleGet(%Param); - my %ArticleSenderTypeList = $Kernel::OM->Get('Kernel::System::Ticket::Article')->ArticleSenderTypeList(); + return unless %MetaArticle; # Include sender type lookup. + my %ArticleSenderTypeList = $Kernel::OM->Get('Kernel::System::Ticket::Article')->ArticleSenderTypeList(); $MetaArticle{SenderType} = $ArticleSenderTypeList{ $MetaArticle{SenderTypeID} }; return %MetaArticle; diff --git a/scripts/test/DynamicField/ObjectType/Article/ObjectDataGet.t b/scripts/test/DynamicField/ObjectType/Article/ObjectDataGet.t index 6b6546d8e6..bceca2160e 100644 --- a/scripts/test/DynamicField/ObjectType/Article/ObjectDataGet.t +++ b/scripts/test/DynamicField/ObjectType/Article/ObjectDataGet.t @@ -2,7 +2,7 @@ # OTOBO is a web-based ticketing system for service organisations. # -- # Copyright (C) 2001-2020 OTRS AG, https://otrs.com/ -# Copyright (C) 2019-2022 Rother OSS GmbH, https://otobo.de/ +# Copyright (C) 2019-2023 Rother OSS GmbH, https://otobo.de/ # -- # This program is free software: you can redistribute it and/or modify it under # the terms of the GNU General Public License as published by the Free Software @@ -18,10 +18,13 @@ use strict; use warnings; use utf8; -# Set up the test driver $Self when we are running as a standalone script. -use Kernel::System::UnitTest::RegisterDriver; +# core modules -use vars (qw($Self)); +# CPAN modules +use Test2::V0; + +# OTOBO modules +use Kernel::System::UnitTest::RegisterDriver; # Set up $Kernel::OM # Get helper object $Kernel::OM->ObjectParamAdd( @@ -65,10 +68,7 @@ my $TicketID = $TicketObject->TicketCreate( UserID => 1, ); -$Self->True( - $TicketID, - "TicketCreate()", -); +ok( $TicketID, "TicketCreate()" ); my $ArticleObject = $Kernel::OM->Get('Kernel::System::Ticket::Article'); my $ArticleBackendObject = $ArticleObject->BackendForChannel( ChannelName => 'Phone' ); @@ -87,10 +87,7 @@ my $ArticleID = $ArticleBackendObject->ArticleCreate( HistoryComment => '%%', UserID => 1, ); -$Self->True( - $ArticleID, - "ArticleCreate()", -); +ok( $ArticleID, "ArticleCreate()" ); my %ArticleData = $ArticleBackendObject->ArticleGet( TicketID => $TicketID, @@ -221,26 +218,27 @@ for my $Test (@Tests) { my %ObjectData = $ObjectHandlerObject->ObjectDataGet( %{ $Test->{Config} } ); if ( !$Test->{Success} ) { - $Self->IsDeeply( + is( \%ObjectData, {}, "$Test->{Name} - ObjectDataGet() unsuccessful", ); + next TEST; } - $Self->IsDeeply( + is( \%ObjectData, $Test->{ExectedResult}, "$Test->{Name} ObjectDataGet()", ); } continue { + + # force creation of new ParamObject in the next iteration $Kernel::OM->ObjectsDiscard( Objects => [ 'Kernel::System::Web::Request', ], ); } -# cleanup is done by RestoreDatabase - -$Self->DoneTesting(); +done_testing;