Bugzilla – Attachment 89560 Details for
Bug 20384
Elasticsearch rebuild script improvements - options for indexing
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20384: unit test for get_all_biblios_iterator & get_all_authorities_iterator
Bug-20384-unit-test-for-getallbibliositerator--get.patch (text/plain), 6.54 KB, created by
axel Amghar
on 2019-05-10 15:15:50 UTC
(
hide
)
Description:
Bug 20384: unit test for get_all_biblios_iterator & get_all_authorities_iterator
Filename:
MIME Type:
Creator:
axel Amghar
Created:
2019-05-10 15:15:50 UTC
Size:
6.54 KB
patch
obsolete
>From 35ca702372136283a401defe3def538c7196c75b Mon Sep 17 00:00:00 2001 >From: Axel Amghar <axel.amghar@biblibre.com> >Date: Tue, 7 May 2019 15:36:09 +0200 >Subject: [PATCH] Bug 20384: unit test for get_all_biblios_iterator & > get_all_authorities_iterator > >--- > .../Koha/BiblioUtils/get_all_biblios_iterator.t | 82 ++++++++++++++++ > t/db_dependent/Koha/MetadataRecord/Authority.t | 106 +++++++++++++++++++++ > 2 files changed, 188 insertions(+) > create mode 100644 t/db_dependent/Koha/BiblioUtils/get_all_biblios_iterator.t > create mode 100644 t/db_dependent/Koha/MetadataRecord/Authority.t > >diff --git a/t/db_dependent/Koha/BiblioUtils/get_all_biblios_iterator.t b/t/db_dependent/Koha/BiblioUtils/get_all_biblios_iterator.t >new file mode 100644 >index 0000000..7051204 >--- /dev/null >+++ b/t/db_dependent/Koha/BiblioUtils/get_all_biblios_iterator.t >@@ -0,0 +1,82 @@ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+use Koha::BiblioUtils; >+use Koha::SearchEngine::Elasticsearch; >+use t::lib::TestBuilder; >+use C4::Biblio; >+use C4::AuthoritiesMarc; >+ >+use Test::More tests => 4; >+ >+my $schema = Koha::Database->new()->schema(); >+$schema->storage->txn_begin(); >+ >+my $dbh = C4::Context->dbh; >+ >+$dbh->do("DELETE FROM reserves"); >+$dbh->do("DELETE FROM issues"); >+$dbh->do("DELETE FROM biblio"); >+$dbh->do("DELETE FROM biblioitems"); >+ >+my $offset = 1; >+my $length = 2; >+ >+#test without items in biblioitems >+ >+my $records = Koha::BiblioUtils->get_all_biblios_iterator($offset, $length); >+ >+is(ref($records),'Koha::MetadataIterator',"the package name isn't Koha::MetadataIterator"); >+ >+my $count = 0; >+ >+while ($records->next()) { >+ $count++; >+} >+ >+is($count,0,"There is not the right number of notices"); >+ >+my $builder = t::lib::TestBuilder->new(); >+ >+# Add three biblio records >+ >+my $biblio1 = MARC::Record->new; >+$biblio1->append_fields( MARC::Field->new( '200', '0', '0', 'a' => 'Titre1' )); >+my $biblionumber1 = AddBiblio($biblio1, ''); >+ >+my $biblio2 = MARC::Record->new; >+$biblio2->append_fields( MARC::Field->new( '201', '0', '0', 'a' => 'Titre2' )); >+my $biblionumber2 = AddBiblio($biblio2, ''); >+ >+my $biblio3 = MARC::Record->new; >+$biblio3->append_fields( MARC::Field->new( '202', '0', '0', 'a' => 'Titre2' )); >+my $biblionumber3 = AddBiblio($biblio3, ''); >+ >+#test with items in biblioitems >+ >+$records = Koha::BiblioUtils->get_all_biblios_iterator($offset, $length); >+ >+is(ref($records),'Koha::MetadataIterator',"the package name is Koha::MetadataIterator"); >+ >+$count = 0; >+ >+while ($records->next()) { >+ $count++; >+} >+ >+is($count,2,"There is the right number of notices"); >+ >+$schema->storage->txn_rollback; >\ No newline at end of file >diff --git a/t/db_dependent/Koha/MetadataRecord/Authority.t b/t/db_dependent/Koha/MetadataRecord/Authority.t >new file mode 100644 >index 0000000..3eb59d9 >--- /dev/null >+++ b/t/db_dependent/Koha/MetadataRecord/Authority.t >@@ -0,0 +1,106 @@ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+use Koha::MetadataIterator; >+use Koha::MetadataRecord::Authority; >+use Koha::SearchEngine::Elasticsearch; >+use t::lib::TestBuilder; >+use C4::Biblio; >+use C4::AuthoritiesMarc; >+ >+use Test::More tests => 1; >+ >+my $schema = Koha::Database->new()->schema(); >+$schema->storage->txn_begin(); >+ >+subtest 'Test Koha::MetadataRecord::Authority' => sub { >+ plan tests => 4; >+ >+ my $dbh = C4::Context->dbh; >+ >+ $dbh->do("DELETE FROM auth_header"); >+ >+ my $offset = 1; >+ my $length = 2; >+ >+ #test without items in auth_header >+ >+ my $records = Koha::MetadataRecord::Authority->get_all_authorities_iterator($offset, $length); >+ >+ is(ref($records),'Koha::MetadataIterator',"the package name isn't Koha::MetadataIterator"); >+ >+ my $count = 0; >+ >+ while ($records->next()) { >+ $count++; >+ } >+ >+ is($count,0,"There is not the right number of notices"); >+ >+ my $builder = t::lib::TestBuilder->new(); >+ >+ # create three auth types >+ >+ my $authtype1 = $builder->build({ >+ source => 'AuthType', >+ value => { >+ auth_tag_to_report => '1', >+ }, >+ }); >+ my $authtype2 = $builder->build({ >+ source => 'AuthType', >+ value => { >+ auth_tag_to_report => '2', >+ }, >+ }); >+ my $authtype3 = $builder->build({ >+ source => 'AuthType', >+ value => { >+ auth_tag_to_report => '3', >+ }, >+ }); >+ >+ # Add three authority records >+ >+ my $auth1 = MARC::Record->new; >+ $auth1->append_fields( MARC::Field->new( '109', '0', '0', 'a' => 'Auth1' )); >+ my $authid1 = AddAuthority( $auth1, undef, $authtype1->{'authtypecode'} ); >+ >+ my $auth2 = MARC::Record->new; >+ $auth2->append_fields( MARC::Field->new( '110', '0', '0', 'a' => 'Auth2' )); >+ my $authid2 = AddAuthority( $auth2, undef, $authtype2->{'authtypecode'} ); >+ >+ my $auth3 = MARC::Record->new; >+ $auth3->append_fields( MARC::Field->new( '111', '0', '0', 'a' => 'Auth3' )); >+ my $authid3 = AddAuthority( $auth3, undef, $authtype3->{'authtypecode'} ); >+ >+ #test with items in auth_header >+ >+ $records = Koha::MetadataRecord::Authority->get_all_authorities_iterator($offset, $length); >+ >+ is(ref($records),'Koha::MetadataIterator',"the package name is Koha::MetadataIterator"); >+ >+ $count = 0; >+ >+ while ($records->next()) { >+ $count++; >+ } >+ >+ is($count,2,"There is the right number of notices"); >+ >+}; >+ >+$schema->storage->txn_rollback; >\ No newline at end of file >-- >2.7.4
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 20384
:
89425
|
89559
|
89560
|
89727
|
89886
|
89887
|
89888
|
106587
|
106588