Bug 18286: [Follow-up] Remove assumption on branch count
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Tue, 2 May 2017 14:18:41 +0000 (16:18 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 5 Jun 2017 20:52:44 +0000 (17:52 -0300)
A test in db_dependent should not make assumptions on the number of
branches in the database. If you need one, create one. Removing the
assumption of a non-zero count.

Removing the library count statement outside the subtest.
Replacing C4::Context by Koha::Database.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
t/db_dependent/01-test_dbic.t

index 0741332..c3d9727 100644 (file)
@@ -7,14 +7,11 @@ use Modern::Perl;
 use Test::More;
 use Test::MockModule;
 
+use Koha::Database;
 use Koha::Libraries;
-use C4::Context;
-
-Koha::Libraries->search->count;
 
 my $verbose = 0;
 
-
 subtest "Scenario: Show how caching prevents Test::DBIx::Class from working properly and how to circumvent it", sub {
   my ($firstSchema, $cachedSchema, $cachedSchema2, $firstLibCount, $libCount);
 
@@ -23,11 +20,8 @@ subtest "Scenario: Show how caching prevents Test::DBIx::Class from working prop
   ok($firstSchema = Koha::Database->schema,
   'Step: Given a normal DB connection.');
 
-  ok($firstLibCount = Koha::Libraries->search->count,
-  '  When the libraries are counted');
+  $firstLibCount = Koha::Libraries->search->count; # first count normal conn
 
-  ok($firstLibCount,
-  '  Then we got a count'); #There should be something like 12 branches in the default DB but making an accurate check here to prevent surface for brittleness.
   print "\$firstLibCount '$firstLibCount'\n" if $verbose;
 
   ok($cachedSchema = Koha::Database::get_schema_cached(),