Bugzilla – Attachment 171613 Details for
Bug 37898
All db dependent tests should run within a transaction
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37898: Wrap Relationships.t inside a transaction
Bug-37898-Wrap-Relationshipst-inside-a-transaction.patch (text/plain), 3.62 KB, created by
Martin Renvoize (ashimema)
on 2024-09-17 12:25:23 UTC
(
hide
)
Description:
Bug 37898: Wrap Relationships.t inside a transaction
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-09-17 12:25:23 UTC
Size:
3.62 KB
patch
obsolete
>From 110d6a139acd59725bfbf57aa7149abcdd94a37a Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 11 Sep 2024 12:55:40 -0300 >Subject: [PATCH] Bug 37898: Wrap Relationships.t inside a transaction > >This tests leave data on the DB and need to be fixed. This patch does >that. > >To test: >1. Run: > $ ktd --shell > k$ echo "SELECT COUNT(*) FROM borrowers \G" | koha-mysql kohadev > k$ echo "SELECT COUNT(*) FROM borrower_relationships \G" | koha-mysql kohadev >2. Run: > k$ prove t/db_dependent/Patron/Relationships.t >=> SUCCESS: Tests pass >3. Repeat 1 >=> FAIL: Numbers don't match the original ones! >4. Apply this patch >5. Repeat 2 and 3 >=> SUCCESS: Tests still pass! >=> SUCCESS: Numbers match! >6. Sign off :-D > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > t/db_dependent/Patron/Relationships.t | 70 +++++++++++++-------------- > 1 file changed, 33 insertions(+), 37 deletions(-) > >diff --git a/t/db_dependent/Patron/Relationships.t b/t/db_dependent/Patron/Relationships.t >index d73e7ef796a..dacac11bf3e 100755 >--- a/t/db_dependent/Patron/Relationships.t >+++ b/t/db_dependent/Patron/Relationships.t >@@ -20,6 +20,7 @@ use Modern::Perl; > use Test::More tests => 54; > > use C4::Context; >+use Koha::Database; > > use t::lib::TestBuilder; > >@@ -30,57 +31,52 @@ BEGIN { > use_ok('Koha::Patron::Relationships'); > } > >+my $schema = Koha::Database->new->schema; > my $builder = t::lib::TestBuilder->new(); > >+$schema->storage->txn_begin; >+ > # Father >-my $kyle = Koha::Patrons->find( >- $builder->build( >- { >- source => 'Borrower', >- value => { >- firstname => 'Kyle', >- surname => 'Hall', >- } >+my $kyle = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { >+ firstname => 'Kyle', >+ surname => 'Hall', > } >- )->{borrowernumber} >+ } > ); > > # Mother >-my $chelsea = Koha::Patrons->find( >- $builder->build( >- { >- source => 'Borrower', >- value => { >- firstname => 'Chelsea', >- surname => 'Hall', >- } >+my $chelsea = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { >+ firstname => 'Chelsea', >+ surname => 'Hall', > } >- )->{borrowernumber} >+ } > ); > > # Children >-my $daria = Koha::Patrons->find( >- $builder->build( >- { >- source => 'Borrower', >- value => { >- firstname => 'Daria', >- surname => 'Hall', >- } >+my $daria = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { >+ firstname => 'Daria', >+ surname => 'Hall', > } >- )->{borrowernumber} >+ } > ); > >-my $kylie = Koha::Patrons->find( >- $builder->build( >- { >- source => 'Borrower', >- value => { >- firstname => 'Kylie', >- surname => 'Hall', >- } >+my $kylie = $builder->build_object( >+ { >+ class => 'Koha::Patrons', >+ value => { >+ firstname => 'Kylie', >+ surname => 'Hall', > } >- )->{borrowernumber} >+ } > ); > > Koha::Patron::Relationship->new({ guarantor_id => $kyle->id, guarantee_id => $daria->id, relationship => 'father' })->store(); >@@ -152,4 +148,4 @@ is( $sibling->firstname, 'Kylie', 'Sibling from scalar first name matches correc > is( $sibling->surname, 'Hall', 'Sibling from scalar surname matches correctly' ); > is( $sibling->id, $kylie->id, 'Sibling from scalar patron id matches correctly' ); > >-1; >+$schema->storage->txn_rollback; >-- >2.46.0
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 37898
:
171346
|
171347
|
171348
|
171349
|
171353
|
171611
|
171612
| 171613 |
171614
|
171615