Bugzilla – Attachment 58462 Details for
Bug 17742
Test t/db_dependent/Patrons.t can fail randomly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17742: Fix t/db_dependent/Patrons.t
Bug-17742-Fix-tdbdependentPatronst.patch (text/plain), 3.40 KB, created by
Jonathan Druart
on 2016-12-28 08:58:13 UTC
(
hide
)
Description:
Bug 17742: Fix t/db_dependent/Patrons.t
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-12-28 08:58:13 UTC
Size:
3.40 KB
patch
obsolete
>From 41a1f03e1b321e02222b405670afdb24ea106f5b Mon Sep 17 00:00:00 2001 >From: Josef Moravec <josef.moravec@gmail.com> >Date: Tue, 6 Dec 2016 21:07:56 +0000 >Subject: [PATCH] Bug 17742: Fix t/db_dependent/Patrons.t > >Moves the getting of testing date for updated_on just after the storing >the test patron data to make the gap between generating data and now >date as short as possible > >Fixes test 7 > >Use Koha::Database instead of C4::Context->dbh > >Test plan >1. prove t/db_dependent/Patrons.t >2. read the diff > >NOTE: Only minor improvement could be using test builder to > generate the category and branch codes, rather than assume > data exists. However, that is beyond scope of this bug. > >Signed-off-by: Mark Tompsett <mtompset@hotmail.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> >--- > t/db_dependent/Patrons.t | 29 +++++++++++++++-------------- > 1 file changed, 15 insertions(+), 14 deletions(-) > >diff --git a/t/db_dependent/Patrons.t b/t/db_dependent/Patrons.t >index 24707df..b0b6b60 100755 >--- a/t/db_dependent/Patrons.t >+++ b/t/db_dependent/Patrons.t >@@ -30,17 +30,15 @@ BEGIN { > } > > # Start transaction >-my $dbh = C4::Context->dbh; >-$dbh->{AutoCommit} = 0; >-$dbh->{RaiseError} = 1; >-$dbh->do("DELETE FROM issues"); >-$dbh->do("DELETE FROM borrowers"); >- >-my $categorycode = >- Koha::Database->new()->schema()->resultset('Category')->first() >- ->categorycode(); >-my $branchcode = >- Koha::Database->new()->schema()->resultset('Branch')->first()->branchcode(); >+my $database = Koha::Database->new(); >+my $schema = $database->schema(); >+$schema->storage->txn_begin(); >+ >+$schema->resultset('Issue')->delete_all(); >+$schema->resultset('Borrower')->delete_all(); >+ >+my $categorycode = $schema->resultset('Category')->first()->categorycode(); >+my $branchcode = $schema->resultset('Branch')->first()->branchcode(); > > my $b1 = Koha::Patron->new( > { >@@ -50,6 +48,7 @@ my $b1 = Koha::Patron->new( > } > ); > $b1->store(); >+my $now = dt_from_string; > my $b2 = Koha::Patron->new( > { > surname => 'Test 2', >@@ -72,13 +71,13 @@ $b3->store(); > my $b1_new = Koha::Patrons->find( $b1->borrowernumber() ); > is( $b1->surname(), $b1_new->surname(), "Found matching patron" ); > isnt( $b1_new->updated_on, undef, "borrowers.updated_on should be set" ); >-is( dt_from_string($b1_new->updated_on), dt_from_string, "borrowers.updated_on should have been set to now on creating" ); >+is( dt_from_string($b1_new->updated_on), $now, "borrowers.updated_on should have been set to now on creating" ); > > my $b3_new = Koha::Patrons->find( $b3->borrowernumber() ); > is( dt_from_string($b3_new->updated_on), $three_days_ago, "borrowers.updated_on should have been kept to what we set on creating" ); >-$b3_new->set({ surname => 'another surname for Test 3' }); >+$b3_new->set({ firstname => 'Some first name for Test 3' })->store(); > $b3_new = Koha::Patrons->find( $b3->borrowernumber() ); >-is( dt_from_string($b1_new->updated_on), dt_from_string, "borrowers.updated_on should have been set to now on updating" ); >+is( dt_from_string($b3_new->updated_on), dt_from_string, "borrowers.updated_on should have been set to now on updating" ); > > my @patrons = Koha::Patrons->search( { branchcode => $branchcode } ); > is( @patrons, 3, "Found 3 patrons with Search" ); >@@ -104,4 +103,6 @@ foreach my $b ( $patrons->as_list() ) { > is( $b->categorycode(), $categorycode, "Iteration returns a patron object" ); > } > >+$schema->storage->txn_rollback(); >+ > 1; >-- >2.9.3
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 17742
:
58033
|
58085
|
58148
|
58150
|
58460
| 58462 |
58463