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

(-)a/t/db_dependent/Virtualshelves.t (-5 / +4 lines)
Lines 120-140 subtest 'Sharing' => sub { Link Here
120
120
121
    my $shared_shelf = eval { $shelf_to_share->share };
121
    my $shared_shelf = eval { $shelf_to_share->share };
122
    is ( ref( $@ ), 'Koha::Exceptions::Virtualshelves::InvalidKeyOnSharing', 'Do not share if no key given' );
122
    is ( ref( $@ ), 'Koha::Exceptions::Virtualshelves::InvalidKeyOnSharing', 'Do not share if no key given' );
123
    $shared_shelf = eval { $shelf_to_share->share('this is a valid key') };
123
    $shared_shelf = eval { $shelf_to_share->share('valid key') };
124
    is( ref( $shared_shelf ), 'Koha::Virtualshelfshare', 'On sharing, the method should return a valid Koha::Virtualshelfshare object' );
124
    is( ref( $shared_shelf ), 'Koha::Virtualshelfshare', 'On sharing, the method should return a valid Koha::Virtualshelfshare object' );
125
125
126
    my $another_shared_shelf = eval { $shelf_to_share->share('this is another valid key') }; # Just to have 2 shares in DB
126
    my $another_shared_shelf = eval { $shelf_to_share->share('valid key2') }; # Just to have 2 shares in DB
127
127
128
    $number_of_shelves_shared = Koha::Virtualshelfshares->search->count;
128
    $number_of_shelves_shared = Koha::Virtualshelfshares->search->count;
129
    is( $number_of_shelves_shared, 2, '2 shares should have been inserted' );
129
    is( $number_of_shelves_shared, 2, '2 shares should have been inserted' );
130
130
131
    my $is_accepted = eval {
131
    my $is_accepted = eval {
132
        $shared_shelf->accept( 'this is an invalid key', $share_with_me->{borrowernumber} );
132
        $shared_shelf->accept( 'invalid k', $share_with_me->{borrowernumber} );
133
    };
133
    };
134
    is( $is_accepted, undef, 'The share should have not been accepted if the key is invalid' );
134
    is( $is_accepted, undef, 'The share should have not been accepted if the key is invalid' );
135
    is( ref( $@ ), 'Koha::Exceptions::Virtualshelves::InvalidInviteKey', 'accept with an invalid key should raise an exception' );
135
    is( ref( $@ ), 'Koha::Exceptions::Virtualshelves::InvalidInviteKey', 'accept with an invalid key should raise an exception' );
136
136
137
    $is_accepted = $shared_shelf->accept( 'this is a valid key', $share_with_me->{borrowernumber} );
137
    $is_accepted = $shared_shelf->accept( 'valid key', $share_with_me->{borrowernumber} );
138
    ok( defined($is_accepted), 'The share should have been accepted if the key valid' );
138
    ok( defined($is_accepted), 'The share should have been accepted if the key valid' );
139
139
140
    is( $shelf_to_share->is_shared, 1, 'first shelf is shared' );
140
    is( $shelf_to_share->is_shared, 1, 'first shelf is shared' );
141
- 

Return to bug 20144