Bug 11943: Add unit test for double accepts

Test plan:
Run t/db_dependent/Virtualshelves.t

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Marcel de Rooy 2018-05-04 09:54:30 +02:00 committed by Jonathan Druart
parent 94fd62dac9
commit ee82d441c2

View file

@ -90,7 +90,7 @@ subtest 'CRUD' => sub {
};
subtest 'Sharing' => sub {
plan tests => 18;
plan tests => 21;
my $patron_wants_to_share = $builder->build({
source => 'Borrower',
});
@ -152,6 +152,14 @@ subtest 'Sharing' => sub {
$number_of_shelves_shared = Koha::Virtualshelfshares->search->count;
is( $number_of_shelves_shared, 2, 'To be sure no shares have been removed' );
# Test double accept (BZ 11943) before removing the accepted share
my $third_share = $shelf_to_share->share('valid key number 2');
is( Koha::Virtualshelfshares->search->count, 3, 'Three shares' );
$is_accepted = $third_share->accept( 'valid key number 2', $share_with_me->{borrowernumber} );
is( $is_accepted->shelfnumber, $shelf_to_share->shelfnumber, 'Accept returned the existing share' );
is( Koha::Virtualshelfshares->search->count, 2, 'Check that number of shares went down again' );
# Remove the first accept
is( $shelf_to_share->remove_share( $share_with_me->{borrowernumber} ), 1, '1 share should have been removed if the shelf was shared with this patron' );
$number_of_shelves_shared = Koha::Virtualshelfshares->search->count;
is( $number_of_shelves_shared, 1, 'To be sure the share has been removed' );