Bug 28327: Add unit tests
Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
2b963d3683
commit
a2e9b44074
2 changed files with 44 additions and 2 deletions
19
t/Context.t
19
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 = {};
|
||||
|
||||
|
|
|
@ -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");
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue