From e514e304bf4c8caee2434f244e81a3f77c8a25dc Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 4 Jun 2015 12:05:17 +0200 Subject: [PATCH] Bug 13967: Add a couple of tests for SysPref and Object Signed-off-by: Jonathan Druart --- t/db_dependent/Borrowers.t | 5 ++++- t/db_dependent/sysprefs.t | 10 ++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/t/db_dependent/Borrowers.t b/t/db_dependent/Borrowers.t index bd75551..50d9c32 100755 --- a/t/db_dependent/Borrowers.t +++ b/t/db_dependent/Borrowers.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 12; +use Test::More tests => 13; use Test::Warn; use C4::Context; @@ -72,6 +72,9 @@ is( $b1->surname(), $b1_new->surname(), "Found matching borrower" ); my @borrowers = Koha::Borrowers->search( { branchcode => $branchcode } ); is( @borrowers, 3, "Found 3 borrowers with Search" ); +my $unexistent = Koha::Borrowers->find( '1234567890' ); +is( $unexistent, undef, 'Koha::Objects->Find should return undef if the record does not exist' ); + my $borrowers = Koha::Borrowers->search( { branchcode => $branchcode } ); is( $borrowers->count( { branchcode => $branchcode } ), 3, "Counted 3 borrowers with Count" ); diff --git a/t/db_dependent/sysprefs.t b/t/db_dependent/sysprefs.t index 5b82750..c678d24 100755 --- a/t/db_dependent/sysprefs.t +++ b/t/db_dependent/sysprefs.t @@ -19,7 +19,7 @@ # along with Koha; if not, see . use Modern::Perl; -use Test::More tests => 4; +use Test::More tests => 5; use C4::Context; # Start transaction @@ -31,10 +31,10 @@ my $opacheader = C4::Context->preference('opacheader'); my $newopacheader = "newopacheader"; C4::Context->set_preference( 'OPACHEADER', $newopacheader ); -is( C4::Context->preference('opacheader'), $newopacheader ); +is( C4::Context->preference('opacheader'), $newopacheader, 'The pref should have been set correctly' ); C4::Context->set_preference( 'opacheader', $opacheader ); -is( C4::Context->preference('OPACHEADER'), $opacheader ); +is( C4::Context->preference('OPACHEADER'), $opacheader, 'A pref name should be case insensitive'); $ENV{OVERRIDE_SYSPREF_opacheader} = 'this is an override'; C4::Context->clear_syspref_cache(); @@ -44,5 +44,7 @@ is( 'system preference value overridden from environment' ); +is( C4::Context->preference('IDoNotExist'), undef, 'Get a non-existent system preference should return undef'); + C4::Context->set_preference( 'IDoNotExist', 'NonExistent' ); -is( C4::Context->preference('IDoNotExist'), 'NonExistent', 'Test creation of non-existant system preferencer' ); +is( C4::Context->preference('IDoNotExist'), 'NonExistent', 'Test creation of non-existent system preference' ); -- 2.1.0