Bugzilla – Attachment 19221 Details for
Bug 10499
UT: VirtualShelves.t needs a database transaction
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 10499: VirtualShelves.t - wrap tests in a database connection
Bug-10499-VirtualShelvest---wrap-tests-in-a-databa.patch (text/plain), 3.84 KB, created by
Chris Cormack
on 2013-06-25 08:05:53 UTC
(
hide
)
Description:
Bug 10499: VirtualShelves.t - wrap tests in a database connection
Filename:
MIME Type:
Creator:
Chris Cormack
Created:
2013-06-25 08:05:53 UTC
Size:
3.84 KB
patch
obsolete
>From a2113a6e2735a2d46018860f11f937bb857c0306 Mon Sep 17 00:00:00 2001 >From: Kenza Zaki <kenza.zaki@biblibre.com> >Date: Thu, 20 Jun 2013 15:06:44 +0200 >Subject: [PATCH] Bug 10499: VirtualShelves.t - wrap tests in a database > connection > >Before this patch, the queries in VirtualShelves.t were committed in the >database and have to be removed at the end. >This patch wraps tests in a database connection. > >Test plan: >prove t/db_dependent/VirtualShelves.t >VirtualShelves.t .. ok >All tests successful. >Files=1, Tests=72, 1 wallclock secs ( 0.06 usr 0.00 sys + 0.72 cusr 0.06 csys = 0.84 CPU) >Result: PASS > >Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> >--- > t/db_dependent/VirtualShelves.t | 36 +++++++++++++----------------------- > 1 file changed, 13 insertions(+), 23 deletions(-) > >diff --git a/t/db_dependent/VirtualShelves.t b/t/db_dependent/VirtualShelves.t >index 323cc2c..3313517 100755 >--- a/t/db_dependent/VirtualShelves.t >+++ b/t/db_dependent/VirtualShelves.t >@@ -6,14 +6,18 @@ > # > > use Modern::Perl; >-use Test::More tests => 82; >+use Test::More tests => 72; > use MARC::Record; > > use C4::Biblio qw( AddBiblio DelBiblio ); > use C4::Context; > >-# Getting some borrowers from database. >+# Start transaction > my $dbh = C4::Context->dbh; >+$dbh->{RaiseError} = 1; >+$dbh->{AutoCommit} = 0; >+ >+# Getting some borrowers from database. > my $query = q{ > SELECT borrowernumber > FROM borrowers >@@ -34,7 +38,6 @@ foreach(0..9) { > push @biblionumbers, $biblionumber; > } > >-# FIXME Why are you deleting my shelves? See bug 10386. > my $delete_virtualshelf = q{ > DELETE FROM virtualshelves WHERE 1 > }; >@@ -42,10 +45,8 @@ my $delete_virtualshelfcontent = q{ > DELETE FROM virtualshelfcontents WHERE 1 > }; > >-$sth = $dbh->prepare($delete_virtualshelf); >-$sth->execute; >-$sth = $dbh->prepare($delete_virtualshelfcontent); >-$sth->execute; >+$dbh->do($delete_virtualshelf); >+$dbh->do($delete_virtualshelfcontent); > # --- > > #----------------------------------------------------------------------# >@@ -61,7 +62,7 @@ use_ok('C4::VirtualShelves'); > > # creating 10 good shelves. > my @shelves; >-for(my $i=0; $i<10;$i++){ >+for my $i(0..9){ > my $ShelfNumber = AddShelf( > {shelfname=>"Shelf_".$i, category=>int(rand(2))+1 }, $borrowers[$i] ); > die "test Not ok, remove some shelves before" if ($ShelfNumber == -1); >@@ -72,7 +73,7 @@ for(my $i=0; $i<10;$i++){ > ok(10 == scalar @shelves, 'created 10 lists'); # 10 shelves in @shelves; > > # try to create some shelf which already exists. >-for(my $i=0;$i<10;$i++){ >+for my $i(0..9){ > my @shlf=GetShelf($shelves[$i]); > > # FIXME This test still needs some attention >@@ -95,7 +96,7 @@ for(my $i=0;$i<10;$i++){ > # usage : $biblist = GetShelfContents($shelfnumber); > > my %used = (); >-for(my $i=0; $i<10;$i++){ >+for my $i(0..9){ > my $bib = $biblionumbers[int(rand(9))]; > my $shelfnumber = $shelves[int(rand(9))]; > >@@ -125,8 +126,7 @@ for(my $i=0; $i<10;$i++){ > #-----------------------TEST ModShelf & GetShelf functions------------------------# > # usage : ModShelf($shelfnumber, $shelfname, $owner, $category ) > # usage : (shelfnumber,shelfname,owner,category) = GetShelf($shelfnumber); >- >-for(my $i=0; $i<10;$i++){ >+for my $i(0..9){ > my $rand = int(rand(9)); > my $numA = $shelves[$rand]; > my $shelf = { shelfname => "NewName_".$rand, >@@ -140,14 +140,4 @@ for(my $i=0; $i<10;$i++){ > ok($shelf->{category} eq $categoryB, '... and category change took'); > } > >-#-----------------------TEST DelShelf & DelFromShelf functions------------------------# >-# usage : ($status) = &DelShelf($shelfnumber); >- >-for(my $i=0; $i<10;$i++){ >- my $shelfnumber = $shelves[$i]; >- my $status = DelShelf($shelfnumber); >- ok(1 == $status, "deleted shelf $shelfnumber and its contents"); >-} >- >-#----------------------- CLEANUP ----------------------------------------------# >-DelBiblio($_) for @biblionumbers; >+$dbh->rollback; >-- >1.7.10.4
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 10499
:
19171
|
19221
|
19308
|
19343
|
19619