From 9cbe7d163afb14e85a0c1da93733ac25e8d36898 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 11 Dec 2018 12:28:53 -0300 Subject: [PATCH] Bug 21817: Fix 2 failing tests Signed-off-by: Tomas Cohen Arazi --- t/db_dependent/Acquisition/NewOrder.t | 7 +++++-- t/db_dependent/Bookseller.t | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/t/db_dependent/Acquisition/NewOrder.t b/t/db_dependent/Acquisition/NewOrder.t index 96a2d72bfe..79a53ec397 100644 --- a/t/db_dependent/Acquisition/NewOrder.t +++ b/t/db_dependent/Acquisition/NewOrder.t @@ -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(); diff --git a/t/db_dependent/Bookseller.t b/t/db_dependent/Bookseller.t index 9e5a193820..c6f4c7fa24 100644 --- a/t/db_dependent/Bookseller.t +++ b/t/db_dependent/Bookseller.t @@ -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 ), -- 2.20.0