Bug 14778: Make Barcodes_ValueBuilder.t db dependent
[koha.git] / t / db_dependent / Circulation / Returns.t
1 use Modern::Perl;
2 use Test::More tests => 2;
3
4 use C4::Biblio;
5 use C4::Circulation;
6 use C4::Items;
7 use C4::Members;
8 use Koha::DateUtils;
9
10 use MARC::Record;
11
12 *C4::Context::userenv = \&Mock_userenv;
13
14 my $dbh = C4::Context->dbh;
15 $dbh->{AutoCommit} = 0;
16 $dbh->{RaiseError} = 1;
17
18 my $record = MARC::Record->new();
19 my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $record, '' );
20
21 my ( undef, undef, $itemnumber ) = AddItem(
22     {
23         homebranch         => 'CPL',
24         holdingbranch      => 'CPL',
25         barcode            => 'i_dont_exist',
26         location           => 'PROC',
27         permanent_location => 'TEST'
28     },
29     $biblionumber
30 );
31
32 my $item;
33
34 C4::Context->set_preference( "InProcessingToShelvingCart", 1 );
35 AddReturn( 'i_dont_exist', 'CPL' );
36 $item = GetItem($itemnumber);
37 is( $item->{location}, 'CART', "InProcessingToShelvingCart functions as intended" );
38
39 $item->{location} = 'PROC';
40 ModItem( $item, undef, $itemnumber );
41
42 C4::Context->set_preference( "InProcessingToShelvingCart", 0 );
43 AddReturn( 'i_dont_exist', 'CPL' );
44 $item = GetItem($itemnumber);
45 is( $item->{location}, 'TEST', "InProcessingToShelvingCart functions as intended" );
46
47 # C4::Context->userenv
48 sub Mock_userenv {
49     return { branch => 'CPL' };
50 }