Bugzilla – Attachment 72959 Details for
Bug 19929
Add Koha Objects for class_source and class_sort_rules
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19929 - Add Koha objects for class sources and sorters
Bug-19929---Add-Koha-objects-for-class-sources-and.patch (text/plain), 10.45 KB, created by
Mark Tompsett
on 2018-03-15 13:58:35 UTC
(
hide
)
Description:
Bug 19929 - Add Koha objects for class sources and sorters
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2018-03-15 13:58:35 UTC
Size:
10.45 KB
patch
obsolete
>From e7a606a87af7e5a8e869d453dc042c1df7dd5d0c Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Tue, 9 Jan 2018 11:45:47 +0000 >Subject: [PATCH] Bug 19929 - Add Koha objects for class sources and sorters > >prove -v t/db_dependent/Koha/ClassSortRules.t >prove -v t/db_dependent/Koha/ClassSources.t > >Signed-off-by: Mark Tompsett <mtompset@hotmail.com> >--- > Koha/ClassSortRule.pm | 44 +++++++++++++++++++++++++++ > Koha/ClassSortRules.pm | 50 ++++++++++++++++++++++++++++++ > Koha/ClassSource.pm | 44 +++++++++++++++++++++++++++ > Koha/ClassSources.pm | 50 ++++++++++++++++++++++++++++++ > t/db_dependent/Koha/ClassSortRules.t | 55 +++++++++++++++++++++++++++++++++ > t/db_dependent/Koha/ClassSources.t | 59 ++++++++++++++++++++++++++++++++++++ > 6 files changed, 302 insertions(+) > create mode 100644 Koha/ClassSortRule.pm > create mode 100644 Koha/ClassSortRules.pm > create mode 100644 Koha/ClassSource.pm > create mode 100644 Koha/ClassSources.pm > create mode 100644 t/db_dependent/Koha/ClassSortRules.t > create mode 100644 t/db_dependent/Koha/ClassSources.t > >diff --git a/Koha/ClassSortRule.pm b/Koha/ClassSortRule.pm >new file mode 100644 >index 0000000..9e856b2 >--- /dev/null >+++ b/Koha/ClassSortRule.pm >@@ -0,0 +1,44 @@ >+package Koha::ClassSortRule; >+ >+# 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::ClassSortRule Koha Classfication Sorting Rule Object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'ClassSortRule'; >+} >+ >+1; >diff --git a/Koha/ClassSortRules.pm b/Koha/ClassSortRules.pm >new file mode 100644 >index 0000000..197b91d >--- /dev/null >+++ b/Koha/ClassSortRules.pm >@@ -0,0 +1,50 @@ >+package Koha::ClassSortRules; >+ >+# 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::ClassSortRule; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::ClassSortRules - Koha Classification Sort Rules Object set class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'ClassSortRule'; >+} >+ >+sub object_class { >+ return 'Koha::ClassSortRule'; >+} >+ >+1; >diff --git a/Koha/ClassSource.pm b/Koha/ClassSource.pm >new file mode 100644 >index 0000000..373c1e0 >--- /dev/null >+++ b/Koha/ClassSource.pm >@@ -0,0 +1,44 @@ >+package Koha::ClassSource; >+ >+# 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::ClassSource - Koha Classfication Source Object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'ClassSource'; >+} >+ >+1; >diff --git a/Koha/ClassSources.pm b/Koha/ClassSources.pm >new file mode 100644 >index 0000000..f15abd7 >--- /dev/null >+++ b/Koha/ClassSources.pm >@@ -0,0 +1,50 @@ >+package Koha::ClassSources; >+ >+# 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::ClassSource; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::ClassSources - Koha Classification Source Object set class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'ClassSource'; >+} >+ >+sub object_class { >+ return 'Koha::ClassSource'; >+} >+ >+1; >diff --git a/t/db_dependent/Koha/ClassSortRules.t b/t/db_dependent/Koha/ClassSortRules.t >new file mode 100644 >index 0000000..e83d93b >--- /dev/null >+++ b/t/db_dependent/Koha/ClassSortRules.t >@@ -0,0 +1,55 @@ >+#!/usr/bin/perl >+ >+# Copyright 2017 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::Database; >+ >+use Koha::ClassSortRules; >+ >+use t::lib::TestBuilder; >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+my $builder = t::lib::TestBuilder->new; >+my $nb_of_class_sort_rules = Koha::ClassSortRules->search->count; >+my $new_cs_1 = Koha::ClassSortRule->new({ >+ class_sort_rule => 'sort_rule1', >+ description => 'a_sort_test_1', >+ sort_routine => 'lcc', >+})->store; >+my $new_cs_2 = Koha::ClassSortRule->new({ >+ class_sort_rule => 'sort_rule2', >+ description => 'a_sort_test_2', >+ sort_routine => 'dewey', >+})->store; >+ >+is( $new_cs_1->class_sort_rule, 'sort_rule1', 'Adding a new classification sort should have set the class_sort_rule'); >+is( Koha::ClassSortRules->search->count, $nb_of_class_sort_rules + 2, 'The 2 classification sorters should have been added' ); >+ >+my $retrieved_cs_1 = Koha::ClassSortRules->find( $new_cs_1->class_sort_rule ); >+is( $retrieved_cs_1->description, $new_cs_1->description, 'Find a sorter by class_sort_rule should return the correct source' ); >+ >+$retrieved_cs_1->delete; >+is( Koha::ClassSortRules->search->count, $nb_of_class_sort_rules + 1, 'Delete should have deleted the sort' ); >+ >+$schema->storage->txn_rollback; >diff --git a/t/db_dependent/Koha/ClassSources.t b/t/db_dependent/Koha/ClassSources.t >new file mode 100644 >index 0000000..f188e0f >--- /dev/null >+++ b/t/db_dependent/Koha/ClassSources.t >@@ -0,0 +1,59 @@ >+#!/usr/bin/perl >+ >+# Copyright 2017 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::Database; >+ >+use Koha::ClassSources; >+ >+use t::lib::TestBuilder; >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+my $builder = t::lib::TestBuilder->new; >+my $class_sort_1 = $builder->build({ source=>'ClassSortRule' }); >+my $class_sort_2 = $builder->build({ source=>'ClassSortRule' }); >+my $nb_of_class_sources = Koha::ClassSources->search->count; >+my $new_cs_1 = Koha::ClassSource->new({ >+ cn_source => 'source_1', >+ description => 'a_test_1', >+ used => '1', >+ class_sort_rule => $class_sort_1->{class_sort_rule},#'sort_rule_1', >+})->store; >+my $new_cs_2 = Koha::ClassSource->new({ >+ cn_source => 'source_2', >+ description => 'a_test_2', >+ used => '0', >+ class_sort_rule => $class_sort_2->{class_sort_rule},#'sort_rule_1', >+})->store; >+ >+is( $new_cs_1->cn_source, 'source_1', 'Adding a new classification should have set the cn_source'); >+is( Koha::ClassSources->search->count, $nb_of_class_sources + 2, 'The 2 classifcations should have been added' ); >+ >+my $retrieved_cs_1 = Koha::ClassSources->find( $new_cs_1->cn_source ); >+is( $retrieved_cs_1->description, $new_cs_1->description, 'Find a source by cn_source should return the correct source' ); >+ >+$retrieved_cs_1->delete; >+is( Koha::ClassSources->search->count, $nb_of_class_sources + 1, 'Delete should have deleted the classification' ); >+ >+$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 19929
:
70337
|
72948
|
72949
|
72959
|
72965
|
72966