Bugzilla – Attachment 70337 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.85 KB, created by
Nick Clemens (kidclamp)
on 2018-01-09 11:46:55 UTC
(
hide
)
Description:
Bug 19929 - Add Koha objects for class sources and sorters
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2018-01-09 11:46:55 UTC
Size:
10.85 KB
patch
obsolete
>From e54b5e5610a936f8dd7867f6bf657416ec4f2c6c 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/ClassificationSorters.t >prove -v t/db_dependent/Koha/ClassificationSources.t >--- > Koha/ClassificationSort.pm | 44 +++++++++++++++++++++ > Koha/ClassificationSorters.pm | 50 +++++++++++++++++++++++ > Koha/ClassificationSource.pm | 44 +++++++++++++++++++++ > Koha/ClassificationSources.pm | 50 +++++++++++++++++++++++ > t/db_dependent/Koha/ClassificationSorters.t | 57 +++++++++++++++++++++++++++ > t/db_dependent/Koha/ClassificationSources.t | 61 +++++++++++++++++++++++++++++ > 6 files changed, 306 insertions(+) > create mode 100644 Koha/ClassificationSort.pm > create mode 100644 Koha/ClassificationSorters.pm > create mode 100644 Koha/ClassificationSource.pm > create mode 100644 Koha/ClassificationSources.pm > create mode 100644 t/db_dependent/Koha/ClassificationSorters.t > create mode 100644 t/db_dependent/Koha/ClassificationSources.t > >diff --git a/Koha/ClassificationSort.pm b/Koha/ClassificationSort.pm >new file mode 100644 >index 0000000..eac3d4e >--- /dev/null >+++ b/Koha/ClassificationSort.pm >@@ -0,0 +1,44 @@ >+package Koha::ClassificationSort; >+ >+# 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::ClassificationSort - Koha Classfication Sorting Rule Object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'ClassSortRule'; >+} >+ >+1; >diff --git a/Koha/ClassificationSorters.pm b/Koha/ClassificationSorters.pm >new file mode 100644 >index 0000000..7eacac5 >--- /dev/null >+++ b/Koha/ClassificationSorters.pm >@@ -0,0 +1,50 @@ >+package Koha::ClassificationSorters; >+ >+# 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::ClassificationSorters; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::ClassificationSorters - 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::ClassificationSort'; >+} >+ >+1; >diff --git a/Koha/ClassificationSource.pm b/Koha/ClassificationSource.pm >new file mode 100644 >index 0000000..6b7d9eb >--- /dev/null >+++ b/Koha/ClassificationSource.pm >@@ -0,0 +1,44 @@ >+package Koha::ClassificationSource; >+ >+# 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::ClassificationSource - Koha Classfication Source Object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'ClassSource'; >+} >+ >+1; >diff --git a/Koha/ClassificationSources.pm b/Koha/ClassificationSources.pm >new file mode 100644 >index 0000000..a9dc843 >--- /dev/null >+++ b/Koha/ClassificationSources.pm >@@ -0,0 +1,50 @@ >+package Koha::ClassificationSources; >+ >+# 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::ClassificationSource; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::ClassificationSources - Koha Classification Source Object set class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'ClassSource'; >+} >+ >+sub object_class { >+ return 'Koha::ClassificationSource'; >+} >+ >+1; >diff --git a/t/db_dependent/Koha/ClassificationSorters.t b/t/db_dependent/Koha/ClassificationSorters.t >new file mode 100644 >index 0000000..c0e3fe4 >--- /dev/null >+++ b/t/db_dependent/Koha/ClassificationSorters.t >@@ -0,0 +1,57 @@ >+#!/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::ClassificationSorters; >+use Koha::ClassificationSort; >+ >+use t::lib::TestBuilder; >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+my $builder = t::lib::TestBuilder->new; >+my $nb_of_class_sorters = Koha::ClassificationSorters->search->count; >+my $new_cs_1 = Koha::ClassificationSort->new({ >+ class_sort_rule => 'sort_rule1', >+ description => 'a_sort_test_1', >+ sort_routine => 'lcc', >+})->store; >+my $new_cs_2 = Koha::ClassificationSort->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::ClassificationSorters->search->count, $nb_of_class_sorters + 2, 'The 2 classification sorters should have been added' ); >+ >+my $retrieved_cs_1 = Koha::ClassificationSorters->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::ClassificationSorters->search->count, $nb_of_class_sorters + 1, 'Delete should have deleted the sort' ); >+ >+$schema->storage->txn_rollback; >+ >diff --git a/t/db_dependent/Koha/ClassificationSources.t b/t/db_dependent/Koha/ClassificationSources.t >new file mode 100644 >index 0000000..edf644e >--- /dev/null >+++ b/t/db_dependent/Koha/ClassificationSources.t >@@ -0,0 +1,61 @@ >+#!/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::ClassificationSources; >+use Koha::ClassificationSource; >+ >+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::ClassificationSources->search->count; >+my $new_cs_1 = Koha::ClassificationSource->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::ClassificationSource->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::ClassificationSources->search->count, $nb_of_class_sources + 2, 'The 2 classifcations should have been added' ); >+ >+my $retrieved_cs_1 = Koha::ClassificationSources->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::ClassificationSources->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