Lines 337-364
subtest 'get_float_libraries and validate_float_sibling' => sub {
Link Here
|
337 |
|
337 |
|
338 |
$schema->storage->txn_begin; |
338 |
$schema->storage->txn_begin; |
339 |
|
339 |
|
340 |
my $library1 = $builder->build_object({ class => 'Koha::Libraries' }); |
340 |
my $library1 = $builder->build_object( { class => 'Koha::Libraries' } ); |
341 |
my $library2 = $builder->build_object({ class => 'Koha::Libraries' }); |
341 |
my $library2 = $builder->build_object( { class => 'Koha::Libraries' } ); |
342 |
my $library3 = $builder->build_object({ class => 'Koha::Libraries' }); |
342 |
my $library3 = $builder->build_object( { class => 'Koha::Libraries' } ); |
343 |
my $library4 = $builder->build_object({ class => 'Koha::Libraries' }); |
343 |
my $library4 = $builder->build_object( { class => 'Koha::Libraries' } ); |
344 |
|
344 |
|
345 |
my $root1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_float_group => 1 } } ); |
345 |
my $root1 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_float_group => 1 } } ); |
346 |
my $root2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_float_group => 1 } } ); |
346 |
my $root2 = $builder->build_object( { class => 'Koha::Library::Groups', value => { ft_local_float_group => 1 } } ); |
|
|
347 |
|
347 |
# Float group 1 |
348 |
# Float group 1 |
348 |
$builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root1->id, branchcode => $library1->branchcode } } ); |
349 |
$builder->build_object( |
349 |
$builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root1->id, branchcode => $library2->branchcode } } ); |
350 |
{ class => 'Koha::Library::Groups', value => { parent_id => $root1->id, branchcode => $library1->branchcode } } |
|
|
351 |
); |
352 |
$builder->build_object( |
353 |
{ class => 'Koha::Library::Groups', value => { parent_id => $root1->id, branchcode => $library2->branchcode } } |
354 |
); |
355 |
|
350 |
# Float group 2 |
356 |
# Float group 2 |
351 |
$builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library3->branchcode } } ); |
357 |
$builder->build_object( |
352 |
$builder->build_object( { class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library4->branchcode } } ); |
358 |
{ class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library3->branchcode } } |
|
|
359 |
); |
360 |
$builder->build_object( |
361 |
{ class => 'Koha::Library::Groups', value => { parent_id => $root2->id, branchcode => $library4->branchcode } } |
362 |
); |
353 |
|
363 |
|
354 |
my @libraries1 = $library1->get_float_libraries()->as_list; |
364 |
my @libraries1 = $library1->get_float_libraries()->as_list; |
355 |
is(scalar @libraries1, '2', '1st float group contains 2 libraries'); |
365 |
is( scalar @libraries1, '2', '1st float group contains 2 libraries' ); |
356 |
|
366 |
|
357 |
my @libraries2 = $library3->get_float_libraries()->as_list; |
367 |
my @libraries2 = $library3->get_float_libraries()->as_list; |
358 |
is(scalar @libraries2, '2', '2nd float group also contains 2 libraries'); |
368 |
is( scalar @libraries2, '2', '2nd float group also contains 2 libraries' ); |
359 |
|
369 |
|
360 |
ok($library1->validate_float_sibling({ branchcode => $library2->branchcode }), "Library1 and library2 belong in to the same float group."); |
370 |
ok( |
361 |
ok($library3->validate_float_sibling({ branchcode => $library4->branchcode }), "Library3 and library5 belong in to the same float group."); |
371 |
$library1->validate_float_sibling( { branchcode => $library2->branchcode } ), |
|
|
372 |
"Library1 and library2 belong in to the same float group." |
373 |
); |
374 |
ok( |
375 |
$library3->validate_float_sibling( { branchcode => $library4->branchcode } ), |
376 |
"Library3 and library5 belong in to the same float group." |
377 |
); |
362 |
|
378 |
|
363 |
$schema->storage->txn_rollback; |
379 |
$schema->storage->txn_rollback; |
364 |
}; |
380 |
}; |
365 |
- |
|
|