From 1fdeddec717f01aa7de0082de4652931fa1fd809 Mon Sep 17 00:00:00 2001 From: Mark Tompsett Date: Fri, 19 Dec 2014 12:28:19 -0500 Subject: [PATCH] Bug 13457 - Followup for CPL and S codes Based on comment #3, this corrects CPL and S issues if they do not exist in the DB. TEST PLAN --------- 0) Backup your DB. 1) Clear CPL and S from your DB. - delete from borrowers where categorycode='S'; - delete from categories where categorycode='S'; - delete from borrowers where branchcode='CPL'; - delete from branch where branchcode='CPL'; 2) prove t/db_dependent/Suggestions.t -- This should fail. 3) Apply patch 4) prove t/db_dependent/Suggestions.t -- This should work. 5) Intentionally add categorycode 'S' and branchcode 'CPL' back into the database. 6) prove t/db_dependent/Suggestions.t -- This should work. 7) run koha qa test tools. 8) Restore your DB :) Signed-off-by: Paola Rossi Signed-off-by: Katrin Fischer --- t/db_dependent/Suggestions.t | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t index f6a001c..a2377f9 100644 --- a/t/db_dependent/Suggestions.t +++ b/t/db_dependent/Suggestions.t @@ -20,6 +20,7 @@ use Modern::Perl; use C4::Context; use C4::Members; use C4::Letters; +use C4::Branch; use C4::Budgets; use Koha::DateUtils qw( dt_from_string ); @@ -33,6 +34,7 @@ BEGIN { } my $dbh = C4::Context->dbh; +my $sql; # Start transaction $dbh->{AutoCommit} = 0; @@ -40,7 +42,7 @@ $dbh->{RaiseError} = 1; # Reset item types to only the default ones $dbh->do(q|DELETE FROM itemtypes;|); -my $sql = " +$sql = " INSERT INTO itemtypes (itemtype, description, rentalcharge, notforloan, imageurl, summary) VALUES ('BK', 'Books',5,0,'bridge/book.gif',''), ('MX', 'Mixed Materials',5,0,'bridge/kit.gif',''), @@ -58,6 +60,25 @@ $dbh->do(q|DELETE FROM letter|); $dbh->do(q|DELETE FROM message_queue|); $dbh->do(q|INSERT INTO letter(module, code, content) VALUES ('suggestions', 'CHECKED', 'my content')|); +# Add CPL if missing. +if (not defined GetBranchDetail('CPL')) { + ModBranch({add => 1, branchcode => 'CPL', branchname => 'Centerville'}); +} + +my $sth = $dbh->prepare("SELECT * FROM categories WHERE categorycode='S';"); +$sth->execute(); +if (!$sth->fetchrow_hashref) { + $sql = "INSERT INTO categories + (categorycode,description,enrolmentperiod,upperagelimit, + dateofbirthrequired,finetype,bulk,enrolmentfee, + overduenoticerequired,issuelimit,reservefee,category_type) + VALUES + ('S','Staff',99,999, + 18,NULL,NULL,'0.000000', + 0,NULL,'0.000000','S');"; + $dbh->do($sql); +} + my $member = { firstname => 'my firstname', surname => 'my surname', -- 1.9.1