Bug 17600: Standardize our EXPORT_OK
[srvgit] / t / db_dependent / Koha / Acquisition / Basket.t
index 0570e24..971752a 100755 (executable)
@@ -25,7 +25,7 @@ use Test::Exception;
 use t::lib::TestBuilder;
 use t::lib::Mocks;
 
-use C4::Acquisition;
+use C4::Acquisition qw( NewBasket ModBasket ModBasketHeader );
 use Koha::Database;
 use Koha::DateUtils qw(dt_from_string);
 
@@ -303,7 +303,7 @@ subtest 'orders' => sub {
     $schema->storage->txn_rollback;
 };
 
-subtest 'closed() tests' => sub {
+subtest 'is_closed() tests' => sub {
 
     plan tests => 2;
 
@@ -327,15 +327,19 @@ subtest 'closed() tests' => sub {
         }
     );
 
-    ok( $closed_basket->closed, 'Closed basket is tested as closed' );
-    ok( !$open_basket->closed, 'Open basket is tested as open' );
+    ok( $closed_basket->is_closed, 'Closed basket is tested as closed' );
+    ok( !$open_basket->is_closed, 'Open basket is tested as open' );
 
     $schema->storage->txn_rollback;
 };
 
 subtest 'close() tests' => sub {
 
-    plan tests => 3;
+    plan tests => 4;
+
+    # Turn on acquisitions logging and ensure the logs are empty
+    t::lib::Mocks::mock_preference('AcquisitionLog', 1);
+    Koha::ActionLogs->delete;
 
     $schema->storage->txn_begin;
 
@@ -363,7 +367,7 @@ subtest 'close() tests' => sub {
 
     $basket->close;
 
-    ok( $basket->closed, 'Basket is closed' );
+    ok( $basket->is_closed, 'Basket is closed' );
     my $ordered_orders = $basket->orders->search({ orderstatus => 'ordered' });
     is( $ordered_orders->count, 3, 'Only open orders have been marked as ordered' );
 
@@ -372,5 +376,8 @@ subtest 'close() tests' => sub {
         'Koha::Exceptions::Acquisition::Basket::AlreadyClosed',
         'Trying to close an already closed basket throws an exception';
 
+    my @close_logs = Koha::ActionLogs->search({ module =>'ACQUISITIONS', action => 'CLOSE_BASKET', object => $basket->id });
+    is (scalar @close_logs, 1, 'Basket closure is logged');
+
     $schema->storage->txn_rollback;
 };