Bugzilla – Attachment 136473 Details for
Bug 28327
System preference CSVdelimiter special case for tabulation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28327: Add unit tests
Bug-28327-Add-unit-tests.patch (text/plain), 3.50 KB, created by
Fridolin Somers
on 2022-06-24 07:42:46 UTC
(
hide
)
Description:
Bug 28327: Add unit tests
Filename:
MIME Type:
Creator:
Fridolin Somers
Created:
2022-06-24 07:42:46 UTC
Size:
3.50 KB
patch
obsolete
>From 8ae0b89517513334721edf83812521b778001df0 Mon Sep 17 00:00:00 2001 >From: Fridolin Somers <fridolin.somers@biblibre.com> >Date: Mon, 21 Mar 2022 21:48:50 -1000 >Subject: [PATCH] Bug 28327: Add unit tests > >--- > t/Context.t | 19 ++++++++++++++++++- > t/Koha_Template_Plugin_Koha.t | 27 ++++++++++++++++++++++++++- > 2 files changed, 44 insertions(+), 2 deletions(-) > >diff --git a/t/Context.t b/t/Context.t >index 156ae778bb..8d353e35f6 100755 >--- a/t/Context.t >+++ b/t/Context.t >@@ -18,7 +18,7 @@ > use Modern::Perl; > > use DBI; >-use Test::More tests => 31; >+use Test::More tests => 32; > use Test::MockModule; > use Test::Warn; > use YAML::XS; >@@ -63,6 +63,23 @@ subtest 'needs_install() tests' => sub { > is( C4::Context->needs_install, 1, "->preference(Version) is not defined, need to install" ); > }; > >+subtest 'csv_delimiter() tests' => sub { >+ >+ plan tests => 4; >+ >+ t::lib::Mocks::mock_preference( 'CSVDelimiter', undef ); >+ is( C4::Context->csv_delimiter, ';', "csv_delimiter returns semicolon if system preference CSVDelimiter is undefined" ); >+ >+ t::lib::Mocks::mock_preference( 'CSVDelimiter', '' ); >+ is( C4::Context->csv_delimiter, ';', "csv_delimiter returns semicolon if system preference CSVDelimiter is empty string" ); >+ >+ t::lib::Mocks::mock_preference( 'CSVDelimiter', ',' ); >+ is( C4::Context->csv_delimiter, ',', "csv_delimiter returns comma if system preference CSVDelimiter is comma" ); >+ >+ t::lib::Mocks::mock_preference( 'CSVDelimiter', 'tabulation' ); >+ is( C4::Context->csv_delimiter, "\t", "csv_delimiter returns '\t' if system preference CSVDelimiter is tabulation" ); >+}; >+ > my $context = Test::MockModule->new('C4::Context'); > my $userenv = {}; > >diff --git a/t/Koha_Template_Plugin_Koha.t b/t/Koha_Template_Plugin_Koha.t >index 13079a9753..812f5f96cc 100755 >--- a/t/Koha_Template_Plugin_Koha.t >+++ b/t/Koha_Template_Plugin_Koha.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 4; >+use Test::More tests => 5; > use Test::MockModule; > use t::lib::Mocks; > >@@ -88,3 +88,28 @@ subtest "Koha::Template::Plugin::Koha::ArePluginsEnabled tests" => sub { > is(Koha::Template::Plugin::Koha::ArePluginsEnabled(), 0, "Correct ArePluginsEnabled is no"); > > }; >+ >+subtest "Koha::Template::Plugin::Koha::CSVDelimiter tests" => sub { >+ >+ plan tests => 8; >+ >+ my $plugin = Koha::Template::Plugin::Koha->new(); >+ >+ t::lib::Mocks::mock_preference('CSVDelimiter', ''); >+ is($plugin->CSVDelimiter(), ',', "CSVDelimiter() returns comma when preference is empty string"); >+ >+ t::lib::Mocks::mock_preference('CSVDelimiter', undef); >+ is($plugin->CSVDelimiter(), ',', "CSVDelimiter() returns comma when preference is undefined"); >+ >+ t::lib::Mocks::mock_preference('CSVDelimiter', ';'); >+ is($plugin->CSVDelimiter(), ';', "CSVDelimiter() returns preference value when preference is not tabulation"); >+ >+ t::lib::Mocks::mock_preference('CSVDelimiter', 'tabulation'); >+ is($plugin->CSVDelimiter(), "\t", "CSVDelimiter() returns \\t when preference is tabulation"); >+ >+ t::lib::Mocks::mock_preference('CSVDelimiter', '#'); >+ is($plugin->CSVDelimiter(undef), '#', "CSVDelimiter(arg) returns preference value when arg is undefined"); >+ is($plugin->CSVDelimiter(''), '#', "CSVDelimiter(arg) returns preference value when arg is empty string"); >+ is($plugin->CSVDelimiter(','), ',', "CSVDelimiter(arg) returns arg value when arg is not tabulation"); >+ is($plugin->CSVDelimiter('tabulation'), "\t", "CSVDelimiter(arg) returns \\t value when arg is tabulation"); >+}; >-- >2.35.3
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 28327
:
120859
|
120861
|
120867
|
120868
|
120869
|
120870
|
120871
|
120872
|
120873
|
120874
|
120876
|
120877
|
120878
|
120879
|
120880
|
120881
|
126682
|
126683
|
126684
|
126685
|
126964
|
126965
|
126966
|
126967
|
131995
|
131996
|
131997
|
136378
|
136379
|
136380
|
136381
|
136473
|
136474
|
136475
|
136535
|
136536
|
136537
|
139479
|
139513
|
139514
|
139515
|
139516