Bugzilla – Attachment 35047 Details for
Bug 13540
Item's permanent_location is set to CART|PROC if an Item is edited when it's location is CART|PROC.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 13540 - Item's permanent_location is set to CART|PROC when... - Unit tests
Bug-13540---Items-permanentlocation-is-set-to-CART.patch (text/plain), 6.27 KB, created by
Olli-Antti Kivilahti
on 2015-01-09 12:42:22 UTC
(
hide
)
Description:
Bug 13540 - Item's permanent_location is set to CART|PROC when... - Unit tests
Filename:
MIME Type:
Creator:
Olli-Antti Kivilahti
Created:
2015-01-09 12:42:22 UTC
Size:
6.27 KB
patch
obsolete
>From 0c7d27c4497d1fe5350a16e04614302693041bf6 Mon Sep 17 00:00:00 2001 >From: Olli-Antti Kivilahti <olli-antti.kivilahti@jns.fi> >Date: Fri, 9 Jan 2015 14:41:26 +0200 >Subject: [PATCH] Bug 13540 - Item's permanent_location is set to CART|PROC > when... - Unit tests > >--- > t/db_dependent/Circulation.t | 94 +++++++++++++++++++++++++++++++++++++++++- > 1 file changed, 93 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Circulation.t b/t/db_dependent/Circulation.t >index 58dbc2b..44d7580 100755 >--- a/t/db_dependent/Circulation.t >+++ b/t/db_dependent/Circulation.t >@@ -16,6 +16,7 @@ > # along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >+use utf8; > > use DateTime; > use C4::Biblio; >@@ -26,7 +27,7 @@ use C4::Reserves; > use Koha::DateUtils; > use Koha::Database; > >-use Test::More tests => 59; >+use Test::More tests => 66; > > BEGIN { > use_ok('C4::Circulation'); >@@ -539,6 +540,97 @@ C4::Context->dbh->do("DELETE FROM accountlines"); > > } > >+##Preparing test Objects for the testReturnToShelvingCart() because none are available in this context. >+##The test can be easily moved to another context. >+#Create another record >+my $biblio = MARC::Record->new(); >+$biblio->append_fields( >+ MARC::Field->new('100', ' ', ' ', a => 'The Anonymous'), >+ MARC::Field->new('245', ' ', ' ', a => 'Something is worng here') >+); >+my ($biblionumber, $biblioitemnumber, $itemnumber) = C4::Biblio::AddBiblio($biblio, ''); >+$biblio = C4::Biblio::GetBiblio($biblionumber); >+#Create any circulable item >+($biblionumber, $biblioitemnumber, $itemnumber) = C4::Items::AddItem( >+ { >+ homebranch => 'CPL', >+ holdingbranch => 'CPL', >+ barcode => 'SauliNiinistö', >+ }, >+ $biblionumber >+); >+$item = C4::Items::GetItem($itemnumber); >+# Create a borrower >+my $borrowernumber = C4::Members::AddMember( >+ firstname => 'Fridolyn', >+ surname => 'SOMERS', >+ categorycode => 'S', >+ branchcode => 'CPL', >+); >+$borrower = C4::Members::GetMember(borrowernumber => $borrowernumber); >+testReturnToShelvingCart($borrower, $item); >+ > $dbh->rollback; > > 1; >+ >+=head testReturnToShelvingCart >+ >+ testReturnToShelvingCart($borrower, $item); >+ >+ Runs 7 tests for the ReturnToShelvingCart-feature. >+ >+@PARAM1, borrower-hash from koha.borrowers-table, can be any Borrower who can check-out/in >+@PARAM2, item-hash from koha-items-table, can be any Item which can be circulated >+ >+=cut >+sub testReturnToShelvingCart { >+ my $borrower = shift; #Any borrower who can check-in-out will do. >+ my $item = shift; #Any Item that can be circulated will do. >+ my $originalIssues = C4::Circulation::GetIssues({borrowernumber => $borrower->{borrowernumber}}); >+ my $originalReturnToShelvingCart = C4::Context->preference('ReturnToShelvingCart'); #Store the original preference so we can rollback changes >+ C4::Context->set_preference('ReturnToShelvingCart', 1) unless $originalReturnToShelvingCart; #Make sure it is 'Move' >+ >+ #TEST1: Make sure the Item has an intelligible location and permanent_location >+ my $location = 'BOOK'; >+ my $anotherLocation = 'SHELF'; >+ C4::Items::ModItem({location => $location}, $item->{biblionumber}, $item->{itemnumber}); >+ $item = C4::Items::GetItem($item->{itemnumber}); #Update the DB changes. >+ ok($item->{permanent_location} eq $location, "ReturnToShelvingCart: Setting a proper location succeeded."); >+ >+ #TEST2: It makes no difference in which state the Item is, when it is returned, the location changes to 'CART' >+ C4::Circulation::AddReturn($item->{barcode}, $borrower->{branchcode}); >+ $item = C4::Items::GetItem($item->{itemnumber}); #Update the DB changes. >+ ok($item->{permanent_location} eq $location && $item->{location} eq 'CART', "ReturnToShelvingCart: Item returned, location and permanent_location OK!"); >+ >+ #TEST3: Editing the Item didn't screw up the permanent_location >+ C4::Items::ModItem({price => 12}, $item->{biblionumber}, $item->{itemnumber}); >+ $item = C4::Items::GetItem($item->{itemnumber}); #Update the DB changes. >+ ok($item->{permanent_location} eq $location && $item->{location} eq 'CART', "ReturnToShelvingCart: Minor modifying an Item doesn't overwrite permanent_location!"); >+ >+ #TEST4: Checking an Item out to test another possible state. >+ C4::Items::ModItem({location => $location}, $item->{biblionumber}, $item->{itemnumber}); #Reset the original location, as if the cart_to_Shelf.pl-script has been ran. >+ C4::Circulation::AddIssue($borrower, $item->{barcode}); >+ my $issues = C4::Circulation::GetIssues({borrowernumber => $borrower->{borrowernumber}}); >+ ok( scalar(@$originalIssues)+1 == scalar(@$issues) ,"ReturnToShelvingCart: Adding an Issue succeeded!" ); >+ >+ #TEST5: >+ C4::Circulation::AddReturn($item->{barcode}, $borrower->{branchcode}); >+ $item = C4::Items::GetItem($item->{itemnumber}); #Update the DB changes. >+ ok($item->{permanent_location} eq $location && $item->{location} eq 'CART', "ReturnToShelvingCart: Item returned again, location and permanent_location OK!"); >+ >+ #TEST6: Editing the Item without a permanent_location >+ # (like when Editing the item using the staff clients editing view @ additem.pl?biblionumber=469263) >+ # didn't screw up the permanent_location >+ delete $item->{permanent_location}; >+ C4::Items::ModItem($item, $item->{biblionumber}, $item->{itemnumber}); >+ $item = C4::Items::GetItem($item->{itemnumber}); #Update the DB changes. >+ ok($item->{permanent_location} eq $location && $item->{location} eq 'CART', "ReturnToShelvingCart: Modifying the whole Item doesn't overwrite permanent_location!"); >+ >+ #TEST7: Modifying only the permanent_location is an interesting option! So our Item is in 'CART', but we want to keep it there (hypothetically) and change the real location! >+ C4::Items::ModItem({permanent_location => $anotherLocation}, $item->{biblionumber}, $item->{itemnumber}); >+ $item = C4::Items::GetItem($item->{itemnumber}); #Update the DB changes. >+ ok($item->{permanent_location} eq $anotherLocation && $item->{location} eq 'CART', "ReturnToShelvingCart: Modifying the permanent_location while the location is 'CART'."); >+ >+ C4::Context->set_preference('ReturnToShelvingCart', $originalReturnToShelvingCart) unless $originalReturnToShelvingCart; #Set it to the original value >+} >\ No newline at end of file >-- >1.7.9.5
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 13540
:
35038
|
35047
|
35055
|
35336
|
35337
|
35951
|
35952
|
35953
|
40183
|
40214
|
40878