From a007178b873cc84171549f7a93c63a391a1740ca Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 20 Jan 2016 13:13:14 +0000 Subject: [PATCH] Bug 15629: Koha::Libraries - Remove ModBranch This subroutine was only used in tests to add/update a library. Signed-off-by: Owen Leonard Signed-off-by: Kyle M Hall Signed-off-by: Brendan Gallagher brendan@bywatersolutions.com --- C4/Branch.pm | 107 ------------------ t/db_dependent/Branch.t | 61 +++------- .../Circulation/CheckIfIssuedToPatron.t | 4 +- .../Circulation/CheckValidBarcode.t | 4 +- t/db_dependent/Circulation/GetIssues.t | 3 +- .../Circulation/MarkIssueReturned.t | 4 +- t/db_dependent/Circulation_Branch.t | 8 +- t/db_dependent/Circulation_Issuingrule.t | 8 +- t/db_dependent/Circulation_OfflineOperation.t | 5 +- t/db_dependent/Circulation_issue.t | 8 +- t/db_dependent/Items.t | 14 +-- t/db_dependent/Members/GetAllIssues.t | 4 +- t/db_dependent/Members/GetOverdues.t | 4 +- t/db_dependent/Members/GetPendingIssues.t | 4 +- t/db_dependent/Members/IssueSlip.t | 4 +- t/db_dependent/RotatingCollections.t | 5 +- t/db_dependent/Suggestions.t | 4 +- t/db_dependent/Template/Plugin/Branches.t | 7 +- t/db_dependent/Utils/Datatables_Members.t | 6 +- .../Utils/Datatables_Virtualshelves.t | 5 +- 20 files changed, 59 insertions(+), 210 deletions(-) diff --git a/C4/Branch.pm b/C4/Branch.pm index 465a0e48fd..b8eb9ca772 100644 --- a/C4/Branch.pm +++ b/C4/Branch.pm @@ -33,7 +33,6 @@ BEGIN { &GetBranch &GetBranches &GetBranchesLoop - &ModBranch &GetBranchInfo &mybranch ); @@ -171,112 +170,6 @@ sub GetBranchName { return ($branchname); } -=head2 ModBranch - -$error = &ModBranch($newvalue); - -This function modifies an existing branch - -C<$newvalue> is a ref to an array which contains all the columns from branches table. - -=cut - -sub ModBranch { - my ($data) = @_; - - my $dbh = C4::Context->dbh; - if ($data->{add}) { - my $query = " - INSERT INTO branches - (branchcode,branchname,branchaddress1, - branchaddress2,branchaddress3,branchzip,branchcity,branchstate, - branchcountry,branchphone,branchfax,branchemail, - branchurl,branchip,branchprinter,branchnotes,opac_info, - branchreplyto, branchreturnpath) - VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) - "; - my $sth = $dbh->prepare($query); - $sth->execute( - $data->{'branchcode'}, $data->{'branchname'}, - $data->{'branchaddress1'}, $data->{'branchaddress2'}, - $data->{'branchaddress3'}, $data->{'branchzip'}, - $data->{'branchcity'}, $data->{'branchstate'}, - $data->{'branchcountry'}, - $data->{'branchphone'}, $data->{'branchfax'}, - $data->{'branchemail'}, $data->{'branchurl'}, - $data->{'branchip'}, $data->{'branchprinter'}, - $data->{'branchnotes'}, $data->{opac_info}, - $data->{'branchreplyto'}, $data->{'branchreturnpath'} - ); - return 1 if $dbh->err; - } else { - my $query = " - UPDATE branches - SET branchname=?,branchaddress1=?, - branchaddress2=?,branchaddress3=?,branchzip=?, - branchcity=?,branchstate=?,branchcountry=?,branchphone=?, - branchfax=?,branchemail=?,branchurl=?,branchip=?, - branchprinter=?,branchnotes=?,opac_info=?, - branchreplyto=?, branchreturnpath=? - WHERE branchcode=? - "; - my $sth = $dbh->prepare($query); - $sth->execute( - $data->{'branchname'}, - $data->{'branchaddress1'}, $data->{'branchaddress2'}, - $data->{'branchaddress3'}, $data->{'branchzip'}, - $data->{'branchcity'}, $data->{'branchstate'}, - $data->{'branchcountry'}, - $data->{'branchphone'}, $data->{'branchfax'}, - $data->{'branchemail'}, $data->{'branchurl'}, - $data->{'branchip'}, $data->{'branchprinter'}, - $data->{'branchnotes'}, $data->{opac_info}, - $data->{'branchreplyto'}, $data->{'branchreturnpath'}, - $data->{'branchcode'}, - ); - } - # sort out the categories.... - my @checkedcats; - my @cats = Koha::LibraryCategories->search; - foreach my $cat (@cats) { - my $code = $cat->categorycode; - if ( $data->{$code} ) { - push( @checkedcats, $code ); - } - } - my $branchcode = uc( $data->{'branchcode'} ); - my $branch = GetBranchInfo($branchcode); - $branch = $branch->[0]; - my $branchcats = $branch->{'categories'}; - my @addcats; - my @removecats; - foreach my $bcat (@$branchcats) { - - unless ( grep { /^$bcat$/ } @checkedcats ) { - push( @removecats, $bcat ); - } - } - foreach my $ccat (@checkedcats) { - unless ( grep { /^$ccat$/ } @$branchcats ) { - push( @addcats, $ccat ); - } - } - foreach my $cat (@addcats) { - my $sth = - $dbh->prepare( -"insert into branchrelations (branchcode, categorycode) values(?, ?)" - ); - $sth->execute( $branchcode, $cat ); - } - foreach my $cat (@removecats) { - my $sth = - $dbh->prepare( - "delete from branchrelations where branchcode=? and categorycode=?" - ); - $sth->execute( $branchcode, $cat ); - } -} - =head2 GetBranch $branch = GetBranch( $query, $branches ); diff --git a/t/db_dependent/Branch.t b/t/db_dependent/Branch.t index 73e7ec731e..c715e9831b 100644 --- a/t/db_dependent/Branch.t +++ b/t/db_dependent/Branch.t @@ -21,9 +21,11 @@ use Modern::Perl; use C4::Context; use Data::Dumper; -use Test::More tests => 19; +use Test::More tests => 17; use C4::Branch; +use Koha::Database; +use Koha::Library; use Koha::Libraries; use Koha::LibraryCategories; @@ -38,17 +40,15 @@ can_ok( GetBranch GetBranches GetBranchesLoop - ModBranch GetBranchInfo mybranch ) ); +my $schema = Koha::Database->new->schema; +$schema->storage->txn_begin; -# Start transaction my $dbh = C4::Context->dbh; -$dbh->{AutoCommit} = 0; -$dbh->{RaiseError} = 1; # clear the slate $dbh->do('DELETE FROM branchcategories'); @@ -60,7 +60,6 @@ like( $count, '/^\d+$/', "the count is a number" ); #add 2 branches my $b1 = { - add => 1, branchcode => 'BRA', branchname => 'BranchA', branchaddress1 => 'adr1A', @@ -104,11 +103,9 @@ my $b2 = { opac_info => 'opacB', issuing => undef, }; -ModBranch($b1); -is( ModBranch($b2), undef, 'the field add is missing' ); +Koha::Library->new($b1)->store; +Koha::Library->new($b2)->store; -$b2->{add} = 1; -ModBranch($b2); is( Koha::Libraries->search->count, $count + 2, "two branches added" ); is( Koha::Libraries->find( $b2->{branchcode} )->delete, 1, "One row affected" ); @@ -123,7 +120,7 @@ my $branches = GetBranches(); is( scalar( keys %$branches ), Koha::Libraries->search->count, "GetBranches returns the right number of branches" ); -#Test ModBranch +#Test modify a library $b1 = { branchcode => 'BRA', @@ -148,7 +145,7 @@ $b1 = { issuing => undef, }; -ModBranch($b1); +Koha::Libraries->find($b1->{branchcode})->set($b1)->store; is( Koha::Libraries->search->count, $count + 1, "A branch has been modified, no new branch added" ); @@ -190,8 +187,9 @@ is( $del, 1, 'One row affected' ); is( Koha::LibraryCategories->search->count, $count_cat + 2, "Category CAT 2 deleted" ); -$b2->{CAT1} = 1; -ModBranch($b2); +my $b2_stored = Koha::Library->new($b2)->store; +my $CAT1 = Koha::LibraryCategories->find('CAT1'); +$b2_stored->add_to_categories([$CAT1]); is( Koha::Libraries->search->count, $count + 2, 'BRB added' ); #Test GetBranchInfo @@ -209,37 +207,6 @@ is_deeply( @$b2info[0], $b2, 'BRB has the category CAT1' ); Koha::LibraryCategory->new($cat2)->store; is( Koha::LibraryCategories->search->count, $count_cat + 3, "Two categories added" ); -$b2 = { - branchcode => 'BRB', - branchname => 'BranchB', - branchaddress1 => 'adr1B', - branchaddress2 => 'adr2B', - branchaddress3 => 'adr3B', - branchzip => 'zipB', - branchcity => 'cityB', - branchstate => 'stateB', - branchcountry => 'countryB', - branchphone => 'phoneB', - branchfax => 'faxB', - branchemail => 'emailB', - branchreplyto => 'emailreply', - branchreturnpath => 'branchreturn', - branchurl => 'urlB', - branchip => 'ipB', - branchprinter => undef, - branchnotes => 'noteB', - opac_info => 'opacB', - issuing => undef, - CAT1 => 1, - CAT2 => 1 -}; -ModBranch($b2); -$b2info = GetBranchInfo( $b2->{branchcode} ); -push( @cat, $cat2->{categorycode} ); -delete $b2->{CAT1}; -delete $b2->{CAT2}; -$b2->{categories} = \@cat; -is_deeply( @$b2info[0], $b2, 'BRB has the category CAT1 and CAT2' ); #TODO later: test mybranchine and onlymine # Actually we cannot mock C4::Context->userenv in unit tests @@ -248,6 +215,4 @@ is_deeply( @$b2info[0], $b2, 'BRB has the category CAT1 and CAT2' ); my $loop = GetBranchesLoop; is( scalar(@$loop), Koha::Libraries->search->count, 'There is the right number of branches' ); -# End transaction -$dbh->rollback; - +$schema->storage->txn_rollback; diff --git a/t/db_dependent/Circulation/CheckIfIssuedToPatron.t b/t/db_dependent/Circulation/CheckIfIssuedToPatron.t index 10e10b6b6e..440f36e94b 100644 --- a/t/db_dependent/Circulation/CheckIfIssuedToPatron.t +++ b/t/db_dependent/Circulation/CheckIfIssuedToPatron.t @@ -23,8 +23,8 @@ use Test::MockModule; use C4::Biblio; use C4::Items; use C4::Members; -use C4::Branch; use C4::Category; +use Koha::Library; use MARC::Record; BEGIN { @@ -46,7 +46,7 @@ $dbh->do(q|DELETE FROM categories|); my $branchcode = 'B'; -ModBranch({ add => 1, branchcode => $branchcode, branchname => 'Branch' }); +Koha::Library->new( {branchcode => $branchcode, branchname => 'Branch' } )->store; my $categorycode = 'C'; $dbh->do("INSERT INTO categories(categorycode) VALUES(?)", undef, $categorycode); diff --git a/t/db_dependent/Circulation/CheckValidBarcode.t b/t/db_dependent/Circulation/CheckValidBarcode.t index 2e43270be9..39cad00514 100644 --- a/t/db_dependent/Circulation/CheckValidBarcode.t +++ b/t/db_dependent/Circulation/CheckValidBarcode.t @@ -22,7 +22,7 @@ use Test::More tests => 10; use C4::Circulation; use C4::Biblio; use C4::Items; -use C4::Branch; +use Koha::Library; BEGIN { @@ -42,7 +42,7 @@ $dbh->do(q|DELETE FROM categories|); my $branchcode = 'B'; -ModBranch({ add => 1, branchcode => $branchcode, branchname => 'Branch' }); +Koha::Library->new({ branchcode => $branchcode, branchname => 'Branch' })->store; my $categorycode = 'C'; $dbh->do("INSERT INTO categories(categorycode) VALUES(?)", undef, $categorycode); diff --git a/t/db_dependent/Circulation/GetIssues.t b/t/db_dependent/Circulation/GetIssues.t index ddd5186722..b215f3342a 100644 --- a/t/db_dependent/Circulation/GetIssues.t +++ b/t/db_dependent/Circulation/GetIssues.t @@ -10,6 +10,7 @@ use C4::Members; use C4::Branch; use C4::Category; use C4::Circulation; +use Koha::Library; use MARC::Record; my $dbh = C4::Context->dbh; @@ -25,7 +26,7 @@ if (@branches) { $branchcode = $branches[0]; } else { $branchcode = 'B'; - ModBranch({ add => 1, branchcode => $branchcode, branchname => 'Branch' }); + Koha::Library->new({ branchcode => $branchcode, branchname => 'Branch' })->store; $branch_created = 1; } diff --git a/t/db_dependent/Circulation/MarkIssueReturned.t b/t/db_dependent/Circulation/MarkIssueReturned.t index 1409fc7232..4c6f52c0cd 100644 --- a/t/db_dependent/Circulation/MarkIssueReturned.t +++ b/t/db_dependent/Circulation/MarkIssueReturned.t @@ -20,9 +20,9 @@ use Modern::Perl; use Test::More tests => 2; use Test::Warn; -use C4::Branch; use C4::Circulation; use C4::Members; +use Koha::Library; use t::lib::Mocks; my $dbh = C4::Context->dbh; @@ -32,7 +32,7 @@ $dbh->{RaiseError} = 1; t::lib::Mocks::mock_preference('AnonymousPatron', ''); my $branchcode = 'B'; -ModBranch({ add => 1, branchcode => $branchcode, branchname => 'Branch' }); +Koha::Library->new({ branchcode => $branchcode, branchname => 'Branch' })->store; my $categorycode = 'C'; $dbh->do("INSERT INTO categories(categorycode) VALUES(?)", undef, $categorycode); diff --git a/t/db_dependent/Circulation_Branch.t b/t/db_dependent/Circulation_Branch.t index 19ebf95388..ae7eadfec8 100644 --- a/t/db_dependent/Circulation_Branch.t +++ b/t/db_dependent/Circulation_Branch.t @@ -3,10 +3,10 @@ use Modern::Perl; use C4::Biblio; use C4::Members; -use C4::Branch; use C4::Circulation; use C4::Items; use C4::Context; +use Koha::Library; use Test::More tests => 14; @@ -43,7 +43,6 @@ $dbh->do(q|DELETE FROM default_branch_item_rules|); #Add branch and category my $samplebranch1 = { - add => 1, branchcode => 'SAB1', branchname => 'Sample Branch', branchaddress1 => 'sample adr1', @@ -62,7 +61,6 @@ my $samplebranch1 = { opac_info => 'sample opac', }; my $samplebranch2 = { - add => 1, branchcode => 'SAB2', branchname => 'Sample Branch2', branchaddress1 => 'sample adr1_2', @@ -80,8 +78,8 @@ my $samplebranch2 = { branchprinter => undef, opac_info => 'sample opac2', }; -ModBranch($samplebranch1); -ModBranch($samplebranch2); +Koha::Library->new($samplebranch1)->store; +Koha::Library->new($samplebranch2)->store; my $samplecat = { categorycode => 'CAT1', diff --git a/t/db_dependent/Circulation_Issuingrule.t b/t/db_dependent/Circulation_Issuingrule.t index 2e8f47ac0c..977cb8bb95 100644 --- a/t/db_dependent/Circulation_Issuingrule.t +++ b/t/db_dependent/Circulation_Issuingrule.t @@ -2,9 +2,9 @@ use Modern::Perl; use C4::Context; -use C4::Branch; use DateTime; use Koha::DateUtils; +use Koha::Library; use Test::More tests => 9; @@ -36,7 +36,6 @@ $dbh->do(q|DELETE FROM issuingrules|); #Add branch and category my $samplebranch1 = { - add => 1, branchcode => 'SAB1', branchname => 'Sample Branch', branchaddress1 => 'sample adr1', @@ -55,7 +54,6 @@ my $samplebranch1 = { opac_info => 'sample opac', }; my $samplebranch2 = { - add => 1, branchcode => 'SAB2', branchname => 'Sample Branch2', branchaddress1 => 'sample adr1_2', @@ -73,8 +71,8 @@ my $samplebranch2 = { branchprinter => undef, opac_info => 'sample opac2', }; -ModBranch($samplebranch1); -ModBranch($samplebranch2); +Koha::Library->new($samplebranch1)->store; +Koha::Library->new($samplebranch2)->store; my $samplecat = { categorycode => 'CAT1', diff --git a/t/db_dependent/Circulation_OfflineOperation.t b/t/db_dependent/Circulation_OfflineOperation.t index 2f5edf8235..387ae6427f 100644 --- a/t/db_dependent/Circulation_OfflineOperation.t +++ b/t/db_dependent/Circulation_OfflineOperation.t @@ -1,8 +1,8 @@ #!/usr/bin/perl use Modern::Perl; -use C4::Branch; use C4::Circulation; +use Koha::Library; use Test::More tests => 7; @@ -32,7 +32,6 @@ $dbh->do(q|DELETE FROM pending_offline_operations|); #Add branch my $samplebranch1 = { - add => 1, branchcode => 'SAB1', branchname => 'Sample Branch', branchaddress1 => 'sample adr1', @@ -50,7 +49,7 @@ my $samplebranch1 = { branchprinter => undef, opac_info => 'sample opac', }; -ModBranch($samplebranch1); +Koha::Library->new($samplebranch1)->store; #Begin Tests #Test AddOfflineOperation diff --git a/t/db_dependent/Circulation_issue.t b/t/db_dependent/Circulation_issue.t index 511c3be327..9b1a9c8f9c 100644 --- a/t/db_dependent/Circulation_issue.t +++ b/t/db_dependent/Circulation_issue.t @@ -21,11 +21,11 @@ use Koha::DateUtils; use DateTime::Duration; use C4::Biblio; use C4::Members; -use C4::Branch; use C4::Circulation; use C4::Items; use C4::Context; use C4::Reserves; +use Koha::Library; use Test::More tests => 32; @@ -76,7 +76,6 @@ my $daysago10 = output_pref({ dt => $dt_today2, dateformat => 'iso', timeformat #Add branch and category my $samplebranch1 = { - add => 1, branchcode => 'CPL', branchname => 'Sample Branch', branchaddress1 => 'sample adr1', @@ -95,7 +94,6 @@ my $samplebranch1 = { opac_info => 'sample opac', }; my $samplebranch2 = { - add => 1, branchcode => 'MPL', branchname => 'Sample Branch2', branchaddress1 => 'sample adr1_2', @@ -113,8 +111,8 @@ my $samplebranch2 = { branchprinter => undef, opac_info => 'sample opac2', }; -ModBranch($samplebranch1); -ModBranch($samplebranch2); +Koha::Library->new($samplebranch1)->store; +Koha::Library->new($samplebranch2)->store; my $samplecat = { categorycode => 'CAT1', diff --git a/t/db_dependent/Items.t b/t/db_dependent/Items.t index e3a1e02d8c..a8f9ac24bf 100755 --- a/t/db_dependent/Items.t +++ b/t/db_dependent/Items.t @@ -20,8 +20,8 @@ use Modern::Perl; use MARC::Record; use C4::Biblio; -use C4::Branch; use Koha::Database; +use Koha::Library; use t::lib::Mocks; use t::lib::TestBuilder; @@ -202,13 +202,13 @@ subtest 'GetItemsInfo tests' => sub { holdingbranch => $library2->{branchcode}, }, $biblionumber ); - my $library = Koha::Libraries->find( $library1->{branchcode} )->unblessed; - $library->{ opac_info }= "homebranch OPAC info"; - ModBranch($library); + my $library = Koha::Libraries->find( $library1->{branchcode} ); + $library->opac_info("homebranch OPAC info"); + $library->store; - $library = Koha::Libraries->find( $library2->{branchcode} )->unblessed; - $library->{ opac_info } = "holdingbranch OPAC info"; - ModBranch($library); + $library = Koha::Libraries->find( $library2->{branchcode} ); + $library->opac_info("holdingbranch OPAC info"); + $library->store; my @results = GetItemsInfo( $biblionumber ); ok( @results, 'GetItemsInfo returns results'); diff --git a/t/db_dependent/Members/GetAllIssues.t b/t/db_dependent/Members/GetAllIssues.t index 5027b07fa6..62eae89bcb 100644 --- a/t/db_dependent/Members/GetAllIssues.t +++ b/t/db_dependent/Members/GetAllIssues.t @@ -8,9 +8,9 @@ use Test::MockModule; use C4::Biblio; use C4::Items; use C4::Members; -use C4::Branch; use C4::Category; use C4::Circulation; +use Koha::Libraries; use MARC::Record; my $dbh = C4::Context->dbh; @@ -25,7 +25,7 @@ $dbh->do(q|DELETE FROM biblio|); $dbh->do(q|DELETE FROM categories|); my $branchcode = 'B'; -ModBranch( { add => 1, branchcode => $branchcode, branchname => 'Branch' } ); +Koha::Library->new( { branchcode => $branchcode, branchname => 'Branch' } )->store; my $categorycode = 'C'; $dbh->do( "INSERT INTO categories(categorycode) VALUES(?)", diff --git a/t/db_dependent/Members/GetOverdues.t b/t/db_dependent/Members/GetOverdues.t index f8a5c6beee..da4088079f 100644 --- a/t/db_dependent/Members/GetOverdues.t +++ b/t/db_dependent/Members/GetOverdues.t @@ -8,9 +8,9 @@ use Test::MockModule; use C4::Biblio; use C4::Items; use C4::Members; -use C4::Branch; use C4::Category; use C4::Circulation; +use Koha::Libraries; use MARC::Record; my $dbh = C4::Context->dbh; @@ -25,7 +25,7 @@ $dbh->do(q|DELETE FROM biblio|); $dbh->do(q|DELETE FROM categories|); my $branchcode = 'B'; -ModBranch( { add => 1, branchcode => $branchcode, branchname => 'Branch' } ); +Koha::Library->new( { branchcode => $branchcode, branchname => 'Branch' } )->store; my $categorycode = 'C'; $dbh->do( "INSERT INTO categories(categorycode) VALUES(?)", diff --git a/t/db_dependent/Members/GetPendingIssues.t b/t/db_dependent/Members/GetPendingIssues.t index 1c1c683bcb..cd51bcbc89 100644 --- a/t/db_dependent/Members/GetPendingIssues.t +++ b/t/db_dependent/Members/GetPendingIssues.t @@ -8,9 +8,9 @@ use Test::MockModule; use C4::Biblio; use C4::Items; use C4::Members; -use C4::Branch; use C4::Category; use C4::Circulation; +use Koha::Library; use MARC::Record; my $dbh = C4::Context->dbh; @@ -25,7 +25,7 @@ $dbh->do(q|DELETE FROM biblio|); $dbh->do(q|DELETE FROM categories|); my $branchcode = 'B'; -ModBranch( { add => 1, branchcode => $branchcode, branchname => 'Branch' } ); +Koha::Library->new( { branchcode => $branchcode, branchname => 'Branch' } )->store; my $categorycode = 'C'; $dbh->do( "INSERT INTO categories(categorycode) VALUES(?)", diff --git a/t/db_dependent/Members/IssueSlip.t b/t/db_dependent/Members/IssueSlip.t index 8c32c21e02..84ad1158b3 100644 --- a/t/db_dependent/Members/IssueSlip.t +++ b/t/db_dependent/Members/IssueSlip.t @@ -8,11 +8,11 @@ use Test::MockModule; use C4::Biblio; use C4::Items; use C4::Members; -use C4::Branch; use C4::Category; use C4::Circulation; use Koha::DateUtils qw( dt_from_string output_pref ); +use Koha::Library; use DateTime::Duration; use MARC::Record; @@ -30,7 +30,7 @@ $dbh->do(q|DELETE FROM categories|); $dbh->do(q|DELETE FROM letter|); my $branchcode = 'B'; -ModBranch( { add => 1, branchcode => $branchcode, branchname => 'Branch' } ); +Koha::Library->new( { branchcode => $branchcode, branchname => 'Branch' } )->store; my $categorycode = 'C'; $dbh->do( "INSERT INTO categories(categorycode) VALUES(?)", diff --git a/t/db_dependent/RotatingCollections.t b/t/db_dependent/RotatingCollections.t index 125dddc491..fe47bb853d 100644 --- a/t/db_dependent/RotatingCollections.t +++ b/t/db_dependent/RotatingCollections.t @@ -19,8 +19,8 @@ use Modern::Perl; use Test::More tests => 52; use C4::Context; -use C4::Branch; use C4::Biblio; +use Koha::Library; BEGIN { use_ok('C4::RotatingCollections'); @@ -173,7 +173,6 @@ is_deeply( #Test TransferCollection my $samplebranch = { - add => 1, branchcode => 'SAB', branchname => 'Sample Branch', branchaddress1 => 'sample adr1', @@ -192,7 +191,7 @@ my $samplebranch = { branchnotes => 'sample note', opac_info => 'sample opac', }; -ModBranch($samplebranch); +Koha::Library->new($samplebranch)->store; is( TransferCollection( $collection_id1, $samplebranch->{branchcode} ), 1, "Collection1 has been transfered in the branch SAB" ); @collection1 = GetCollection($collection_id1); diff --git a/t/db_dependent/Suggestions.t b/t/db_dependent/Suggestions.t index ddd7f00187..62481d1252 100644 --- a/t/db_dependent/Suggestions.t +++ b/t/db_dependent/Suggestions.t @@ -20,10 +20,10 @@ use Modern::Perl; use C4::Context; use C4::Members; use C4::Letters; -use C4::Branch; use C4::Budgets qw( AddBudgetPeriod AddBudget ); use Koha::DateUtils qw( dt_from_string ); +use Koha::Library; use Koha::Libraries; use DateTime::Duration; @@ -64,7 +64,7 @@ $dbh->do(q|INSERT INTO letter(module, code, content) VALUES ('suggestions', 'CHE # Add CPL if missing. if (not defined Koha::Libraries->find('CPL')) { - ModBranch({add => 1, branchcode => 'CPL', branchname => 'Centerville'}); + Koha::Library->new({ branchcode => 'CPL', branchname => 'Centerville' })->store; } my $sth = $dbh->prepare("SELECT * FROM categories WHERE categorycode='S';"); diff --git a/t/db_dependent/Template/Plugin/Branches.t b/t/db_dependent/Template/Plugin/Branches.t index 5b77d594d6..fb276f3ae5 100644 --- a/t/db_dependent/Template/Plugin/Branches.t +++ b/t/db_dependent/Template/Plugin/Branches.t @@ -3,7 +3,7 @@ use Modern::Perl; use Test::More tests => 5; use C4::Context; -use C4::Branch; +use Koha::Library; use Koha::Template::Plugin::Branches; my $dbh = C4::Context->dbh; @@ -11,13 +11,12 @@ $dbh->{AutoCommit} = 0; $dbh->{RaiseError} = 1; for my $i ( 1 .. 5 ) { - C4::Branch::ModBranch( + Koha::Library->new( { branchcode => "test_br_$i", branchname => "test_br_$i", - add => 1, } - ); + )->store; } diff --git a/t/db_dependent/Utils/Datatables_Members.t b/t/db_dependent/Utils/Datatables_Members.t index 855d129fa0..eb9af5aacf 100644 --- a/t/db_dependent/Utils/Datatables_Members.t +++ b/t/db_dependent/Utils/Datatables_Members.t @@ -20,12 +20,13 @@ use Modern::Perl; use Test::More tests => 19; use C4::Context; -use C4::Branch; use C4::Members; use C4::Members::Attributes; use C4::Members::AttributeTypes; +use Koha::Library; + use t::lib::Mocks; use_ok( "C4::Utils::DataTables::Members" ); @@ -42,7 +43,6 @@ my $categorycode = $categories[0]->categorycode; # Add a new branch so we control what borrowers it has my $branchcode = "UNC"; my $branch_data = { - add => 1, branchcode => $branchcode, branchname => 'Universidad Nacional de Cordoba', branchaddress1 => 'Haya de la Torre', @@ -52,7 +52,7 @@ my $branch_data = { branchstate => 'Cordoba', branchcountry => 'Argentina' }; -ModBranch( $branch_data ); +Koha::Library->new( $branch_data )->store; my %john_doe = ( cardnumber => '123456', diff --git a/t/db_dependent/Utils/Datatables_Virtualshelves.t b/t/db_dependent/Utils/Datatables_Virtualshelves.t index 0a8f0ab362..cb5ff55db3 100644 --- a/t/db_dependent/Utils/Datatables_Virtualshelves.t +++ b/t/db_dependent/Utils/Datatables_Virtualshelves.t @@ -21,9 +21,9 @@ use Test::More tests => 13; use C4::Biblio; use C4::Context; -use C4::Branch; use C4::Members; +use Koha::Library; use Koha::Virtualshelf; use Koha::Virtualshelves; @@ -42,11 +42,10 @@ my @categories = C4::Category->all; my $categorycode = $categories[0]->categorycode; my $branchcode = "ABC"; my $branch_data = { - add => 1, branchcode => $branchcode, branchname => 'my branchname', }; -ModBranch( $branch_data ); +Koha::Library->new( $branch_data )->store; my %john_doe = ( cardnumber => '123456', -- 2.39.5