Bug 13967: Add a couple of tests for SysPref and Object
authorJonathan Druart <jonathan.druart@koha-community.org>
Thu, 4 Jun 2015 10:05:17 +0000 (12:05 +0200)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Thu, 4 Jun 2015 13:39:16 +0000 (10:39 -0300)
Signed-off-by: Jonathan Druart <jonathan.druart@koha-community.org>
t/db_dependent/Borrowers.t
t/db_dependent/sysprefs.t

index bd75551..50d9c32 100755 (executable)
@@ -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" );
 
index 5b82750..c678d24 100755 (executable)
@@ -19,7 +19,7 @@
 # along with Koha; if not, see <http://www.gnu.org/licenses>.
 
 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' );