Lines 12-23
use Koha::Virtualshelfcontents;
Link Here
|
12 |
|
12 |
|
13 |
use t::lib::TestBuilder; |
13 |
use t::lib::TestBuilder; |
14 |
|
14 |
|
|
|
15 |
my $builder = t::lib::TestBuilder->new; |
15 |
my $dbh = C4::Context->dbh; |
16 |
my $dbh = C4::Context->dbh; |
16 |
$dbh->{AutoCommit} = 0; |
|
|
17 |
teardown(); |
17 |
teardown(); |
18 |
|
18 |
|
19 |
my $builder = t::lib::TestBuilder->new; |
|
|
20 |
|
21 |
subtest 'CRUD' => sub { |
19 |
subtest 'CRUD' => sub { |
22 |
plan tests => 13; |
20 |
plan tests => 13; |
23 |
my $patron = $builder->build({ |
21 |
my $patron = $builder->build({ |
Lines 207-216
subtest 'Shelf content' => sub {
Link Here
|
207 |
$shelf->allow_delete_own(0); |
205 |
$shelf->allow_delete_own(0); |
208 |
$shelf->store; |
206 |
$shelf->store; |
209 |
$number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio2->{biblionumber} ], borrowernumber => $patron1->{borrowernumber} } ); |
207 |
$number_of_deleted_biblios = $shelf->remove_biblios( { biblionumbers => [ $biblio2->{biblionumber} ], borrowernumber => $patron1->{borrowernumber} } ); |
210 |
is( $number_of_deleted_biblios, 1, ); |
208 |
is( $number_of_deleted_biblios, 0, 'A patron is not allowed to delete his own content if allow_delete_own=0, even if he is the owner of the list'); |
211 |
$number_of_contents = Koha::Virtualshelfcontents->search->count; |
209 |
$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)' ); |
210 |
is( $number_of_contents, 1, 'The biblio should not 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} ); |
|
|
214 |
|
211 |
|
215 |
# allow_add = 1, allow_delete_own = 1 |
212 |
# allow_add = 1, allow_delete_own = 1 |
216 |
$shelf->allow_add(1); |
213 |
$shelf->allow_add(1); |
Lines 273-279
subtest 'Shelf permissions' => sub {
Link Here
|
273 |
is( $public_shelf->can_biblios_be_added( $patron1->{borrowernumber} ), 1, 'The owner should be able to add biblios to his list' ); |
270 |
is( $public_shelf->can_biblios_be_added( $patron1->{borrowernumber} ), 1, 'The owner should be able to add biblios to his list' ); |
274 |
is( $public_shelf->can_biblios_be_added( $patron2->{borrowernumber} ), 0, 'Public list should not be modified (add) by someone else' ); |
271 |
is( $public_shelf->can_biblios_be_added( $patron2->{borrowernumber} ), 0, 'Public list should not be modified (add) by someone else' ); |
275 |
|
272 |
|
276 |
is( $public_shelf->can_biblios_be_removed( $patron1->{borrowernumber} ), 1, 'The owner should be able to remove biblios to his list' ); |
273 |
is( $public_shelf->can_biblios_be_removed( $patron1->{borrowernumber} ), 0, 'The owner not should be able to remove biblios to his list' ); |
277 |
is( $public_shelf->can_biblios_be_removed( $patron2->{borrowernumber} ), 0, 'Public list should not be modified (remove) by someone else' ); |
274 |
is( $public_shelf->can_biblios_be_removed( $patron2->{borrowernumber} ), 0, 'Public list should not be modified (remove) by someone else' ); |
278 |
|
275 |
|
279 |
|
276 |
|
Lines 320-326
subtest 'Shelf permissions' => sub {
Link Here
|
320 |
is( $private_shelf->can_biblios_be_added( $patron1->{borrowernumber} ), 1, 'The owner should be able to add biblios to his list' ); |
317 |
is( $private_shelf->can_biblios_be_added( $patron1->{borrowernumber} ), 1, 'The owner should be able to add biblios to his list' ); |
321 |
is( $private_shelf->can_biblios_be_added( $patron2->{borrowernumber} ), 0, 'Private list should not be modified (add) by someone else' ); |
318 |
is( $private_shelf->can_biblios_be_added( $patron2->{borrowernumber} ), 0, 'Private list should not be modified (add) by someone else' ); |
322 |
|
319 |
|
323 |
is( $private_shelf->can_biblios_be_removed( $patron1->{borrowernumber} ), 1, 'The owner should be able to remove biblios to his list' ); |
320 |
is( $private_shelf->can_biblios_be_removed( $patron1->{borrowernumber} ), 0, 'The owner should not be able to remove biblios to his list' ); |
324 |
is( $private_shelf->can_biblios_be_removed( $patron2->{borrowernumber} ), 0, 'Private list should not be modified (remove) by someone else' ); |
321 |
is( $private_shelf->can_biblios_be_removed( $patron2->{borrowernumber} ), 0, 'Private list should not be modified (remove) by someone else' ); |
325 |
|
322 |
|
326 |
|
323 |
|
327 |
- |
|
|