Bug 18936: Convert issuingrules fields to circulation_rules
[koha-equinox.git] / t / db_dependent / Fines.t
index 7a0ede4..1960a1f 100644 (file)
@@ -13,19 +13,21 @@ my $schema = Koha::Database->new->schema;
 $schema->storage->txn_begin;
 my $dbh = C4::Context->dbh;
 
-$dbh->do(q|DELETE FROM issuingrules|);
+$dbh->do(q|DELETE FROM circulation_rules|);
 
-my $issuingrule = $schema->resultset('Issuingrule')->create(
+my $issuingrule = Koha::CirculationRules->set_rules(
     {
-        categorycode           => '*',
-        itemtype               => '*',
-        branchcode             => '*',
-        fine                   => 1,
-        finedays               => 0,
-        chargeperiod           => 7,
-        chargeperiod_charge_at => 0,
-        lengthunit             => 'days',
-        issuelength            => 1,
+        categorycode => '*',
+        itemtype     => '*',
+        branchcode   => '*',
+        rules        => {
+            fine                   => 1,
+            finedays               => 0,
+            chargeperiod           => 7,
+            chargeperiod_charge_at => 0,
+            lengthunit             => 'days',
+            issuelength            => 1,
+        }
     }
 );
 
@@ -42,7 +44,16 @@ $period_end = dt_from_string('2000-01-10');
 is( $fine, 1, '9 days overdue, charge period 7 days, charge at end of interval gives fine of $1' );
 
 # Test charging fine at the *beginning* of each charge period
-$issuingrule->update( { chargeperiod_charge_at => 1 } );
+my $issuingrule = Koha::CirculationRules->set_rules(
+    {
+        categorycode => '*',
+        itemtype     => '*',
+        branchcode   => '*',
+        rules        => {
+            chargeperiod_charge_at => 1,
+        }
+    }
+);
 
 $period_end = dt_from_string('2000-01-05');
 ( $fine ) = CalcFine( {}, q{}, q{}, $period_start, $period_end  );