Skip to content

Commit

Permalink
Issue #4060: adapt test to new year range 2019-2025
Browse files Browse the repository at this point in the history
Use the testing function TextEqOrDiff() for checking long multiline strings.
  • Loading branch information
bschmalhofer committed Jan 15, 2025
1 parent 21030f2 commit 5fff159
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 18 deletions.
16 changes: 13 additions & 3 deletions scripts/test/EmailParser/MultipartMixed.t
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -237,7 +238,7 @@ Cheers,<BR>
/* 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
Expand Down Expand Up @@ -284,7 +285,7 @@ for my $Test (@Tests) {
);

my $Body = $EmailParserObject->GetMessageBody;
is(
TextEqOrDiff(
$Body,
$Test->{Body},
"$Test->{Name} - body (line $Test->{Line})",
Expand All @@ -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},
Expand Down
11 changes: 6 additions & 5 deletions scripts/test/Layout/RichTextDocumentComplete.t
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -43,7 +44,7 @@ my @Tests = (
/* OTOBO is a web-based ticketing system for service organisations.
Copyright (C) 2001-2020 OTRS AG, <a href="https://otrs.com/" target="_blank" title="https://otrs.com/">https://otrs.com/</a>
Copyright (C) 2019-2024 Rother OSS GmbH, <a href="https://otobo.io/" target="_blank" title="https://otobo.io/">https://otobo.io/</a>
Copyright (C) 2019-2025 Rother OSS GmbH, <a href="https://otobo.io/" target="_blank" title="https://otobo.io/">https://otobo.io/</a>
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
Expand All @@ -70,7 +71,7 @@ END_HTML
/* OTOBO is a web-based ticketing system for service organisations.
Copyright (C) 2001-2020 OTRS AG, <a href="https://otrs.com/" target="_blank" title="https://otrs.com/">https://otrs.com/</a>
Copyright (C) 2019-2024 Rother OSS GmbH, <a href="https://otobo.io/" target="_blank" title="https://otobo.io/">https://otobo.io/</a>
Copyright (C) 2019-2025 Rother OSS GmbH, <a href="https://otobo.io/" target="_blank" title="https://otobo.io/">https://otobo.io/</a>
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
Expand All @@ -97,7 +98,7 @@ END_HTML
/* OTOBO is a web-based ticketing system for service organisations.
Copyright (C) 2001-2020 OTRS AG, <a href="https://otrs.com/" target="_blank" title="https://otrs.com/">https://otrs.com/</a>
Copyright (C) 2019-2024 Rother OSS GmbH, <a href="https://otobo.io/" target="_blank" title="https://otobo.io/">https://otobo.io/</a>
Copyright (C) 2019-2025 Rother OSS GmbH, <a href="https://otobo.io/" target="_blank" title="https://otobo.io/">https://otobo.io/</a>
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
Expand All @@ -123,7 +124,7 @@ END_HTML
/* OTOBO is a web-based ticketing system for service organisations.
Copyright (C) 2001-2020 OTRS AG, <a href="https://otrs.com/" target="_blank" title="https://otrs.com/">https://otrs.com/</a>
Copyright (C) 2019-2024 Rother OSS GmbH, <a href="https://otobo.io/" target="_blank" title="https://otobo.io/">https://otobo.io/</a>
Copyright (C) 2019-2025 Rother OSS GmbH, <a href="https://otobo.io/" target="_blank" title="https://otobo.io/">https://otobo.io/</a>
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
Expand All @@ -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})",
Expand Down
13 changes: 7 additions & 6 deletions scripts/test/Loader.t
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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' );
}

{
Expand All @@ -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()' );
}

{
Expand Down Expand Up @@ -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",
Expand All @@ -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;
5 changes: 3 additions & 2 deletions scripts/test/TemplateGenerator/AutoResponse.t
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion scripts/test/sample/Loader/OTOBO.Agent.App.Login.min.js
Original file line number Diff line number Diff line change
@@ -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();}
Expand Down
2 changes: 1 addition & 1 deletion scripts/test/sample/Loader/OTOBO.Reset.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 5fff159

Please sign in to comment.