From 2ab1ec967bea11c39795d0b77d40845d3f6fb0a5 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Fri, 23 Nov 2018 15:44:04 -0300 Subject: [PATCH] Bug 21846: Add Koha::Tags::Approval(s) and Koha::Tags::Index(es) In order to avoid writing the tests using plain DBIC which would later need to be replaced by a Koha::Object-based counterpart, I introduce this stub classes. Stub tests are added as well. To test: - Apply this patch - Run: $ kshell k$ prove t/db_dependent/Koha/Tags.t \ t/db_dependent/Koha/Tags/Approvals.t \ t/db_dependent/Koha/Tags/Indexes.t => SUCCESS: Tests pass - Sign off :-D Signed-off-by: Owen Leonard Signed-off-by: Josef Moravec Signed-off-by: Nick Clemens (cherry picked from commit 6c86de628d5873b88a7d6d2d676ecd7b98345aa7) Signed-off-by: Martin Renvoize --- Koha/Tag.pm | 42 ++++++++++++++++++++++ Koha/Tags.pm | 52 ++++++++++++++++++++++++++++ Koha/Tags/Approval.pm | 42 ++++++++++++++++++++++ Koha/Tags/Approvals.pm | 52 ++++++++++++++++++++++++++++ Koha/Tags/Index.pm | 42 ++++++++++++++++++++++ Koha/Tags/Indexes.pm | 52 ++++++++++++++++++++++++++++ t/db_dependent/Koha/Tags.t | 45 ++++++++++++++++++++++++ t/db_dependent/Koha/Tags/Approvals.t | 45 ++++++++++++++++++++++++ t/db_dependent/Koha/Tags/Indexes.t | 45 ++++++++++++++++++++++++ 9 files changed, 417 insertions(+) create mode 100644 Koha/Tag.pm create mode 100644 Koha/Tags.pm create mode 100644 Koha/Tags/Approval.pm create mode 100644 Koha/Tags/Approvals.pm create mode 100644 Koha/Tags/Index.pm create mode 100644 Koha/Tags/Indexes.pm create mode 100644 t/db_dependent/Koha/Tags.t create mode 100644 t/db_dependent/Koha/Tags/Approvals.t create mode 100644 t/db_dependent/Koha/Tags/Indexes.t diff --git a/Koha/Tag.pm b/Koha/Tag.pm new file mode 100644 index 0000000000..7a59504f28 --- /dev/null +++ b/Koha/Tag.pm @@ -0,0 +1,42 @@ +package Koha::Tag; + +# 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 base qw(Koha::Object); + +=head1 NAME + +Koha::Tag - Koha Tag Object class + +=head1 API + +=head2 Internal methods + +=cut + +=head3 _type + +=cut + +sub _type { + return 'TagAll'; +} + +1; diff --git a/Koha/Tags.pm b/Koha/Tags.pm new file mode 100644 index 0000000000..a6a49ab8bc --- /dev/null +++ b/Koha/Tags.pm @@ -0,0 +1,52 @@ +package Koha::Tags; + +# 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::Tag; + +use base qw(Koha::Objects); + +=head1 NAME + +Koha::Tags - Koha Tags Object set class + +=head1 API + +=head2 Internal methods + +=cut + +=head3 _type + +=cut + +sub _type { + return 'TagAll'; +} + +=head3 object_class + +=cut + +sub object_class { + return 'Koha::Tag'; +} + +1; diff --git a/Koha/Tags/Approval.pm b/Koha/Tags/Approval.pm new file mode 100644 index 0000000000..42a9b3823f --- /dev/null +++ b/Koha/Tags/Approval.pm @@ -0,0 +1,42 @@ +package Koha::Tags::Approval; + +# 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 base qw(Koha::Object); + +=head1 NAME + +Koha::Tags::Approval - Koha Tag approval Object class + +=head1 API + +=head2 Internal methods + +=cut + +=head3 _type + +=cut + +sub _type { + return 'TagsApproval'; +} + +1; diff --git a/Koha/Tags/Approvals.pm b/Koha/Tags/Approvals.pm new file mode 100644 index 0000000000..663f1fdd54 --- /dev/null +++ b/Koha/Tags/Approvals.pm @@ -0,0 +1,52 @@ +package Koha::Tags::Approvals; + +# 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::Tags::Approval; + +use base qw(Koha::Objects); + +=head1 NAME + +Koha::Tags::Approvals - Koha Tag Approvals Object set class + +=head1 API + +=head2 Internal methods + +=cut + +=head3 _type + +=cut + +sub _type { + return 'TagsApproval'; +} + +=head3 object_class + +=cut + +sub object_class { + return 'Koha::Tags::Approval'; +} + +1; diff --git a/Koha/Tags/Index.pm b/Koha/Tags/Index.pm new file mode 100644 index 0000000000..b0007ba164 --- /dev/null +++ b/Koha/Tags/Index.pm @@ -0,0 +1,42 @@ +package Koha::Tags::Index; + +# 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 base qw(Koha::Object); + +=head1 NAME + +Koha::Tags::Index - Koha Tag approval Object class + +=head1 API + +=head2 Internal methods + +=cut + +=head3 _type + +=cut + +sub _type { + return 'TagsIndex'; +} + +1; diff --git a/Koha/Tags/Indexes.pm b/Koha/Tags/Indexes.pm new file mode 100644 index 0000000000..86bbabe270 --- /dev/null +++ b/Koha/Tags/Indexes.pm @@ -0,0 +1,52 @@ +package Koha::Tags::Indexes; + +# 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::Tags::Index; + +use base qw(Koha::Objects); + +=head1 NAME + +Koha::Tags::Indexes - Koha Tag Indexes Object set class + +=head1 API + +=head2 Internal methods + +=cut + +=head3 _type + +=cut + +sub _type { + return 'TagsIndex'; +} + +=head3 object_class + +=cut + +sub object_class { + return 'Koha::Tags::Index'; +} + +1; diff --git a/t/db_dependent/Koha/Tags.t b/t/db_dependent/Koha/Tags.t new file mode 100644 index 0000000000..a1a3939fd7 --- /dev/null +++ b/t/db_dependent/Koha/Tags.t @@ -0,0 +1,45 @@ +#!/usr/bin/perl + +# 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 => 1; + +use t::lib::TestBuilder; + +use Koha::Database; +use Koha::Tags; + +my $schema = Koha::Database->schema; +my $builder = t::lib::TestBuilder->new; + +subtest 'search() tests' => sub { + + plan tests => 1; + + $schema->storage->txn_begin; + + my $current_count = Koha::Tags->search->count; + + my $approval_1 = $builder->build_object({ class => 'Koha::Tags' }); + my $approval_2 = $builder->build_object({ class => 'Koha::Tags' }); + + is( Koha::Tags->search->count, $current_count + 2, 'Tags count consistent' ); + + $schema->storage->txn_rollback; + +}; diff --git a/t/db_dependent/Koha/Tags/Approvals.t b/t/db_dependent/Koha/Tags/Approvals.t new file mode 100644 index 0000000000..dc2a438a0e --- /dev/null +++ b/t/db_dependent/Koha/Tags/Approvals.t @@ -0,0 +1,45 @@ +#!/usr/bin/perl + +# 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 => 1; + +use t::lib::TestBuilder; + +use Koha::Database; +use Koha::Tags::Approvals; + +my $schema = Koha::Database->schema; +my $builder = t::lib::TestBuilder->new; + +subtest 'search() tests' => sub { + + plan tests => 1; + + $schema->storage->txn_begin; + + my $current_count = Koha::Tags::Approvals->search->count; + + my $approval_1 = $builder->build_object({ class => 'Koha::Tags::Approvals' }); + my $approval_2 = $builder->build_object({ class => 'Koha::Tags::Approvals' }); + + is( Koha::Tags::Approvals->search->count, $current_count + 2, 'Approvals count consistent' ); + + $schema->storage->txn_rollback; + +}; diff --git a/t/db_dependent/Koha/Tags/Indexes.t b/t/db_dependent/Koha/Tags/Indexes.t new file mode 100644 index 0000000000..770bee33b6 --- /dev/null +++ b/t/db_dependent/Koha/Tags/Indexes.t @@ -0,0 +1,45 @@ +#!/usr/bin/perl + +# 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 => 1; + +use t::lib::TestBuilder; + +use Koha::Database; +use Koha::Tags::Indexes; + +my $schema = Koha::Database->schema; +my $builder = t::lib::TestBuilder->new; + +subtest 'search() tests' => sub { + + plan tests => 1; + + $schema->storage->txn_begin; + + my $current_count = Koha::Tags::Indexes->search->count; + + my $approval_1 = $builder->build_object({ class => 'Koha::Tags::Indexes' }); + my $approval_2 = $builder->build_object({ class => 'Koha::Tags::Indexes' }); + + is( Koha::Tags::Indexes->search->count, $current_count + 2, 'Indexes count consistent' ); + + $schema->storage->txn_rollback; + +}; -- 2.39.5