Bugzilla – Attachment 160470 Details for
Bug 33036
Add route to merge bibliographic records
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33036: Add more tests
Bug-33036-Add-more-tests.patch (text/plain), 9.24 KB, created by
Jonathan Druart
on 2024-01-03 14:54:29 UTC
(
hide
)
Description:
Bug 33036: Add more tests
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-01-03 14:54:29 UTC
Size:
9.24 KB
patch
obsolete
>From 9f565fc95e83d1e13e1868ef7f1bb7bcf8012aa3 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 14 Dec 2023 10:29:32 +0100 >Subject: [PATCH] Bug 33036: Add more tests > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > t/db_dependent/Koha/Biblio.t | 188 +++++++++++++++++++++++++++++++---- > 1 file changed, 167 insertions(+), 21 deletions(-) > >diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t >index f95ffc5525d..1ce1e25ae36 100755 >--- a/t/db_dependent/Koha/Biblio.t >+++ b/t/db_dependent/Koha/Biblio.t >@@ -23,6 +23,7 @@ use Test::Warn; > > use C4::Biblio qw( AddBiblio ModBiblio ModBiblioMarc ); > use C4::Circulation qw( AddIssue AddReturn ); >+use C4::Reserves qw( AddReserve ); > > use Koha::Database; > use Koha::Cache::Memory::Lite; >@@ -487,34 +488,179 @@ subtest 'to_api() tests' => sub { > }; > > subtest 'merge of records' => sub { >- plan tests => 9; >- $schema->storage->txn_begin; >+ plan tests => 8; > >- # 3 items from 3 different biblio records >- my $item1 = $builder->build_sample_item; >- my $item2 = $builder->build_sample_item; >- my $item3 = $builder->build_sample_item; >+ subtest 'move items' => sub { >+ plan tests => 9; >+ $schema->storage->txn_begin; > >- my $biblio1 = $item1->biblio; >- my $biblio2 = $item2->biblio; >- my $biblio3 = $item3->biblio; >+ # 3 items from 3 different biblio records >+ my $item1 = $builder->build_sample_item; >+ my $item2 = $builder->build_sample_item; >+ my $item3 = $builder->build_sample_item; > >- my $pre_merged_rs = Koha::Biblios->search( >- { biblionumber => [ $biblio1->biblionumber, $biblio2->biblionumber, $biblio3->biblionumber ] } ); >- is( $pre_merged_rs->count, 3, '3 biblios exist' ); >+ my $biblio1 = $item1->biblio; >+ my $biblio2 = $item2->biblio; >+ my $biblio3 = $item3->biblio; > >- warning_like { $biblio1->merge_with( [ $biblio2->biblionumber, $biblio3->biblionumber ] ) } q{}; >- is( $biblio1->items->count, 3, "After merge we have 3 items on first record" ); >+ my $pre_merged_rs = Koha::Biblios->search( >+ { biblionumber => [ $biblio1->biblionumber, $biblio2->biblionumber, $biblio3->biblionumber ] } ); >+ is( $pre_merged_rs->count, 3, '3 biblios exist' ); > >- is( ref( $biblio1->get_from_storage ), 'Koha::Biblio', 'biblio record 1 still exists' ); >- is( $biblio2->get_from_storage, undef, 'biblio record 2 no longer exists' ); >- is( $biblio3->get_from_storage, undef, 'biblio record 3 no longer exists' ); >+ warning_like { $biblio1->merge_with( [ $biblio2->biblionumber, $biblio3->biblionumber ] ) } q{}; >+ is( $biblio1->items->count, 3, "After merge we have 3 items on first record" ); > >- is( $item1->get_from_storage->biblionumber, $biblio1->biblionumber ); >- is( $item2->get_from_storage->biblionumber, $biblio1->biblionumber ); >- is( $item3->get_from_storage->biblionumber, $biblio1->biblionumber ); >+ is( ref( $biblio1->get_from_storage ), 'Koha::Biblio', 'biblio record 1 still exists' ); >+ is( $biblio2->get_from_storage, undef, 'biblio record 2 no longer exists' ); >+ is( $biblio3->get_from_storage, undef, 'biblio record 3 no longer exists' ); >+ >+ is( $item1->get_from_storage->biblionumber, $biblio1->biblionumber ); >+ is( $item2->get_from_storage->biblionumber, $biblio1->biblionumber ); >+ is( $item3->get_from_storage->biblionumber, $biblio1->biblionumber ); >+ >+ $schema->storage->txn_rollback; >+ }; >+ >+ subtest 'move holds' => sub { >+ plan tests => 3; >+ $schema->storage->txn_begin; >+ >+ my $biblio1 = $builder->build_sample_biblio; >+ my $biblio2 = $builder->build_sample_biblio; >+ >+ my $hold1 = >+ $builder->build_object( { class => 'Koha::Holds', value => { biblionumber => $biblio1->biblionumber } } ); >+ my $hold2 = >+ $builder->build_object( { class => 'Koha::Holds', value => { biblionumber => $biblio2->biblionumber } } ); >+ >+ warning_like { $biblio1->merge_with( [ $biblio2->biblionumber ] ) } q{}; >+ >+ is( $hold1->get_from_storage->biblionumber, $biblio1->biblionumber ); >+ is( $hold2->get_from_storage->biblionumber, $biblio1->biblionumber ); >+ >+ $schema->storage->txn_rollback; >+ }; >+ >+ subtest 'move article requests' => sub { >+ plan tests => 3; >+ $schema->storage->txn_begin; >+ >+ my $biblio1 = $builder->build_sample_biblio; >+ my $biblio2 = $builder->build_sample_biblio; >+ >+ my $ar1 = $builder->build_object( >+ { class => 'Koha::ArticleRequests', value => { biblionumber => $biblio1->biblionumber } } ); >+ my $ar2 = $builder->build_object( >+ { class => 'Koha::ArticleRequests', value => { biblionumber => $biblio2->biblionumber } } ); >+ >+ warning_like { $biblio1->merge_with( [ $biblio2->biblionumber ] ) } q{}; >+ >+ is( $ar1->get_from_storage->biblionumber, $biblio1->biblionumber ); >+ is( $ar2->get_from_storage->biblionumber, $biblio1->biblionumber ); >+ >+ $schema->storage->txn_rollback; >+ }; >+ >+ subtest 'move subscriptions' => sub { >+ plan tests => 3; >+ $schema->storage->txn_begin; >+ >+ my $biblio1 = $builder->build_sample_biblio; >+ my $biblio2 = $builder->build_sample_biblio; >+ >+ my $sub1 = $builder->build_object( >+ { class => 'Koha::Subscriptions', value => { biblionumber => $biblio1->biblionumber } } ); >+ my $sub2 = $builder->build_object( >+ { class => 'Koha::Subscriptions', value => { biblionumber => $biblio2->biblionumber } } ); >+ >+ warning_like { $biblio1->merge_with( [ $biblio2->biblionumber ] ) } q{}; >+ >+ is( $sub1->get_from_storage->biblionumber, $biblio1->biblionumber ); >+ is( $sub2->get_from_storage->biblionumber, $biblio1->biblionumber ); >+ >+ $schema->storage->txn_rollback; >+ }; >+ >+ subtest 'move serials' => sub { >+ plan tests => 3; >+ $schema->storage->txn_begin; >+ >+ my $biblio1 = $builder->build_sample_biblio; >+ my $biblio2 = $builder->build_sample_biblio; >+ >+ my $serial1 = >+ $builder->build_object( { class => 'Koha::Serials', value => { biblionumber => $biblio1->biblionumber } } ); >+ my $serial2 = >+ $builder->build_object( { class => 'Koha::Serials', value => { biblionumber => $biblio2->biblionumber } } ); >+ >+ warning_like { $biblio1->merge_with( [ $biblio2->biblionumber ] ) } q{}; >+ >+ is( $serial1->get_from_storage->biblionumber, $biblio1->biblionumber ); >+ is( $serial2->get_from_storage->biblionumber, $biblio1->biblionumber ); >+ >+ $schema->storage->txn_rollback; >+ }; >+ >+ subtest 'move subscription history' => sub { >+ plan tests => 3; >+ $schema->storage->txn_begin; >+ >+ my $biblio1 = $builder->build_sample_biblio; >+ my $biblio2 = $builder->build_sample_biblio; >+ >+ my $sh1 = $builder->build_object( >+ { class => 'Koha::Subscription::Histories', value => { biblionumber => $biblio1->biblionumber } } ); >+ my $sh2 = $builder->build_object( >+ { class => 'Koha::Subscription::Histories', value => { biblionumber => $biblio2->biblionumber } } ); >+ >+ warning_like { $biblio1->merge_with( [ $biblio2->biblionumber ] ) } q{}; >+ >+ is( $sh1->get_from_storage->biblionumber, $biblio1->biblionumber ); >+ is( $sh2->get_from_storage->biblionumber, $biblio1->biblionumber ); >+ >+ $schema->storage->txn_rollback; >+ }; >+ >+ subtest 'move suggestions' => sub { >+ plan tests => 3; >+ $schema->storage->txn_begin; >+ >+ my $biblio1 = $builder->build_sample_biblio; >+ my $biblio2 = $builder->build_sample_biblio; >+ >+ my $suggestion1 = $builder->build_object( >+ { class => 'Koha::Suggestions', value => { biblionumber => $biblio1->biblionumber } } ); >+ my $suggestion2 = $builder->build_object( >+ { class => 'Koha::Suggestions', value => { biblionumber => $biblio2->biblionumber } } ); >+ >+ warning_like { $biblio1->merge_with( [ $biblio2->biblionumber ] ) } q{}; >+ >+ is( $suggestion1->get_from_storage->biblionumber, $biblio1->biblionumber ); >+ is( $suggestion2->get_from_storage->biblionumber, $biblio1->biblionumber ); >+ >+ $schema->storage->txn_rollback; >+ }; >+ >+ subtest 'move orders' => sub { >+ plan tests => 3; >+ $schema->storage->txn_begin; >+ >+ my $biblio1 = $builder->build_sample_biblio; >+ my $biblio2 = $builder->build_sample_biblio; >+ >+ my $order1 = $builder->build_object( >+ { class => 'Koha::Acquisition::Orders', value => { biblionumber => $biblio1->biblionumber } } ); >+ my $order2 = $builder->build_object( >+ { class => 'Koha::Acquisition::Orders', value => { biblionumber => $biblio2->biblionumber } } ); >+ >+ warning_like { $biblio1->merge_with( [ $biblio2->biblionumber ] ) } q{}; >+ >+ is( $order1->get_from_storage->biblionumber, $biblio1->biblionumber ); >+ is( $order2->get_from_storage->biblionumber, $biblio1->biblionumber ); >+ >+ $schema->storage->txn_rollback; >+ }; > >- $schema->storage->txn_rollback; > }; > > subtest 'suggestions() tests' => sub { >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 33036
:
152436
|
152437
|
152438
|
152439
|
152440
|
152447
|
152472
|
152659
|
152678
|
157481
|
157482
|
157731
|
159011
|
159012
|
159103
|
159120
|
159191
|
159239
|
159826
|
159827
|
159828
|
159829
|
160302
|
160468
|
160469
| 160470 |
160471
|
160472