Bug 21817: Fix 2 failing tests
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 11 Dec 2018 15:28:53 +0000 (12:28 -0300)
committerNick Clemens <nick@bywatersolutions.com>
Wed, 2 Jan 2019 20:18:30 +0000 (20:18 +0000)
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

t/db_dependent/Acquisition/NewOrder.t
t/db_dependent/Bookseller.t

index 96a2d72..79a53ec 100644 (file)
@@ -11,6 +11,7 @@ use Koha::Database;
 use Koha::DateUtils qw( dt_from_string output_pref );
 use Koha::Acquisition::Booksellers;
 use Koha::Acquisition::Orders;
+use t::lib::TestBuilder;
 use t::lib::Mocks;
 
 my $schema = Koha::Database->new()->schema();
@@ -18,7 +19,9 @@ $schema->storage->txn_begin();
 my $dbh = C4::Context->dbh;
 $dbh->{RaiseError} = 1;
 
-t::lib::Mocks::mock_userenv({ branchcode => 'CPL' });
+my $builder = t::lib::TestBuilder->new;
+my $logged_in_user = $builder->build_object({ class => 'Koha::Patrons' });
+t::lib::Mocks::mock_userenv({ patron => $logged_in_user });
 
 my $bookseller = Koha::Acquisition::Bookseller->new(
     {
@@ -89,6 +92,6 @@ my $ordernumber = $order->ordernumber;
 $order = Koha::Acquisition::Orders->find( $ordernumber );
 is( $order->quantityreceived, 0, 'Koha::Acquisition::Order->insert set quantityreceivedto 0 if undef is given' );
 is( $order->entrydate, output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 }), 'Koha::Acquisition::Order->store set entrydate to today' );
-is( $order->created_by, 42, 'Koha::Acquisition::Order->store set created_by to logged in user if not given' );
+is( $order->created_by, $logged_in_user->borrowernumber, 'Koha::Acquisition::Order->store set created_by to logged in user if not given' );
 
 $schema->storage->txn_rollback();
index 9e5a193..c6f4c7f 100644 (file)
@@ -639,7 +639,7 @@ ok( exists( $suppliers{$id_supplier1} ),
     "Supplier1 has late orders and $daysago10==$daysago10 " )
   ;
 
-t::lib::Mocks::mock_userenv({ flags => 0 });
+t::lib::Mocks::mock_userenv({ flags => 0, branchcode => 'BRANCH1' });
 
 my $module = Test::MockModule->new('C4::Auth');
 $module->mock(
@@ -670,7 +670,7 @@ is(
 );
 
 # don the cape and turn into Superlibrarian!
-t::lib::Mocks::mock_userenv({ flags => 1 });
+t::lib::Mocks::mock_userenv({ flags => 1, branchcode => 'BRANCH1' });
 @subscriptions = SearchSubscriptions({expiration_date => '2013-12-31'});
 is(
     scalar(grep { !$_->{cannotdisplay} } @subscriptions ),