|
Lines 1233-1239
subtest 'Shelf permissions' => sub {
Link Here
|
| 1233 |
}; |
1233 |
}; |
| 1234 |
|
1234 |
|
| 1235 |
subtest 'Get shelves' => sub { |
1235 |
subtest 'Get shelves' => sub { |
| 1236 |
plan tests => 5; |
1236 |
plan tests => 13; |
| 1237 |
my $patron1 = $builder->build( |
1237 |
my $patron1 = $builder->build( |
| 1238 |
{ |
1238 |
{ |
| 1239 |
source => 'Borrower', |
1239 |
source => 'Borrower', |
|
Lines 1300-1307
subtest 'Get shelves' => sub {
Link Here
|
| 1300 |
'get_private_shelves should return all shelves for a given patron, even the shared ones' |
1300 |
'get_private_shelves should return all shelves for a given patron, even the shared ones' |
| 1301 |
); |
1301 |
); |
| 1302 |
|
1302 |
|
|
|
1303 |
my $private_shelves_all = $private_shelves->as_list; |
| 1304 |
is( |
| 1305 |
$private_shelves_all->[0]->shelfname, 'private shelf 1 for patron 1', |
| 1306 |
'First private shelf sorted correctly by default' |
| 1307 |
); |
| 1308 |
is( $private_shelves_all->[-1]->shelfname, 'shared shelf', 'Last private shelf sorted correctly by default' ); |
| 1309 |
|
| 1310 |
my $private_shelves_sort_desc = Koha::Virtualshelves->get_private_shelves( |
| 1311 |
{ borrowernumber => $patron1->{borrowernumber}, sort_by => { sortfield => 'shelfname', direction => 'desc' } } |
| 1312 |
); |
| 1313 |
my $private_shelves_sort_desc_all = $private_shelves_sort_desc->as_list; |
| 1314 |
is( |
| 1315 |
$private_shelves_sort_desc_all->[0]->shelfname, 'shared shelf', |
| 1316 |
'First private shelf sorted correctly by explicit desc name sort' |
| 1317 |
); |
| 1318 |
is( |
| 1319 |
$private_shelves_sort_desc_all->[-1]->shelfname, 'private shelf 1 for patron 1', |
| 1320 |
'Last private shelf sorted correctly by explicit desc name sort' |
| 1321 |
); |
| 1322 |
|
| 1303 |
my $public_shelves = Koha::Virtualshelves->get_public_shelves; |
1323 |
my $public_shelves = Koha::Virtualshelves->get_public_shelves; |
| 1304 |
is( $public_shelves->count, 2, 'get_public_shelves should return all public shelves, no matter who is the owner' ); |
1324 |
is( $public_shelves->count, 2, 'get_public_shelves should return all public shelves, no matter who is the owner' ); |
|
|
1325 |
my $public_shelves_all = $public_shelves->as_list; |
| 1326 |
is( $public_shelves_all->[0]->shelfname, 'public shelf 1 for patron 1', 'First shelf sorted correctly by default' ); |
| 1327 |
is( |
| 1328 |
$public_shelves_all->[1]->shelfname, 'public shelf 2 for patron 1', |
| 1329 |
'Second shelf sorted correctly by default' |
| 1330 |
); |
| 1331 |
my $public_shelves_sort_desc = |
| 1332 |
Koha::Virtualshelves->get_public_shelves( { sort_by => { sortfield => 'shelfname', direction => 'desc' } } ); |
| 1333 |
my $public_shelves_sort_desc_all = $public_shelves_sort_desc->as_list; |
| 1334 |
is( |
| 1335 |
$public_shelves_sort_desc_all->[0]->shelfname, 'public shelf 2 for patron 1', |
| 1336 |
'First shelf sorted correctly by explicit desc name sort' |
| 1337 |
); |
| 1338 |
is( |
| 1339 |
$public_shelves_sort_desc_all->[1]->shelfname, 'public shelf 1 for patron 1', |
| 1340 |
'Second shelf sorted correctly by explicit desc name sort' |
| 1341 |
); |
| 1305 |
|
1342 |
|
| 1306 |
my $shared_shelf = eval { $shelf_to_share->share("valid key") }; |
1343 |
my $shared_shelf = eval { $shelf_to_share->share("valid key") }; |
| 1307 |
my $shared_shelves = Koha::Virtualshelfshares->search( { borrowernumber => $patron1->{borrowernumber} } ); |
1344 |
my $shared_shelves = Koha::Virtualshelfshares->search( { borrowernumber => $patron1->{borrowernumber} } ); |
| 1308 |
- |
|
|