Bug 21846: Add Koha::Tags::Approval(s) and Koha::Tags::Index(es)
authorTomas Cohen Arazi <tomascohen@theke.io>
Fri, 23 Nov 2018 18:44:04 +0000 (15:44 -0300)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 19 Mar 2019 09:57:07 +0000 (09:57 +0000)
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 <oleonard@myacpl.org>

Signed-off-by: Josef Moravec <josef.moravec@gmail.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
(cherry picked from commit 6c86de628d5873b88a7d6d2d676ecd7b98345aa7)
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Koha/Tag.pm [new file with mode: 0644]
Koha/Tags.pm [new file with mode: 0644]
Koha/Tags/Approval.pm [new file with mode: 0644]
Koha/Tags/Approvals.pm [new file with mode: 0644]
Koha/Tags/Index.pm [new file with mode: 0644]
Koha/Tags/Indexes.pm [new file with mode: 0644]
t/db_dependent/Koha/Tags.t [new file with mode: 0644]
t/db_dependent/Koha/Tags/Approvals.t [new file with mode: 0644]
t/db_dependent/Koha/Tags/Indexes.t [new file with mode: 0644]

diff --git a/Koha/Tag.pm b/Koha/Tag.pm
new file mode 100644 (file)
index 0000000..7a59504
--- /dev/null
@@ -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 (file)
index 0000000..a6a49ab
--- /dev/null
@@ -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 (file)
index 0000000..42a9b38
--- /dev/null
@@ -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 (file)
index 0000000..663f1fd
--- /dev/null
@@ -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 (file)
index 0000000..b0007ba
--- /dev/null
@@ -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 (file)
index 0000000..86bbabe
--- /dev/null
@@ -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 (file)
index 0000000..a1a3939
--- /dev/null
@@ -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 <http://www.gnu.org/licenses>.
+
+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 (file)
index 0000000..dc2a438
--- /dev/null
@@ -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 <http://www.gnu.org/licenses>.
+
+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 (file)
index 0000000..770bee3
--- /dev/null
@@ -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 <http://www.gnu.org/licenses>.
+
+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;
+
+};