From 5fff1592293aeae260a4dc6a49a444fdca203dc3 Mon Sep 17 00:00:00 2001 From: bernhard Date: Wed, 15 Jan 2025 16:18:30 +0100 Subject: [PATCH] Issue #4060: adapt test to new year range 2019-2025 Use the testing function TextEqOrDiff() for checking long multiline strings. --- scripts/test/EmailParser/MultipartMixed.t | 16 +++++++++++++--- scripts/test/Layout/RichTextDocumentComplete.t | 11 ++++++----- scripts/test/Loader.t | 13 +++++++------ scripts/test/TemplateGenerator/AutoResponse.t | 5 +++-- .../sample/Loader/OTOBO.Agent.App.Login.min.js | 2 +- scripts/test/sample/Loader/OTOBO.Reset.min.css | 2 +- 6 files changed, 31 insertions(+), 18 deletions(-) diff --git a/scripts/test/EmailParser/MultipartMixed.t b/scripts/test/EmailParser/MultipartMixed.t index 5ad640b85c..f795ee316f 100644 --- a/scripts/test/EmailParser/MultipartMixed.t +++ b/scripts/test/EmailParser/MultipartMixed.t @@ -26,7 +26,8 @@ use Test2::V0; # OTOBO modules use Kernel::System::UnitTest::RegisterOM; # Set up $Kernel::OM -use Kernel::System::EmailParser (); +use Kernel::System::EmailParser (); +use Kernel::System::UnitTest::Diff qw(TextEqOrDiff); my $Home = $Kernel::OM->Get('Kernel::Config')->Get('Home'); @@ -237,7 +238,7 @@ Cheers,
/* OTOBO is a web-based ticketing system for service organisations. Copyright (C) 2001-2020 OTRS AG, https://otrs.com/ -Copyright (C) 2019-2024 Rother OSS GmbH, https://otobo.io/ +Copyright (C) 2019-2025 Rother OSS GmbH, https://otobo.io/ 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 @@ -284,7 +285,7 @@ for my $Test (@Tests) { ); my $Body = $EmailParserObject->GetMessageBody; - is( + TextEqOrDiff( $Body, $Test->{Body}, "$Test->{Name} - body (line $Test->{Line})", @@ -299,6 +300,15 @@ for my $Test (@Tests) { } } + # Explicitily compare the content of the attachments with TextEqOrDiff(), + # just so potential diffs can be more easily inspected + for my $i ( 0 .. $Test->{Attachments}->$#* ) { + TextEqOrDiff( + $Attachments[$i]->{Content}, + $Test->{Attachments}->[$i]->{Content}, + "$Test->{Name} - attachment $i (line $Test->{Line})" + ); + } is( \@Attachments, $Test->{Attachments}, diff --git a/scripts/test/Layout/RichTextDocumentComplete.t b/scripts/test/Layout/RichTextDocumentComplete.t index 97728aefee..55c34e9e0a 100644 --- a/scripts/test/Layout/RichTextDocumentComplete.t +++ b/scripts/test/Layout/RichTextDocumentComplete.t @@ -26,6 +26,7 @@ use Test2::V0; # OTOBO modules use Kernel::System::UnitTest::RegisterOM; # Set up $Kernel::OM +use Kernel::System::UnitTest::Diff qw(TextEqOrDiff); # get layout object my $LayoutObject = $Kernel::OM->Get('Kernel::Output::HTML::Layout'); @@ -43,7 +44,7 @@ my @Tests = ( /* OTOBO is a web-based ticketing system for service organisations. Copyright (C) 2001-2020 OTRS AG, https://otrs.com/ -Copyright (C) 2019-2024 Rother OSS GmbH, https://otobo.io/ +Copyright (C) 2019-2025 Rother OSS GmbH, https://otobo.io/ 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 @@ -70,7 +71,7 @@ END_HTML /* OTOBO is a web-based ticketing system for service organisations. Copyright (C) 2001-2020 OTRS AG, https://otrs.com/ -Copyright (C) 2019-2024 Rother OSS GmbH, https://otobo.io/ +Copyright (C) 2019-2025 Rother OSS GmbH, https://otobo.io/ 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 @@ -97,7 +98,7 @@ END_HTML /* OTOBO is a web-based ticketing system for service organisations. Copyright (C) 2001-2020 OTRS AG, https://otrs.com/ -Copyright (C) 2019-2024 Rother OSS GmbH, https://otobo.io/ +Copyright (C) 2019-2025 Rother OSS GmbH, https://otobo.io/ 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 @@ -123,7 +124,7 @@ END_HTML /* OTOBO is a web-based ticketing system for service organisations. Copyright (C) 2001-2020 OTRS AG, https://otrs.com/ -Copyright (C) 2019-2024 Rother OSS GmbH, https://otobo.io/ +Copyright (C) 2019-2025 Rother OSS GmbH, https://otobo.io/ 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 @@ -143,7 +144,7 @@ for my $Test (@Tests) { my $HTMLString = $LayoutObject->RichTextDocumentComplete( String => $Test->{String}, ); - is( + TextEqOrDiff( "$HTMLString\n", $Test->{Result}, "$Test->{Name} (line $Test->{Line})", diff --git a/scripts/test/Loader.t b/scripts/test/Loader.t index 3bf2956e52..c668c5d4f8 100644 --- a/scripts/test/Loader.t +++ b/scripts/test/Loader.t @@ -26,6 +26,7 @@ use Test2::V0; # OTOBO modules use Kernel::System::UnitTest::RegisterOM; # Set up $Kernel::OM +use Kernel::System::UnitTest::Diff qw(TextEqOrDiff); use Kernel::Config; # the question whether there is a S3 backend must the resolved early @@ -64,7 +65,7 @@ my $Home = $ConfigObject->Get('Home'); my $MinifiedCSS = $LoaderObject->MinifyCSS( Code => $CSS ); - is( $MinifiedCSS, $ExpectedCSS, 'MinifyCSS()' ); + TextEqOrDiff( $MinifiedCSS, $ExpectedCSS, 'MinifyCSS()' ); # empty cache $Kernel::OM->Get('Kernel::System::Cache')->CleanUp( @@ -81,8 +82,8 @@ my $Home = $ConfigObject->Get('Home'); Type => 'CSS', ); - is( $MinifiedCSSFile, $ExpectedCSS, 'GetMinifiedFile() for CSS, no cache' ); - is( $MinifiedCSSFile, $ExpectedCSS, 'GetMinifiedFile() for CSS, with cache' ); + TextEqOrDiff( $MinifiedCSSFile, $ExpectedCSS, 'GetMinifiedFile() for CSS, no cache' ); + TextEqOrDiff( $MinifiedCSSFile, $ExpectedCSS, 'GetMinifiedFile() for CSS, with cache' ); } { @@ -103,7 +104,7 @@ my $Home = $ConfigObject->Get('Home'); $ExpectedJS =~ s{\r\n}{\n}xmsg; chomp $ExpectedJS; # newline after the last line - is( $MinifiedJS, $ExpectedJS, 'MinifyJavaScript()' ); + TextEqOrDiff( $MinifiedJS, $ExpectedJS, 'MinifyJavaScript()' ); } { @@ -151,7 +152,7 @@ my $Home = $ConfigObject->Get('Home'); $Expected =~ s{\r\n}{\n}xmsg; $Expected =~ s{\n$}{}; # newline after the last line - is( $MinifiedJS, $Expected, 'MinifyFiles() result content' ); + TextEqOrDiff( $MinifiedJS, $Expected, 'MinifyFiles() result content' ); $MainObject->FileDelete( Location => $ConfigObject->Get('TempDir') . "/$MinifiedJSFilename", @@ -173,7 +174,7 @@ for my $Test (@JSTests) { my $Result = $LoaderObject->MinifyJavaScript( Code => $Test->{Source}, ); - is( $Result, $Test->{Result}, $Test->{Name} ); + TextEqOrDiff( $Result, $Test->{Result}, $Test->{Name} ); } done_testing; diff --git a/scripts/test/TemplateGenerator/AutoResponse.t b/scripts/test/TemplateGenerator/AutoResponse.t index 946cef64a0..f0d1135865 100644 --- a/scripts/test/TemplateGenerator/AutoResponse.t +++ b/scripts/test/TemplateGenerator/AutoResponse.t @@ -27,6 +27,7 @@ use Test2::V0; # OTOBO modules use Kernel::System::UnitTest::MockTime qw(FixedTimeSet); use Kernel::System::UnitTest::RegisterOM; # Set up $Kernel::OM +use Kernel::System::UnitTest::Diff qw(TextEqOrDiff); my $ConfigObject = $Kernel::OM->Get('Kernel::Config'); @@ -143,7 +144,7 @@ my $HTMLTemplate = /* OTOBO is a web-based ticketing system for service organisations. Copyright (C) 2001-2020 OTRS AG, https://otrs.com/ -Copyright (C) 2019-2024 Rother OSS GmbH, https://otobo.io/ +Copyright (C) 2019-2025 Rother OSS GmbH, https://otobo.io/ 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 @@ -192,7 +193,7 @@ for my $Test (@Tests) { AutoResponseType => 'auto reply/new ticket', UserID => 1, ); - is( + TextEqOrDiff( $AutoResponse{Text}, $Test->{ExpectedResult}, "$Test->{Name} AutoResponse() - Text" diff --git a/scripts/test/sample/Loader/OTOBO.Agent.App.Login.min.js b/scripts/test/sample/Loader/OTOBO.Agent.App.Login.min.js index 49c0a4484f..66e2c790ac 100644 --- a/scripts/test/sample/Loader/OTOBO.Agent.App.Login.min.js +++ b/scripts/test/sample/Loader/OTOBO.Agent.App.Login.min.js @@ -1,5 +1,5 @@ // Copyright (C) 2001-2020 OTRS AG, https://otrs.com/ -// Copyright (C) 2019-2024 Rother OSS GmbH, https://otobo.io/ +// Copyright (C) 2019-2025 Rother OSS GmbH, https://otobo.io/ "use strict";var OTOBO=OTOBO||{};OTOBO.Agent=OTOBO.Agent||{};OTOBO.Agent.App=OTOBO.Agent.App||{};OTOBO.Agent.App.Login=(function(TargetNS){TargetNS.Init=function(){if(!OTOBO.Debug.BrowserCheck()){$('#LoginBox').hide();$('#OldBrowser').show();return;} OTOBO.Form.EnableForm($('#LoginBox form, #PasswordBox form'));if($('#User').val()&&$('#User').val().length){$('#Password').focus();} else{$('#User').focus();} diff --git a/scripts/test/sample/Loader/OTOBO.Reset.min.css b/scripts/test/sample/Loader/OTOBO.Reset.min.css index 5b1a1be6b8..30d4ad39c2 100644 --- a/scripts/test/sample/Loader/OTOBO.Reset.min.css +++ b/scripts/test/sample/Loader/OTOBO.Reset.min.css @@ -1,7 +1,7 @@ /* OTOBO is a web-based ticketing system for service organisations. Copyright (C) 2001-2020 OTRS AG, https://otrs.com/ -Copyright (C) 2019-2024 Rother OSS GmbH, https://otobo.io/ +Copyright (C) 2019-2025 Rother OSS GmbH, https://otobo.io/ 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