Bugzilla – Attachment 113552 Details for
Bug 26984
Tests are failing if AnonymousPatron is configured
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26984: Make other tests pass if AnonymousPatron is set
Bug-26984-Make-other-tests-pass-if-AnonymousPatron.patch (text/plain), 6.97 KB, created by
Kyle M Hall
on 2020-11-12 12:49:03 UTC
(
hide
)
Description:
Bug 26984: Make other tests pass if AnonymousPatron is set
Filename:
MIME Type:
Creator:
Kyle M Hall
Created:
2020-11-12 12:49:03 UTC
Size:
6.97 KB
patch
obsolete
>From f56a775fe08ca56f5e779f058ea1d23ec60f1e2b Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 12 Nov 2020 13:11:13 +0100 >Subject: [PATCH] Bug 26984: Make other tests pass if AnonymousPatron is set > >There is only 1 place where it can be tricky to not remove them as we >want exactly 10 patrons to be present in the DB > >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > t/db_dependent/Accounts.t | 26 ++++----------------- > t/db_dependent/Koha/Biblio.t | 20 +++++++--------- > t/db_dependent/Koha/Objects.t | 1 + > t/db_dependent/Template/Plugin/Categories.t | 14 ++++------- > 4 files changed, 18 insertions(+), 43 deletions(-) > >diff --git a/t/db_dependent/Accounts.t b/t/db_dependent/Accounts.t >index da4d4c3f95..489ae7de36 100755 >--- a/t/db_dependent/Accounts.t >+++ b/t/db_dependent/Accounts.t >@@ -55,10 +55,6 @@ my $dbh = C4::Context->dbh; > my $builder = t::lib::TestBuilder->new; > my $library = $builder->build( { source => 'Branch' } ); > >-$dbh->do(q|DELETE FROM accountlines|); >-$dbh->do(q|DELETE FROM issues|); >-$dbh->do(q|DELETE FROM borrowers|); >- > my $branchcode = $library->{branchcode}; > > my $context = Test::MockModule->new('C4::Context'); >@@ -1104,23 +1100,9 @@ subtest "Payment notice tests" => sub { > > plan tests => 8; > >- Koha::Account::Lines->delete(); >- Koha::Patrons->delete(); > Koha::Notice::Messages->delete(); >- # Create a borrower >- my $categorycode = $builder->build({ source => 'Category' })->{ categorycode }; >- my $branchcode = $builder->build({ source => 'Branch' })->{ branchcode }; >- >- my $borrower = Koha::Patron->new( >- { >- cardnumber => 'chelseahall', >- surname => 'Hall', >- firstname => 'Chelsea', >- email => 'chelsea@example.com', >- categorycode => $categorycode, >- branchcode => $branchcode, >- } >- )->store(); >+ # Create a patron >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); > > my $manager = $builder->build_object({ class => "Koha::Patrons" }); > my $context = Test::MockModule->new('C4::Context'); >@@ -1130,11 +1112,11 @@ subtest "Payment notice tests" => sub { > branch => $manager->branchcode, > }; > }); >- my $account = Koha::Account->new({ patron_id => $borrower->id }); >+ my $account = Koha::Account->new({ patron_id => $patron->borrowernumber }); > > my $line = Koha::Account::Line->new( > { >- borrowernumber => $borrower->borrowernumber, >+ borrowernumber => $patron->borrowernumber, > amountoutstanding => 27, > interface => 'commandline', > debit_type_code => 'LOST' >diff --git a/t/db_dependent/Koha/Biblio.t b/t/db_dependent/Koha/Biblio.t >index cf359edf32..4283460699 100755 >--- a/t/db_dependent/Koha/Biblio.t >+++ b/t/db_dependent/Koha/Biblio.t >@@ -185,19 +185,12 @@ subtest 'is_serial() tests' => sub { > }; > > subtest 'pickup_locations' => sub { >- plan tests => 29; >+ plan tests => 8; > > $schema->storage->txn_begin; > >- my $dbh = C4::Context->dbh; >- >- # Cleanup database >- Koha::Holds->search->delete; >- Koha::Patrons->search->delete; >- Koha::Items->search->delete; >- Koha::Libraries->search->delete; >+ my $nb_libraries = Koha::Libraries->count; > Koha::CirculationRules->search->delete; >- $dbh->do('DELETE FROM issues'); > Koha::CirculationRules->set_rules( > { > categorycode => undef, >@@ -222,6 +215,8 @@ subtest 'pickup_locations' => sub { > my $library7 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 1 } } ); > my $library8 = $builder->build_object( { class => 'Koha::Libraries', value => { pickup_location => 0 } } ); > >+ our @branchcodes = map { $_->branchcode } ($library1, $library2, $library3, $library4, $library5, $library6, $library7, $library8); >+ > Koha::CirculationRules->set_rules( > { > branchcode => $library1->branchcode, >@@ -373,11 +368,11 @@ subtest 'pickup_locations' => sub { > my $patron8 = $builder->build_object( { class => 'Koha::Patrons', value => { firstname=>'8', branchcode => $library8->branchcode } } ); > > my $results = { >- "ItemHomeLibrary-1-1" => 6, >+ "ItemHomeLibrary-1-1" => 6 + $nb_libraries, > "ItemHomeLibrary-1-8" => 1, > "ItemHomeLibrary-2-1" => 2, > "ItemHomeLibrary-2-8" => 0, >- "PatronLibrary-1-1" => 6, >+ "PatronLibrary-1-1" => 6 + $nb_libraries, > "PatronLibrary-1-8" => 3, > "PatronLibrary-2-1" => 0, > "PatronLibrary-2-8" => 3, >@@ -390,6 +385,9 @@ subtest 'pickup_locations' => sub { > my @pl = @{ $biblio->pickup_locations( { patron => $patron} ) }; > > foreach my $pickup_location (@pl) { >+ next >+ unless grep { $pickup_location eq $_ } @branchcodes; >+ > is( ref($pickup_location), 'Koha::Library', 'Object type is correct' ); > } > >diff --git a/t/db_dependent/Koha/Objects.t b/t/db_dependent/Koha/Objects.t >index 76e0393485..6865168b2c 100755 >--- a/t/db_dependent/Koha/Objects.t >+++ b/t/db_dependent/Koha/Objects.t >@@ -263,6 +263,7 @@ subtest '->is_paged and ->pager tests' => sub { > $schema->storage->txn_begin; > > # Delete existing patrons >+ t::lib::Mocks::mock_preference('AnonymousPatron', ''); > Koha::Checkouts->delete; > Koha::Patrons->delete; > # Create 10 patrons >diff --git a/t/db_dependent/Template/Plugin/Categories.t b/t/db_dependent/Template/Plugin/Categories.t >index b6080c7519..0d99a85465 100755 >--- a/t/db_dependent/Template/Plugin/Categories.t >+++ b/t/db_dependent/Template/Plugin/Categories.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 5; >+use Test::More tests => 4; > use t::lib::Mocks; > use t::lib::TestBuilder; > >@@ -30,24 +30,18 @@ use Koha::Template::Plugin::Categories; > my $schema = Koha::Database->new->schema; > $schema->storage->txn_begin; > >-# Delete all categories >-Koha::Checkouts->search->delete; >-Koha::Patrons->search->delete; >-Koha::Patron::Categories->search->delete; >- > my $builder = t::lib::TestBuilder->new; > >-is( Koha::Template::Plugin::Categories->new->all->count, >- 0, '->all returns 0 results if no categories defined' ); >+my $nb_categories = Koha::Patron::Categories->count; > > # Create sample categories > my $category_1 = $builder->build( { source => 'Category' } ); > my @categories = Koha::Template::Plugin::Categories->new->all; >-is( scalar(@categories), 1, '->all returns all defined categories' ); >+is( scalar(@categories), 1 + $nb_categories, '->all returns all defined categories' ); > > my $category_2 = $builder->build( { source => 'Category' } ); > @categories = Koha::Template::Plugin::Categories->new->all; >-is( scalar(@categories), 2, '->all returns all defined categories' ); >+is( scalar(@categories), 2 + $nb_categories, '->all returns all defined categories' ); > > is( Koha::Template::Plugin::Categories->GetName( > $category_1->{categorycode} >-- >2.24.1 (Apple Git-126)
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 26984
:
113547
|
113550
|
113551
|
113552
|
113662
|
113704
|
113817
|
113818