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

(-)a/t/db_dependent/Virtualshelves.t (-9 / +10 lines)
Lines 57-63 subtest 'CRUD' => sub { Link Here
57
            }
57
            }
58
        )->store;
58
        )->store;
59
    };
59
    };
60
    is( ref($@), 'Koha::Exceptions::Virtualshelves::DuplicateObject' );
60
    is( ref($@), 'Koha::Exceptions::Virtualshelves::DuplicateObject',
61
        'Exception on duplicate name' );
61
    $number_of_shelves = Koha::Virtualshelves->search->count;
62
    $number_of_shelves = Koha::Virtualshelves->search->count;
62
    is( $number_of_shelves, 1, 'To be sure the number of shelves is still 1' );
63
    is( $number_of_shelves, 1, 'To be sure the number of shelves is still 1' );
63
64
Lines 130-137 subtest 'Sharing' => sub { Link Here
130
    $is_accepted = $shared_shelf->accept( 'this is a valid key', $share_with_me->{borrowernumber} );
131
    $is_accepted = $shared_shelf->accept( 'this is a valid key', $share_with_me->{borrowernumber} );
131
    ok( defined($is_accepted), 'The share should have been accepted if the key valid' );
132
    ok( defined($is_accepted), 'The share should have been accepted if the key valid' );
132
133
133
    is( $shelf_to_share->is_shared, 1 );
134
    is( $shelf_to_share->is_shared, 1, 'first shelf is shared' );
134
    is( $shelf_not_to_share->is_shared, 0 );
135
    is( $shelf_not_to_share->is_shared, 0, 'second shelf is not shared' );
135
136
136
    is( $shelf_to_share->is_shared_with( $patron_wants_to_share->{borrowernumber} ), 0 , "The shelf should not be shared with the owner" );
137
    is( $shelf_to_share->is_shared_with( $patron_wants_to_share->{borrowernumber} ), 0 , "The shelf should not be shared with the owner" );
137
    is( $shelf_to_share->is_shared_with( $share_with_me->{borrowernumber} ), 1 , "The shelf should be shared with share_with_me" );
138
    is( $shelf_to_share->is_shared_with( $share_with_me->{borrowernumber} ), 1 , "The shelf should be shared with share_with_me" );
Lines 196-204 subtest 'Shelf content' => sub { Link Here
196
    # Patron 2 will try to remove a content
197
    # Patron 2 will try to remove a content
197
    # allow_add = 0, allow_delete_own = 1, allow_delete_other = 0 => Default values
198
    # allow_add = 0, allow_delete_own = 1, allow_delete_other = 0 => Default values
198
    my $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio1->{biblionumber} ], borrowernumber => $patron2->{borrowernumber} } );
199
    my $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio1->{biblionumber} ], borrowernumber => $patron2->{borrowernumber} } );
199
    is( $number_of_deleted_biblios, 0, );
200
    is( $number_of_deleted_biblios, 0, 'Patron 2 removed nothing' );
201
    # Now try with patron 1
200
    $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio1->{biblionumber} ], borrowernumber => $patron1->{borrowernumber} } );
202
    $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio1->{biblionumber} ], borrowernumber => $patron1->{borrowernumber} } );
201
    is( $number_of_deleted_biblios, 1, );
203
    is( $number_of_deleted_biblios, 1, 'Patron 1 removed biblio' );
202
204
203
    $number_of_contents = Koha::Virtualshelfcontents->search->count;
205
    $number_of_contents = Koha::Virtualshelfcontents->search->count;
204
    is( $number_of_contents, 1, 'To be sure the content has been deleted' );
206
    is( $number_of_contents, 1, 'To be sure the content has been deleted' );
Lines 207-213 subtest 'Shelf content' => sub { Link Here
207
    $shelf->allow_delete_own(0);
209
    $shelf->allow_delete_own(0);
208
    $shelf->store;
210
    $shelf->store;
209
    $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio2->{biblionumber} ], borrowernumber => $patron1->{borrowernumber} } );
211
    $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio2->{biblionumber} ], borrowernumber => $patron1->{borrowernumber} } );
210
    is( $number_of_deleted_biblios, 1, );
212
    is( $number_of_deleted_biblios, 1, 'Patron 1 removed another biblio' );
211
    $number_of_contents = Koha::Virtualshelfcontents->search->count;
213
    $number_of_contents = Koha::Virtualshelfcontents->search->count;
212
    is( $number_of_contents, 0, 'The biblio should have been deleted to the shelf by the patron, it is his own content (allow_delete_own=0)' );
214
    is( $number_of_contents, 0, 'The biblio should have been deleted to the shelf by the patron, it is his own content (allow_delete_own=0)' );
213
    $shelf->add_biblio( $biblio2->{biblionumber}, $patron1->{borrowernumber} );
215
    $shelf->add_biblio( $biblio2->{biblionumber}, $patron1->{borrowernumber} );
Lines 224-230 subtest 'Shelf content' => sub { Link Here
224
    is( $number_of_contents, 3, 'The biblio should have been added to the shelf by the patron 2' );
226
    is( $number_of_contents, 3, 'The biblio should have been added to the shelf by the patron 2' );
225
227
226
    $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio3->{biblionumber} ], borrowernumber => $patron2->{borrowernumber} } );
228
    $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio3->{biblionumber} ], borrowernumber => $patron2->{borrowernumber} } );
227
    is( $number_of_deleted_biblios, 1, );
229
    is( $number_of_deleted_biblios, 1, 'Biblio 3 deleted by patron 2' );
228
    $number_of_contents = Koha::Virtualshelfcontents->search->count;
230
    $number_of_contents = Koha::Virtualshelfcontents->search->count;
229
    is( $number_of_contents, 2, 'The biblio should have been deleted to the shelf by the patron, it is his own content (allow_delete_own=1) ' );
231
    is( $number_of_contents, 2, 'The biblio should have been deleted to the shelf by the patron, it is his own content (allow_delete_own=1) ' );
230
232
Lines 233-239 subtest 'Shelf content' => sub { Link Here
233
    $shelf->store;
235
    $shelf->store;
234
236
235
    $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio2->{biblionumber} ], borrowernumber => $patron2->{borrowernumber} } );
237
    $number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio2->{biblionumber} ], borrowernumber => $patron2->{borrowernumber} } );
236
    is( $number_of_deleted_biblios, 1, );
238
    is( $number_of_deleted_biblios, 1, 'Biblio 2 deleted by patron 2' );
237
    $number_of_contents = Koha::Virtualshelfcontents->search->count;
239
    $number_of_contents = Koha::Virtualshelfcontents->search->count;
238
    is( $number_of_contents, 1, 'The biblio should have been deleted to the shelf by the patron 2, even if it is not his own content (allow_delete_other=1)' );
240
    is( $number_of_contents, 1, 'The biblio should have been deleted to the shelf by the patron 2, even if it is not his own content (allow_delete_other=1)' );
239
241
240
- 

Return to bug 14544