Bugzilla – Attachment 127944 Details for
Bug 29495
Issue link is lost in return claims when using 'MarkLostItemsAsReturned'
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29495: Add relation tests
Bug-29495-Add-relation-tests.patch (text/plain), 7.66 KB, created by
Martin Renvoize (ashimema)
on 2021-11-22 18:00:57 UTC
(
hide
)
Description:
Bug 29495: Add relation tests
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-11-22 18:00:57 UTC
Size:
7.66 KB
patch
obsolete
>From 05e4d385b31f365883dbb37113c232880343a29c Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Mon, 22 Nov 2021 17:58:13 +0000 >Subject: [PATCH] Bug 29495: Add relation tests > >This patch adds missing tests for relationship accessors in the >ReturnClaim class. >--- > t/db_dependent/Koha/Checkouts/ReturnClaim.t | 183 +++++++++++++++++++- > 1 file changed, 182 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Checkouts/ReturnClaim.t b/t/db_dependent/Koha/Checkouts/ReturnClaim.t >index 1353f3e8ce..a105b1af5d 100755 >--- a/t/db_dependent/Koha/Checkouts/ReturnClaim.t >+++ b/t/db_dependent/Koha/Checkouts/ReturnClaim.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 2; >+use Test::More tests => 6; > use Test::Exception; > > use Koha::Database; >@@ -284,3 +284,184 @@ subtest "resolve() tests" => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'item() tests' => sub { >+ >+ plan tests => 3; >+ >+ $schema->storage->txn_begin; >+ >+ my $librarian = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $item = $builder->build_sample_item; >+ my $checkout = $builder->build_object( >+ { >+ class => 'Koha::Checkouts', >+ value => { >+ borrowernumber => $patron->borrowernumber, >+ itemnumber => $item->itemnumber, >+ branchcode => $patron->branchcode >+ } >+ } >+ ); >+ >+ my $claim = Koha::Checkouts::ReturnClaim->new( >+ { >+ issue_id => $checkout->id, >+ itemnumber => $checkout->itemnumber, >+ borrowernumber => $checkout->borrowernumber, >+ notes => 'Some notes', >+ created_by => $librarian->borrowernumber >+ } >+ )->store; >+ >+ my $return_claim_item = $claim->item; >+ is( ref( $return_claim_item ), 'Koha::Item', 'Koha::Checkouts::ReturnClaim->item should return a Koha::Item' ); >+ is( $claim->itemnumber, $return_claim_item->itemnumber, 'Koha::Checkouts::ReturnClaim->item should return the correct item' ); >+ >+ my $itemnumber = $item->itemnumber; >+ $checkout->delete; # Required to allow deletion of item >+ $item->delete; >+ >+ my $claims = Koha::Checkouts::ReturnClaims->search({ itemnumber => $itemnumber }); >+ is( $claims->count, 0, 'Koha::Checkouts::ReturnClaim is deleted on item deletion' ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+subtest 'patron() tests' => sub { >+ >+ plan tests => 3; >+ >+ $schema->storage->txn_begin; >+ >+ my $librarian = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $item = $builder->build_sample_item; >+ my $checkout = $builder->build_object( >+ { >+ class => 'Koha::Checkouts', >+ value => { >+ borrowernumber => $patron->borrowernumber, >+ itemnumber => $item->itemnumber, >+ branchcode => $patron->branchcode >+ } >+ } >+ ); >+ >+ my $claim = Koha::Checkouts::ReturnClaim->new( >+ { >+ issue_id => $checkout->id, >+ itemnumber => $checkout->itemnumber, >+ borrowernumber => $checkout->borrowernumber, >+ notes => 'Some notes', >+ created_by => $librarian->borrowernumber >+ } >+ )->store; >+ >+ my $return_claim_patron = $claim->patron; >+ is( ref( $return_claim_patron ), 'Koha::Patron', 'Koha::Checkouts::ReturnClaim->patron should return a Koha::Patron' ); >+ is( $claim->borrowernumber, $return_claim_patron->borrowernumber, 'Koha::Checkouts::ReturnClaim->patron should return the correct borrower' ); >+ >+ my $borrowernumber = $patron->borrowernumber; >+ $checkout->delete; # Required to allow deletion of patron >+ $patron->delete; >+ >+ my $claims = Koha::Checkouts::ReturnClaims->search({ borrowernumber => $borrowernumber }); >+ is( $claims->count, 0, 'Koha::Checkouts::ReturnClaim is deleted on borrower deletion' ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+subtest 'old_checkout() tests' => sub { >+ >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ my $librarian = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $item = $builder->build_sample_item; >+ my $old_checkout = $builder->build_object( >+ { >+ class => 'Koha::Old::Checkouts', >+ value => { >+ borrowernumber => $patron->borrowernumber, >+ itemnumber => $item->itemnumber, >+ branchcode => $patron->branchcode >+ } >+ } >+ ); >+ >+ my $claim = Koha::Checkouts::ReturnClaim->new( >+ { >+ issue_id => $old_checkout->id, >+ itemnumber => $old_checkout->itemnumber, >+ borrowernumber => $old_checkout->borrowernumber, >+ notes => 'Some notes', >+ created_by => $librarian->borrowernumber >+ } >+ )->store; >+ >+ my $return_claim_old_checkout = $claim->old_checkout; >+ is( ref( $return_claim_old_checkout ), 'Koha::Old::Checkout', 'Koha::Checkouts::ReturnClaim->old_checkout should return a Koha::Old::Checkout' ); >+ is( $claim->issue_id, $return_claim_old_checkout->issue_id, 'Koha::Checkouts::ReturnClaim->old_checkout should return the correct borrower' ); >+ >+ my $issue_id = $old_checkout->issue_id; >+ $old_checkout->delete; >+ >+ my $claims = Koha::Checkouts::ReturnClaims->search({ issue_id => $issue_id }); >+ is( $claims->count, 1, 'Koha::Checkouts::ReturnClaim remains on old_checkout deletion' ); >+ # FIXME: Should we actually set null on OldCheckout deletion? >+ >+ $claim->issue_id(undef)->store; >+ is( $claim->old_checkout, undef, 'Koha::Checkouts::ReturnClaim->old_checkout should return undef if no old_checkout linked' ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+subtest 'checkout() tests' => sub { >+ >+ plan tests => 4; >+ >+ $schema->storage->txn_begin; >+ >+ my $librarian = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $item = $builder->build_sample_item; >+ my $checkout = $builder->build_object( >+ { >+ class => 'Koha::Checkouts', >+ value => { >+ borrowernumber => $patron->borrowernumber, >+ itemnumber => $item->itemnumber, >+ branchcode => $patron->branchcode >+ } >+ } >+ ); >+ >+ my $claim = Koha::Checkouts::ReturnClaim->new( >+ { >+ issue_id => $checkout->id, >+ itemnumber => $checkout->itemnumber, >+ borrowernumber => $checkout->borrowernumber, >+ notes => 'Some notes', >+ created_by => $librarian->borrowernumber >+ } >+ )->store; >+ >+ my $return_claim_checkout = $claim->checkout; >+ is( ref( $return_claim_checkout ), 'Koha::Checkout', 'Koha::Checkouts::ReturnClaim->checkout should return a Koha::Checkout' ); >+ is( $claim->issue_id, $return_claim_checkout->issue_id, 'Koha::Checkouts::ReturnClaim->checkout should return the correct borrower' ); >+ >+ my $issue_id = $checkout->issue_id; >+ $checkout->delete; >+ >+ my $claims = Koha::Checkouts::ReturnClaims->search({ issue_id => $issue_id }); >+ is( $claims->count, 1, 'Koha::Checkouts::ReturnClaim remains on checkout deletion' ); >+ >+ $claim->issue_id(undef)->store; >+ is( $claim->checkout, undef, 'Koha::Checkouts::ReturnClaim->checkout should return undef if no checkout linked' ); >+ >+ $schema->storage->txn_rollback; >+}; >-- >2.20.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 29495
:
127711
|
127712
|
127713
|
127714
|
127765
|
127766
|
127767
|
127768
|
127769
|
127809
|
127810
|
127811
|
127812
|
127813
|
127937
|
127938
|
127939
|
127940
|
127941
|
127942
|
127943
|
127944
|
129105
|
129106
|
129107
|
129109
|
129110
|
129111
|
129112
|
129113
|
129547
|
129575
|
129582
|
130460
|
130461
|
130462
|
130463
|
130464
|
130465
|
130466
|
130467
|
130752
|
130753
|
130754
|
130755
|
130756
|
130757
|
130758