Bug 11891: set up tests to require that Koha::Database uses same DB handle as C4...
authorGalen Charlton <gmc@esilibrary.com>
Mon, 26 May 2014 18:39:11 +0000 (18:39 +0000)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Thu, 19 Jun 2014 14:54:45 +0000 (11:54 -0300)
This patch removes changes in two cases to work around the fact that
Koha::Database and C4::Context were not using the same DBI database
handle.

To test:

[1] Run prove -v t/db_dependent/ILSDI_Services.t and
    prove -v t/db_dependent/Items.t.  Both tests
    should fail.
[2] Apply the main patches and run step 1 again.  This
    time, both tests should pass.

Signed-off-by: Galen Charlton <gmc@esilibrary.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
t/db_dependent/ILSDI_Services.t
t/db_dependent/Items.t

index 4d584a2..1951ecc 100644 (file)
@@ -22,7 +22,7 @@ $dbh->{RaiseError} = 1;
 my %data = (
     firstname =>  'my firstname',
     surname => 'my surname',
-    categorycode => 'PT',
+    categorycode => 'UT',
     branchcode => 'UT',
     cardnumber => 'ilsdi-cardnumber',
     userid => 'ilsdi-userid',
@@ -30,11 +30,11 @@ my %data = (
 );
 
 # Crate patron category
-unless ( GetBorrowercategory('PT') ) {
+unless ( GetBorrowercategory('UT') ) {
     $dbh->do("INSERT INTO categories
     (categorycode,description,enrolmentperiod,upperagelimit,enrolmentfee,overduenoticerequired,reservefee,category_type,default_privacy)
         VALUES
-    ('PT','Unit tester',99,99,0.000000,1,0.000000,'C','default');");
+    ('UT','Unit tester',99,99,0.000000,1,0.000000,'C','default');");
 }
 
 # Create branch
index 6867f83..d1b15fb 100755 (executable)
@@ -169,10 +169,10 @@ subtest q{Test Koha::Database->schema()->resultset('Item')->itemtype()} => sub {
     my $biblioitem = $biblio->biblioitem();
     my ( $item ) = $biblioitem->items();
 
-    $schema->resultset('Systempreference')->update_or_create({ variable => 'item-level_itypes', value => 0 });
+    C4::Context->set_preference( 'item-level_itypes', 0 );
     ok( $item->effective_itemtype() eq 'BIB_LEVEL', '$item->itemtype() returns biblioitem.itemtype when item-level_itypes is disabled' );
 
-    $schema->resultset('Systempreference')->update_or_create({ variable => 'item-level_itypes', value => 1 });
+    C4::Context->set_preference( 'item-level_itypes', 1 );
     ok( $item->effective_itemtype() eq 'ITEM_LEVEL', '$item->itemtype() returns items.itype when item-level_itypes is disabled' );