Bugzilla – Attachment 47001 Details for
Bug 15629
Move the C4::Branch related code to Koha::Libraries - part 3
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15629: Koha::Libraries - Remove ModBranch
Bug-15629-KohaLibraries---Remove-ModBranch.patch (text/plain), 25.73 KB, created by
Jonathan Druart
on 2016-01-20 14:36:49 UTC
(
hide
)
Description:
Bug 15629: Koha::Libraries - Remove ModBranch
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-01-20 14:36:49 UTC
Size:
25.73 KB
patch
obsolete
>From 5de8a534f236c74c47f6f890eb385d8ab687f0aa Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >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. >--- > C4/Branch.pm | 107 --------------------- > t/db_dependent/Branch.t | 61 +++--------- > t/db_dependent/Circulation/CheckIfIssuedToPatron.t | 4 +- > t/db_dependent/Circulation/CheckValidBarcode.t | 4 +- > t/db_dependent/Circulation/GetIssues.t | 3 +- > t/db_dependent/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 +- > t/db_dependent/Utils/Datatables_Virtualshelves.t | 5 +- > 20 files changed, 59 insertions(+), 210 deletions(-) > >diff --git a/C4/Branch.pm b/C4/Branch.pm >index 465a0e4..b8eb9ca 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 73e7ec7..c715e98 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 10e10b6..440f36e 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 2e43270..39cad00 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 ddd5186..b215f33 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 1409fc7..4c6f52c 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 19ebf95..ae7eadf 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 2e8f47a..977cb8b 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 2f5edf8..387ae64 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 511c3be..9b1a9c8 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 e3a1e02..a8f9ac2 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 5027b07..62eae89 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 f8a5c6b..da40880 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 1c1c683..cd51bcb 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 8c32c21..84ad115 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 125dddc..fe47bb8 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 ddd7f00..62481d1 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 5b77d59..fb276f3 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 855d129..eb9af5a 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 0a8f0ab..cb5ff55 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.1.0
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 15629
:
46997
|
46998
|
46999
|
47000
|
47001
|
47002
|
47518
|
47519
|
47520
|
47521
|
47522
|
47523
|
47553
|
47701
|
47706
|
47707
|
47708
|
47709
|
47710
|
47711
|
47712
|
47713