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

(-)a/t/db_dependent/Koha/Item.t (-2 / +35 lines)
Lines 545-552 subtest "as_marc_field() tests" => sub { Link Here
545
545
546
subtest 'pickup_locations() tests' => sub {
546
subtest 'pickup_locations() tests' => sub {
547
547
548
    plan tests => 68;
548
    plan tests => 70;
549
549
550
    t::lib::Mocks::mock_preference('canreservefromotherbranches', 1);
550
    $schema->storage->txn_begin;
551
    $schema->storage->txn_begin;
551
552
552
    my $dbh = C4::Context->dbh;
553
    my $dbh = C4::Context->dbh;
Lines 848-853 subtest 'pickup_locations() tests' => sub { Link Here
848
849
849
    t::lib::Mocks::mock_preference('UseBranchTransferLimits', 0);
850
    t::lib::Mocks::mock_preference('UseBranchTransferLimits', 0);
850
851
852
    t::lib::Mocks::mock_preference( 'IndependentBranches',         1 );
853
    t::lib::Mocks::mock_preference( 'canreservefromotherbranches', 0 );
854
    t::lib::Mocks::mock_userenv( { branchcode => $library4->branchcode } );
855
856
    my $item4 = $builder->build_sample_item(
857
        {
858
            homebranch    => $library4->branchcode,
859
            holdingbranch => $library4->branchcode
860
        }
861
    )->store;
862
    my $patron5 = $builder->build_object(
863
        { class => 'Koha::Patrons', value => { branchcode => $library4->branchcode, firstname => '5', flags => 84 } } );
864
865
    @pickup_locations = map {
866
        my $pickup_location = $_;
867
        grep { $pickup_location->branchcode eq $_ } @branchcodes
868
    } $item4->pickup_locations( { patron => $patron5 } )->as_list;
869
    ok(
870
        scalar(@pickup_locations) == 1 && @pickup_locations[0] eq $library4->branchcode,
871
        'There should be only one branch in the pickup locations, the connected branch'
872
    );
873
874
    t::lib::Mocks::mock_userenv( { branchcode => $library2->branchcode } );
875
876
    @pickup_locations = map {
877
        my $pickup_location = $_;
878
        grep { $pickup_location->branchcode eq $_ } @branchcodes
879
    } $item4->pickup_locations( { patron => $patron5 } )->as_list;
880
    ok(
881
        scalar(@pickup_locations) == 0,
882
        'The pickup locations should be empty if the user connected branch is not the same as the item home branch'
883
    );
884
851
    $schema->storage->txn_rollback;
885
    $schema->storage->txn_rollback;
852
};
886
};
853
887
854
- 

Return to bug 35434