@@ -, +, @@ Koha::Authority::Type[s] --- Koha/Authorities.pm | 56 +++++++++++++++++++++++++++++++++++++++ Koha/Authority.pm | 46 ++++++++++++++++++++++++++++++++ Koha/Authority/Type.pm | 49 ++++++++++++++++++++++++++++++++++ Koha/Authority/Types.pm | 50 ++++++++++++++++++++++++++++++++++ t/db_dependent/Koha/Authorities.t | 55 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 256 insertions(+) create mode 100644 Koha/Authorities.pm create mode 100644 Koha/Authority.pm create mode 100644 Koha/Authority/Type.pm create mode 100644 Koha/Authority/Types.pm create mode 100644 t/db_dependent/Koha/Authorities.t --- a/Koha/Authorities.pm +++ a/Koha/Authorities.pm @@ -0,0 +1,56 @@ +package Koha::Authorities; + +# 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, 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::Authority; + +use base qw(Koha::Objects); + +=head1 NAME + +Koha::Authorities - Koha Authority object set class + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub type { + return 'AuthHeader'; +} + +=head3 object_class + +=cut + +sub object_class { + return 'Koha::Authority'; +} + +1; --- a/Koha/Authority.pm +++ a/Koha/Authority.pm @@ -0,0 +1,46 @@ +package Koha::Authority; + +# 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, 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::Authority - Koha Authority Object class + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub type { + return 'AuthHeader'; +} + +1; --- a/Koha/Authority/Type.pm +++ a/Koha/Authority/Type.pm @@ -0,0 +1,49 @@ +package Koha::Authority::Type; + +# 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::Authority::Type - Koha Authority Type Object class + +=head1 API + +=head2 Class Methods + +=cut + +sub auth_tag_structures { + my ( $self ) = @_; + return $self->_result->auth_tag_structures; +} + +=head3 type + +=cut + +sub type { + return 'AuthType'; +} + +1; --- a/Koha/Authority/Types.pm +++ a/Koha/Authority/Types.pm @@ -0,0 +1,50 @@ +package Koha::Authority::Types; + +# 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::Authority::Type; + +use base qw(Koha::Objects); + +=head1 NAME + +Koha::Authority::Types - Koha Authority Type Object set class + +=head1 API + +=head2 Class Methods + +=cut + +=head3 type + +=cut + +sub type { + return 'AuthType'; +} + +sub object_class { + return 'Koha::Authority::Type'; +} + +1; --- a/t/db_dependent/Koha/Authorities.t +++ a/t/db_dependent/Koha/Authorities.t @@ -0,0 +1,55 @@ +#!/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 . + +use Modern::Perl; + +use Test::More tests => 3; + +use Koha::Authority; +use Koha::Authorities; +use Koha::Authority::Type; +use Koha::Authority::Types; +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_authorities = Koha::Authorities->search->count; +my $nb_of_authority_types = Koha::Authority::Types->search->count; +my $new_authority_type_1 = Koha::Authority::Type->new( + { authtypecode => 'my_ac_1', + authtypetext => 'my authority type text 1', + auth_tag_to_report => '100', + summary => 'my summary for authority 1', + } +)->store; +my $new_authority_1 = Koha::Authority->new( { authtypecode => $new_authority_type_1->authtypecode, } )->store; +my $new_authority_2 = Koha::Authority->new( { authtypecode => $new_authority_type_1->authtypecode, } )->store; + +is( Koha::Authority::Types->search->count, $nb_of_authority_types + 1, 'The authority type should have been added' ); +is( Koha::Authorities->search->count, $nb_of_authorities + 2, 'The 2 authorities should have been added' ); + +$new_authority_1->delete; +is( Koha::Authorities->search->count, $nb_of_authorities + 1, 'Delete should have deleted the library' ); + +$schema->storage->txn_rollback; +1; --