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

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

Return to bug 35434