Bug 17600: Standardize our EXPORT_OK
[srvgit] / t / db_dependent / Utils / Datatables_Virtualshelves.t
old mode 100644 (file)
new mode 100755 (executable)
index cdc7225..d43dbc5
@@ -19,7 +19,7 @@ use Modern::Perl;
 
 use Test::More tests => 13;
 
-use C4::Biblio;
+use C4::Biblio qw( AddBiblio );
 use C4::Context;
 
 use Koha::Library;
@@ -27,6 +27,8 @@ use Koha::Patrons;
 use Koha::Patron::Categories;
 use Koha::Virtualshelves;
 
+use t::lib::Mocks;
+
 use_ok( "C4::Utils::DataTables::VirtualShelves" );
 
 my $schema = Koha::Database->new->schema;
@@ -36,7 +38,7 @@ my $dbh = C4::Context->dbh;
 $dbh->do(q|DELETE FROM virtualshelves|);
 
 # Pick a categorycode from the DB
-my @categories   = Koha::Patron::Categories->search_limited;
+my @categories   = Koha::Patron::Categories->search_with_library_limits;
 my $categorycode = $categories[0]->categorycode;
 my $branchcode   = "ABC";
 my $branch_data = {
@@ -77,7 +79,8 @@ my %john_smith = (
     userid       => 'john.smith',
 );
 
-$john_doe{borrowernumber} = Koha::Patron->new( \%john_doe )->store->borrowernumber;
+my $john_doe_patron = Koha::Patron->new( \%john_doe )->store;
+$john_doe{borrowernumber} = $john_doe_patron->borrowernumber;
 $jane_doe{borrowernumber} = Koha::Patron->new( \%jane_doe )->store->borrowernumber;
 $john_smith{borrowernumber} = Koha::Patron->new( \%john_smith )->store->borrowernumber;
 
@@ -179,8 +182,7 @@ my %dt_params = (
 );
 my $search_results;
 
-C4::Context->_new_userenv ('DUMMY_SESSION_ID');
-C4::Context->set_userenv($john_doe{borrowernumber}, $john_doe{userid}, 'usercnum', 'First name', 'Surname', 'MYLIBRARY', 'My Library', 0);
+t::lib::Mocks::mock_userenv({ patron => $john_doe_patron });
 
 # Search private lists by title
 $search_results = C4::Utils::DataTables::VirtualShelves::search({