Bugzilla – Attachment 70756 Details for
Bug 20047
Add Z3950Server Object and use it for getting server count
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20047 - Add Koha::Z3950Server Oject and use it to get server count
Bug-20047---Add-KohaZ3950Server-Oject-and-use-it-t.patch (text/plain), 7.30 KB, created by
Nick Clemens
on 2018-01-19 15:59:14 UTC
(
hide
)
Description:
Bug 20047 - Add Koha::Z3950Server Oject and use it to get server count
Filename:
MIME Type:
Creator:
Nick Clemens
Created:
2018-01-19 15:59:14 UTC
Size:
7.30 KB
patch
obsolete
>From 61d27dfda441e000d96b53f17984c4f201718583 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Fri, 19 Jan 2018 15:57:02 +0000 >Subject: [PATCH] Bug 20047 - Add Koha::Z3950Server Oject and use it to get > server count > >To test: >1 - prove t/db_dependent/Koha/Z3950Servers.t >2 - Load cataloging and authority home pages >3 - Verify you can add form z395 on each page >4 - Delete all z3950 servers >5 - Viery option to add from Z3950 is removed on both pages >--- > Koha/Z3950Server.pm | 44 +++++++++++++++++++++++++++ > Koha/Z3950Servers.pm | 50 ++++++++++++++++++++++++++++++ > authorities/authorities-home.pl | 12 ++------ > cataloguing/addbooks.pl | 12 ++------ > t/db_dependent/Koha/Z3950Servers.t | 62 ++++++++++++++++++++++++++++++++++++++ > 5 files changed, 160 insertions(+), 20 deletions(-) > create mode 100644 Koha/Z3950Server.pm > create mode 100644 Koha/Z3950Servers.pm > create mode 100644 t/db_dependent/Koha/Z3950Servers.t > >diff --git a/Koha/Z3950Server.pm b/Koha/Z3950Server.pm >new file mode 100644 >index 0000000..2aae5ef >--- /dev/null >+++ b/Koha/Z3950Server.pm >@@ -0,0 +1,44 @@ >+package Koha::Z3950Server; >+ >+# 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, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Carp; >+ >+use Koha::Database; >+ >+use base qw(Koha::Object); >+ >+=head1 NAME >+ >+Koha::Z3950Server - Koha Z3950Server Object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'Z3950server'; >+} >+ >+1; >diff --git a/Koha/Z3950Servers.pm b/Koha/Z3950Servers.pm >new file mode 100644 >index 0000000..5efed2b >--- /dev/null >+++ b/Koha/Z3950Servers.pm >@@ -0,0 +1,50 @@ >+package Koha::Z3950Servers; >+ >+# 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, write to the Free Software Foundation, Inc., >+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. >+ >+use Modern::Perl; >+ >+use Carp; >+ >+use Koha::Database; >+ >+use Koha::Z3950Server; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::Z3950Servers - Koha Z3950Server Object set class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'Z3950server'; >+} >+ >+sub object_class { >+ return 'Koha::Z3950Server'; >+} >+ >+1; >diff --git a/authorities/authorities-home.pl b/authorities/authorities-home.pl >index f6d3f85..8a3fc4d 100755 >--- a/authorities/authorities-home.pl >+++ b/authorities/authorities-home.pl >@@ -37,6 +37,7 @@ use Koha::Authority::Types; > use Koha::SearchEngine::Search; > use Koha::SearchEngine::QueryBuilder; > use Koha::Token; >+use Koha::Z3950Servers; > > my $query = new CGI; > my $dbh = C4::Context->dbh; >@@ -214,16 +215,7 @@ if ( $op eq '' ) { > > } > >-my $schema = Koha::Database->new()->schema(); >-my $servers = $schema->resultset('Z3950server')->search( >- { >- recordtype => 'biblio', >- servertype => ['zed', 'sru'], >- }, >- { result_class => 'DBIx::Class::ResultClass::HashRefInflator', >- order_by => ['rank', 'servername'], >- }, >-); >+my $servers = Koha::Z3950Servers->search(); > > $template->param( > servers => $servers, >diff --git a/cataloguing/addbooks.pl b/cataloguing/addbooks.pl >index 653bced..cbfeec1 100755 >--- a/cataloguing/addbooks.pl >+++ b/cataloguing/addbooks.pl >@@ -37,6 +37,7 @@ use C4::Search; > use Koha::BiblioFrameworks; > use Koha::SearchEngine::Search; > use Koha::SearchEngine::QueryBuilder; >+use Koha::Z3950Servers; > > my $input = new CGI; > >@@ -133,16 +134,7 @@ for my $resultsbr (@resultsbr) { > }; > } > >-my $schema = Koha::Database->new()->schema(); >-my $servers = $schema->resultset('Z3950server')->search( >- { >- recordtype => 'biblio', >- servertype => ['zed', 'sru'], >- }, >- { result_class => 'DBIx::Class::ResultClass::HashRefInflator', >- order_by => ['rank', 'servername'], >- }, >-); >+my $servers = Koha::Z3950Servers->search(); > > my $frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] }); > $template->param( >diff --git a/t/db_dependent/Koha/Z3950Servers.t b/t/db_dependent/Koha/Z3950Servers.t >new file mode 100644 >index 0000000..0836e05 >--- /dev/null >+++ b/t/db_dependent/Koha/Z3950Servers.t >@@ -0,0 +1,62 @@ >+#!/usr/bin/perl >+ >+# Copyright 2015 Koha Development team >+# >+# 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 Test::More tests => 4; >+ >+use Koha::Z3950Server; >+use Koha::Z3950Servers; >+use Koha::Database; >+ >+use t::lib::TestBuilder; >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+my $builder = t::lib::TestBuilder->new; >+my $nb_of_z39s = Koha::Z3950Servers->search->count; >+my $new_z39_1 = Koha::Z3950Server->new({ >+ host => 'my_host1.org', >+ port => '32', >+ db => 'db1', >+ servername => 'my_test_1', >+ servertype => 'zed', >+ recordtype => 'biblio', >+})->store; >+my $new_z39_2 = Koha::Z3950Server->new({ >+ host => 'my_host2.org', >+ port => '64', >+ db => 'db2', >+ servername => 'my_test_2', >+ servertype => 'zed', >+ recordtype => 'authority', >+})->store; >+ >+like( $new_z39_1->id, qr|^\d+$|, 'Adding a new z39 server should have set the id'); >+is( Koha::Z3950Servers->search->count, $nb_of_z39s + 2, 'The 2 z39 servers should have been added' ); >+ >+my $retrieved_z39_1 = Koha::Z3950Servers->find( $new_z39_1->id ); >+is( $retrieved_z39_1->servername, $new_z39_1->servername, 'Find a z39 server by id should return the correct z39 server' ); >+ >+$retrieved_z39_1->delete; >+is( Koha::Z3950Servers->search->count, $nb_of_z39s + 1, 'Delete should have deleted the z39 server' ); >+ >+$schema->storage->txn_rollback; >+ >-- >2.1.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 20047
:
70756
|
70829
|
72681
|
74316
|
74317
|
74405
|
74406