Lines 561-568
subtest "as_marc_field() tests" => sub {
Link Here
|
561 |
|
561 |
|
562 |
subtest 'pickup_locations() tests' => sub { |
562 |
subtest 'pickup_locations() tests' => sub { |
563 |
|
563 |
|
564 |
plan tests => 68; |
564 |
plan tests => 70; |
565 |
|
565 |
|
|
|
566 |
t::lib::Mocks::mock_preference('canreservefromotherbranches', 1); |
566 |
$schema->storage->txn_begin; |
567 |
$schema->storage->txn_begin; |
567 |
|
568 |
|
568 |
my $dbh = C4::Context->dbh; |
569 |
my $dbh = C4::Context->dbh; |
Lines 883-888
subtest 'pickup_locations() tests' => sub {
Link Here
|
883 |
|
884 |
|
884 |
t::lib::Mocks::mock_preference( 'UseBranchTransferLimits', 0 ); |
885 |
t::lib::Mocks::mock_preference( 'UseBranchTransferLimits', 0 ); |
885 |
|
886 |
|
|
|
887 |
t::lib::Mocks::mock_preference( 'IndependentBranches', 1 ); |
888 |
t::lib::Mocks::mock_preference( 'canreservefromotherbranches', 0 ); |
889 |
t::lib::Mocks::mock_userenv( { branchcode => $library4->branchcode } ); |
890 |
|
891 |
my $item4 = $builder->build_sample_item( |
892 |
{ |
893 |
homebranch => $library4->branchcode, |
894 |
holdingbranch => $library4->branchcode |
895 |
} |
896 |
)->store; |
897 |
my $patron5 = $builder->build_object( |
898 |
{ class => 'Koha::Patrons', value => { branchcode => $library4->branchcode, firstname => '5', flags => 84 } } ); |
899 |
|
900 |
@pickup_locations = map { |
901 |
my $pickup_location = $_; |
902 |
grep { $pickup_location->branchcode eq $_ } @branchcodes |
903 |
} $item4->pickup_locations( { patron => $patron5 } )->as_list; |
904 |
ok( |
905 |
scalar(@pickup_locations) == 1 && @pickup_locations[0] eq $library4->branchcode, |
906 |
'There should be only one branch in the pickup locations, the connected branch' |
907 |
); |
908 |
|
909 |
t::lib::Mocks::mock_userenv( { branchcode => $library2->branchcode } ); |
910 |
|
911 |
@pickup_locations = map { |
912 |
my $pickup_location = $_; |
913 |
grep { $pickup_location->branchcode eq $_ } @branchcodes |
914 |
} $item4->pickup_locations( { patron => $patron5 } )->as_list; |
915 |
ok( |
916 |
scalar(@pickup_locations) == 0, |
917 |
'The pickup locations should be empty if the user connected branch is not the same as the item home branch' |
918 |
); |
919 |
|
886 |
$schema->storage->txn_rollback; |
920 |
$schema->storage->txn_rollback; |
887 |
}; |
921 |
}; |
888 |
|
922 |
|
889 |
- |
|
|