View | Details | Raw Unified | Return to bug 35434
Collapse All | Expand All

(-)a/t/db_dependent/Koha/Item.t (-2 / +35 lines)
Lines 700-707 subtest "as_marc_field() tests" => sub { Link Here
700
700
701
subtest 'pickup_locations() tests' => sub {
701
subtest 'pickup_locations() tests' => sub {
702
702
703
    plan tests => 68;
703
    plan tests => 70;
704
704
705
    t::lib::Mocks::mock_preference('canreservefromotherbranches', 1);
705
    $schema->storage->txn_begin;
706
    $schema->storage->txn_begin;
706
707
707
    my $dbh = C4::Context->dbh;
708
    my $dbh = C4::Context->dbh;
Lines 1022-1027 subtest 'pickup_locations() tests' => sub { Link Here
1022
1023
1023
    t::lib::Mocks::mock_preference( 'UseBranchTransferLimits', 0 );
1024
    t::lib::Mocks::mock_preference( 'UseBranchTransferLimits', 0 );
1024
1025
1026
    t::lib::Mocks::mock_preference( 'IndependentBranches',         1 );
1027
    t::lib::Mocks::mock_preference( 'canreservefromotherbranches', 0 );
1028
    t::lib::Mocks::mock_userenv( { branchcode => $library4->branchcode } );
1029
1030
    my $item4 = $builder->build_sample_item(
1031
        {
1032
            homebranch    => $library4->branchcode,
1033
            holdingbranch => $library4->branchcode
1034
        }
1035
    )->store;
1036
    my $patron5 = $builder->build_object(
1037
        { class => 'Koha::Patrons', value => { branchcode => $library4->branchcode, firstname => '5', flags => 84 } } );
1038
1039
    @pickup_locations = map {
1040
        my $pickup_location = $_;
1041
        grep { $pickup_location->branchcode eq $_ } @branchcodes
1042
    } $item4->pickup_locations( { patron => $patron5 } )->as_list;
1043
    ok(
1044
        scalar(@pickup_locations) == 1 && @pickup_locations[0] eq $library4->branchcode,
1045
        'There should be only one branch in the pickup locations, the connected branch'
1046
    );
1047
1048
    t::lib::Mocks::mock_userenv( { branchcode => $library2->branchcode } );
1049
1050
    @pickup_locations = map {
1051
        my $pickup_location = $_;
1052
        grep { $pickup_location->branchcode eq $_ } @branchcodes
1053
    } $item4->pickup_locations( { patron => $patron5 } )->as_list;
1054
    ok(
1055
        scalar(@pickup_locations) == 0,
1056
        'The pickup locations should be empty if the user connected branch is not the same as the item home branch'
1057
    );
1058
1025
    $schema->storage->txn_rollback;
1059
    $schema->storage->txn_rollback;
1026
};
1060
};
1027
1061
1028
- 

Return to bug 35434