Introduces Koha::Patron::Consent[s] for new table.
Adds basic CRUD test.
Test plan:
Run t/db_dependent/Koha/Patron/Consents.t
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
--- /dev/null
+package Koha::Patron::Consent;
+
+# Copyright 2018 Rijksmuseum
+#
+# 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 base qw(Koha::Object);
+
+=head1 NAME
+
+Koha::Patron::Consent
+
+=head1 DESCRIPTION
+
+Koha::Object class for handling patron consents
+
+=head1 API
+
+=head2 Class Methods
+
+=head3 _type
+
+=cut
+
+sub _type {
+ return 'PatronConsent';
+}
+
+1;
--- /dev/null
+package Koha::Patron::Consents;
+
+# Copyright 2018 Rijksmuseum
+#
+# 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 base qw(Koha::Objects);
+use Koha::Patron::Consent;
+
+=head1 NAME
+
+Koha::Patron::Consents
+
+=head1 DESCRIPTION
+
+Koha::Objects class for handling patron consents
+
+=head1 API
+
+=head2 Class Methods
+
+=cut
+
+=head3 _type
+
+=cut
+
+sub _type {
+ return 'PatronConsent';
+}
+
+=head3 object_class
+
+=cut
+
+sub object_class {
+ return 'Koha::Patron::Consent';
+}
+
+1;
--- /dev/null
+#!/usr/bin/perl
+
+# Copyright 2018 Rijksmuseum
+#
+# 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::DateUtils qw/dt_from_string/;
+use Koha::Patron::Consents;
+
+our $builder = t::lib::TestBuilder->new;
+our $schema = Koha::Database->new->schema;
+
+subtest 'Basic tests for Koha::Patron::Consent' => sub {
+ plan tests => 2;
+ $schema->storage->txn_begin;
+
+ my $patron1 = $builder->build_object({ class => 'Koha::Patrons' });
+ my $consent1 = Koha::Patron::Consent->new({
+ borrowernumber => $patron1->borrowernumber,
+ type => 'GDPR_PROCESSING',
+ given_on => dt_from_string,
+ })->store;
+ is( Koha::Patron::Consents->search({ borrowernumber => $patron1->borrowernumber })->count, 1, 'One consent for new borrower' );
+ $consent1->delete;
+ is( Koha::Patron::Consents->search({ borrowernumber => $patron1->borrowernumber })->count, 0, 'No consents left for new borrower' );
+
+ $schema->storage->txn_rollback;
+};