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 <oleonard@myacpl.org>

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

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
This commit is contained in:
Tomás Cohen Arazi 2018-11-23 15:44:04 -03:00 committed by Nick Clemens
parent 1464328718
commit 6c86de628d
9 changed files with 417 additions and 0 deletions

42
Koha/Tag.pm Normal file
View file

@ -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;

52
Koha/Tags.pm Normal file
View file

@ -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;

42
Koha/Tags/Approval.pm Normal file
View file

@ -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;

52
Koha/Tags/Approvals.pm Normal file
View file

@ -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;

42
Koha/Tags/Index.pm Normal file
View file

@ -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;

52
Koha/Tags/Indexes.pm Normal file
View file

@ -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;

View file

@ -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;
};

View file

@ -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;
};

View file

@ -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;
};