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

(-)a/t/db_dependent/Koha/Virtualshelves.t (-4 / +17 lines)
Lines 94-100 subtest 'disown_or_delete() tests' => sub { Link Here
94
94
95
    subtest 'Fallback to userenv' => sub {
95
    subtest 'Fallback to userenv' => sub {
96
96
97
        plan tests => 6;
97
        plan tests => 7;
98
98
99
        $schema->storage->txn_begin;
99
        $schema->storage->txn_begin;
100
100
Lines 133-146 subtest 'disown_or_delete() tests' => sub { Link Here
133
133
134
        t::lib::Mocks::mock_preference( 'ListOwnershipUponPatronDeletion', 'transfer' );
134
        t::lib::Mocks::mock_preference( 'ListOwnershipUponPatronDeletion', 'transfer' );
135
        t::lib::Mocks::mock_preference( 'ListOwnerDesignated', undef );
135
        t::lib::Mocks::mock_preference( 'ListOwnerDesignated', undef );
136
        t::lib::Mocks::mock_userenv({ patron => $patron_3 });
137
136
138
        my $rs = Koha::Virtualshelves->search( { shelfnumber => [ $public_list->id, $private_list->id, $private_list_shared->id ] } );
137
        my $public_list_to_delete = $builder->build_object(
138
            {
139
                class => "Koha::Virtualshelves",
140
                value => { owner => $patron_1->id, public => 1 }
141
            }
142
        );
139
143
144
        my $rs = Koha::Virtualshelves->search({ shelfnumber => $public_list_to_delete->id });
140
        my $result = $rs->disown_or_delete;
145
        my $result = $rs->disown_or_delete;
141
        is( ref($result), 'Koha::Virtualshelves', 'Return type is correct' );
146
        is( ref($result), 'Koha::Virtualshelves', 'Return type is correct' );
142
        $rs->reset;
147
        $rs->reset;
143
148
149
        is( $rs->count, 0, 'ListOwnerDesignated and userenv not set yield deletion' );
150
151
        t::lib::Mocks::mock_userenv({ patron => $patron_3 });
152
153
        $rs = Koha::Virtualshelves->search( { shelfnumber => [ $public_list->id, $private_list->id, $private_list_shared->id ] } );
154
155
        $rs->disown_or_delete;
156
        $rs->reset;
157
144
        is( $rs->count, 2, 'The private/non-shared list was deleted' );
158
        is( $rs->count, 2, 'The private/non-shared list was deleted' );
145
        my $first = $rs->next;
159
        my $first = $rs->next;
146
        is( $first->id, $public_list->id );
160
        is( $first->id, $public_list->id );
147
- 

Return to bug 31288