Bugzilla – Attachment 63801 Details for
Bug 17499
Koha objects for messaging preferences
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17499: Add Koha-objects for messaging preferences
Bug-17499-Add-Koha-objects-for-messaging-preferenc.patch (text/plain), 35.21 KB, created by
Marc Véron
on 2017-05-29 12:26:25 UTC
(
hide
)
Description:
Bug 17499: Add Koha-objects for messaging preferences
Filename:
MIME Type:
Creator:
Marc Véron
Created:
2017-05-29 12:26:25 UTC
Size:
35.21 KB
patch
obsolete
>From c8a61b4cc5abf94c645a8ec916dca993297ede16 Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@jns.fi> >Date: Fri, 21 Oct 2016 17:26:24 +0300 >Subject: [PATCH] Bug 17499: Add Koha-objects for messaging preferences >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch adds Koha-objects for messaging preferences. This patch does not >add any extra logic into these objects. > >Includes test coverage for basic usage. > >To test: >1. prove t/db_dependent/Koha/Patron/Message/* > >Signed-off-by: Marc Véron <veron@veron.ch> >--- > Koha/Patron/Message/Attribute.pm | 50 ++++++ > Koha/Patron/Message/Attributes.pm | 55 +++++++ > Koha/Patron/Message/Preference.pm | 50 ++++++ > Koha/Patron/Message/Preferences.pm | 55 +++++++ > Koha/Patron/Message/Transport.pm | 50 ++++++ > Koha/Patron/Message/Transport/Preference.pm | 51 ++++++ > Koha/Patron/Message/Transport/Preferences.pm | 56 +++++++ > Koha/Patron/Message/Transport/Type.pm | 51 ++++++ > Koha/Patron/Message/Transport/Types.pm | 56 +++++++ > Koha/Patron/Message/Transports.pm | 55 +++++++ > t/db_dependent/Koha/Patron/Message/Attributes.t | 74 +++++++++ > t/db_dependent/Koha/Patron/Message/Preferences.t | 136 ++++++++++++++++ > .../Koha/Patron/Message/Transport/Preferences.t | 172 +++++++++++++++++++++ > .../Koha/Patron/Message/Transport/Types.t | 54 +++++++ > t/db_dependent/Koha/Patron/Message/Transports.t | 119 ++++++++++++++ > 15 files changed, 1084 insertions(+) > create mode 100644 Koha/Patron/Message/Attribute.pm > create mode 100644 Koha/Patron/Message/Attributes.pm > create mode 100644 Koha/Patron/Message/Preference.pm > create mode 100644 Koha/Patron/Message/Preferences.pm > create mode 100644 Koha/Patron/Message/Transport.pm > create mode 100644 Koha/Patron/Message/Transport/Preference.pm > create mode 100644 Koha/Patron/Message/Transport/Preferences.pm > create mode 100644 Koha/Patron/Message/Transport/Type.pm > create mode 100644 Koha/Patron/Message/Transport/Types.pm > create mode 100644 Koha/Patron/Message/Transports.pm > create mode 100644 t/db_dependent/Koha/Patron/Message/Attributes.t > create mode 100644 t/db_dependent/Koha/Patron/Message/Preferences.t > create mode 100644 t/db_dependent/Koha/Patron/Message/Transport/Preferences.t > create mode 100644 t/db_dependent/Koha/Patron/Message/Transport/Types.t > create mode 100644 t/db_dependent/Koha/Patron/Message/Transports.t > >diff --git a/Koha/Patron/Message/Attribute.pm b/Koha/Patron/Message/Attribute.pm >new file mode 100644 >index 0000000..9d9004c >--- /dev/null >+++ b/Koha/Patron/Message/Attribute.pm >@@ -0,0 +1,50 @@ >+package Koha::Patron::Message::Attribute; >+ >+# Copyright Koha-Suomi Oy 2016 >+# >+# 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.a >+# >+# 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 Koha::Database; >+ >+use base qw(Koha::Object); >+ >+=head1 NAME >+ >+Koha::Patron::Message::Attribute - Koha Patron Message Attribute object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'MessageAttribute'; >+} >+ >+=head1 AUTHOR >+ >+Lari Taskula <lari.taskula@jns.fi> >+ >+=cut >+ >+1; >diff --git a/Koha/Patron/Message/Attributes.pm b/Koha/Patron/Message/Attributes.pm >new file mode 100644 >index 0000000..a2df4e6 >--- /dev/null >+++ b/Koha/Patron/Message/Attributes.pm >@@ -0,0 +1,55 @@ >+package Koha::Patron::Message::Attributes; >+ >+# Copyright Koha-Suomi Oy 2016 >+# >+# 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 Koha::Database; >+use Koha::Patron::Message::Attribute; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::Patron::Message::Attributes - Koha Patron Message Attributes object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'MessageAttribute'; >+} >+ >+sub object_class { >+ return 'Koha::Patron::Message::Attribute'; >+} >+ >+=head1 AUTHOR >+ >+Lari Taskula <lari.taskula@jns.fi> >+ >+=cut >+ >+1; >diff --git a/Koha/Patron/Message/Preference.pm b/Koha/Patron/Message/Preference.pm >new file mode 100644 >index 0000000..daeae5c >--- /dev/null >+++ b/Koha/Patron/Message/Preference.pm >@@ -0,0 +1,50 @@ >+package Koha::Patron::Message::Preference; >+ >+# Copyright Koha-Suomi Oy 2016 >+# >+# 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.a >+# >+# 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 Koha::Database; >+ >+use base qw(Koha::Object); >+ >+=head1 NAME >+ >+Koha::Patron::Message::Preference - Koha Patron Message Preference object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'BorrowerMessagePreference'; >+} >+ >+=head1 AUTHOR >+ >+Lari Taskula <lari.taskula@jns.fi> >+ >+=cut >+ >+1; >diff --git a/Koha/Patron/Message/Preferences.pm b/Koha/Patron/Message/Preferences.pm >new file mode 100644 >index 0000000..4639a6b >--- /dev/null >+++ b/Koha/Patron/Message/Preferences.pm >@@ -0,0 +1,55 @@ >+package Koha::Patron::Message::Preferences; >+ >+# Copyright Koha-Suomi Oy 2016 >+# >+# 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 Koha::Database; >+use Koha::Patron::Message::Preference; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::Patron::Message::Preferences - Koha Patron Message Preferences object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'BorrowerMessagePreference'; >+} >+ >+sub object_class { >+ return 'Koha::Patron::Message::Preference'; >+} >+ >+=head1 AUTHOR >+ >+Lari Taskula <lari.taskula@jns.fi> >+ >+=cut >+ >+1; >diff --git a/Koha/Patron/Message/Transport.pm b/Koha/Patron/Message/Transport.pm >new file mode 100644 >index 0000000..ca0906e >--- /dev/null >+++ b/Koha/Patron/Message/Transport.pm >@@ -0,0 +1,50 @@ >+package Koha::Patron::Message::Transport; >+ >+# Copyright Koha-Suomi Oy 2016 >+# >+# 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.a >+# >+# 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 Koha::Database; >+ >+use base qw(Koha::Object); >+ >+=head1 NAME >+ >+Koha::Patron::Message::Transport - Koha Patron Message Transport object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'MessageTransport'; >+} >+ >+=head1 AUTHOR >+ >+Lari Taskula <lari.taskula@jns.fi> >+ >+=cut >+ >+1; >diff --git a/Koha/Patron/Message/Transport/Preference.pm b/Koha/Patron/Message/Transport/Preference.pm >new file mode 100644 >index 0000000..fe0ddeb >--- /dev/null >+++ b/Koha/Patron/Message/Transport/Preference.pm >@@ -0,0 +1,51 @@ >+package Koha::Patron::Message::Transport::Preference; >+ >+# Copyright Koha-Suomi Oy 2016 >+# >+# 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.a >+# >+# 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 Koha::Database; >+ >+use base qw(Koha::Object); >+ >+=head1 NAME >+ >+Koha::Patron::Message::Transport::Preference - Koha Patron Message Transport >+Preference object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'BorrowerMessageTransportPreference'; >+} >+ >+=head1 AUTHOR >+ >+Lari Taskula <lari.taskula@jns.fi> >+ >+=cut >+ >+1; >diff --git a/Koha/Patron/Message/Transport/Preferences.pm b/Koha/Patron/Message/Transport/Preferences.pm >new file mode 100644 >index 0000000..aabd851 >--- /dev/null >+++ b/Koha/Patron/Message/Transport/Preferences.pm >@@ -0,0 +1,56 @@ >+package Koha::Patron::Message::Transport::Preferences; >+ >+# Copyright Koha-Suomi Oy 2016 >+# >+# 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 Koha::Database; >+use Koha::Patron::Message::Transport::Preference; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::Patron::Message::Transport::Preferences - Koha Patron Message Transport >+Preferences object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'BorrowerMessageTransportPreference'; >+} >+ >+sub object_class { >+ return 'Koha::Patron::Message::Transport::Preference'; >+} >+ >+=head1 AUTHOR >+ >+Lari Taskula <lari.taskula@jns.fi> >+ >+=cut >+ >+1; >diff --git a/Koha/Patron/Message/Transport/Type.pm b/Koha/Patron/Message/Transport/Type.pm >new file mode 100644 >index 0000000..4a52a10 >--- /dev/null >+++ b/Koha/Patron/Message/Transport/Type.pm >@@ -0,0 +1,51 @@ >+package Koha::Patron::Message::Transport::Type; >+ >+# Copyright Koha-Suomi Oy 2016 >+# >+# 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.a >+# >+# 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 Koha::Database; >+ >+use base qw(Koha::Object); >+ >+=head1 NAME >+ >+Koha::Patron::Message::Transport::Type - Koha Patron Message Transport Type >+object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'MessageTransportType'; >+} >+ >+=head1 AUTHOR >+ >+Lari Taskula <lari.taskula@jns.fi> >+ >+=cut >+ >+1; >diff --git a/Koha/Patron/Message/Transport/Types.pm b/Koha/Patron/Message/Transport/Types.pm >new file mode 100644 >index 0000000..2633ea3 >--- /dev/null >+++ b/Koha/Patron/Message/Transport/Types.pm >@@ -0,0 +1,56 @@ >+package Koha::Patron::Message::Transport::Types; >+ >+# Copyright Koha-Suomi Oy 2016 >+# >+# 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 Koha::Database; >+use Koha::Patron::Message::Transport::Type; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::Patron::Message::Transport::Types - Koha Patron Message Transport Types >+object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'MessageTransportType'; >+} >+ >+sub object_class { >+ return 'Koha::Patron::Message::Transport::Type'; >+} >+ >+=head1 AUTHOR >+ >+Lari Taskula <lari.taskula@jns.fi> >+ >+=cut >+ >+1; >diff --git a/Koha/Patron/Message/Transports.pm b/Koha/Patron/Message/Transports.pm >new file mode 100644 >index 0000000..b6aee32 >--- /dev/null >+++ b/Koha/Patron/Message/Transports.pm >@@ -0,0 +1,55 @@ >+package Koha::Patron::Message::Transports; >+ >+# Copyright Koha-Suomi Oy 2016 >+# >+# 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 Koha::Database; >+use Koha::Patron::Message::Transport; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::Patron::Message::Transports - Koha Patron Message Transports object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'MessageTransport'; >+} >+ >+sub object_class { >+ return 'Koha::Patron::Message::Transport'; >+} >+ >+=head1 AUTHOR >+ >+Lari Taskula <lari.taskula@jns.fi> >+ >+=cut >+ >+1; >diff --git a/t/db_dependent/Koha/Patron/Message/Attributes.t b/t/db_dependent/Koha/Patron/Message/Attributes.t >new file mode 100644 >index 0000000..836b4f0 >--- /dev/null >+++ b/t/db_dependent/Koha/Patron/Message/Attributes.t >@@ -0,0 +1,74 @@ >+#!/usr/bin/perl >+ >+# Copyright 2017 Koha-Suomi Oy >+# >+# 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 => 2; >+ >+use Koha::Database; >+ >+my $schema = Koha::Database->new->schema; >+ >+subtest 'Test class imports' => sub { >+ plan tests => 2; >+ >+ use_ok('Koha::Patron::Message::Attribute'); >+ use_ok('Koha::Patron::Message::Attributes'); >+}; >+ >+subtest 'Test Koha::Patron::Message::Attributes' => sub { >+ plan tests => 6; >+ >+ $schema->storage->txn_begin; >+ >+ Koha::Patron::Message::Attribute->new({ >+ message_name => 'Test_Attribute' >+ })->store; >+ Koha::Patron::Message::Attribute->new({ >+ message_name => 'Test_Attribute2', >+ takes_days => 1 >+ })->store; >+ >+ my $attribute = Koha::Patron::Message::Attributes->find({ >+ message_name => 'Test_Attribute' }); >+ my $attribute2 = Koha::Patron::Message::Attributes->find({ >+ message_name => 'Test_Attribute2' }); >+ >+ is($attribute->message_name, 'Test_Attribute', >+ 'Added a new messaging attribute.'); >+ is($attribute->takes_days, 0, >+ 'For that messaging attribute, takes_days is disabled by default.'); >+ is($attribute2->message_name, 'Test_Attribute2', >+ 'Added another messaging attribute.'); >+ is($attribute2->takes_days, 1, >+ 'takes_days is enabled for that message attribute (as expected).'); >+ >+ $attribute->delete; >+ $attribute2->delete; >+ is(Koha::Patron::Message::Attributes->find({ >+ message_name => 'Test_Attribute' }), undef, >+ 'Deleted the first message attribute.'); >+ is(Koha::Patron::Message::Attributes->find({ >+ message_name => 'Test_Attribute2' }), undef, >+ 'Deleted the second message attribute.'); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+1; >diff --git a/t/db_dependent/Koha/Patron/Message/Preferences.t b/t/db_dependent/Koha/Patron/Message/Preferences.t >new file mode 100644 >index 0000000..b9cef3a >--- /dev/null >+++ b/t/db_dependent/Koha/Patron/Message/Preferences.t >@@ -0,0 +1,136 @@ >+#!/usr/bin/perl >+ >+# Copyright 2017 Koha-Suomi Oy >+# >+# 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 => 2; >+ >+use t::lib::Mocks; >+use t::lib::TestBuilder; >+ >+use Koha::Notice::Templates; >+use Koha::Patron::Categories; >+use Koha::Patron::Message::Attributes; >+use Koha::Patron::Message::Transport::Types; >+use Koha::Patron::Message::Transports; >+use Koha::Patrons; >+ >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+subtest 'Test class imports' => sub { >+ plan tests => 2; >+ >+ use_ok('Koha::Patron::Message::Preference'); >+ use_ok('Koha::Patron::Message::Preferences'); >+}; >+ >+subtest 'Test Koha::Patron::Message::Preferences' => sub { >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $attribute = build_a_test_attribute(); >+ >+ subtest 'Test for a patron' => sub { >+ plan tests => 2; >+ >+ my $patron = build_a_test_patron(); >+ Koha::Patron::Message::Preference->new({ >+ borrowernumber => $patron->borrowernumber, >+ message_attribute_id => $attribute->message_attribute_id, >+ wants_digest => 0, >+ days_in_advance => undef, >+ })->store; >+ >+ my $preference = Koha::Patron::Message::Preferences->find({ >+ borrowernumber => $patron->borrowernumber, >+ message_attribute_id => $attribute->message_attribute_id >+ }); >+ ok($preference->borrower_message_preference_id > 0, >+ 'Added a new messaging preference for patron.'); >+ >+ $preference->delete; >+ is(Koha::Patron::Message::Preferences->search({ >+ borrowernumber => $patron->borrowernumber, >+ message_attribute_id => $attribute->message_attribute_id >+ })->count, 0, 'Deleted the messaging preference.'); >+ }; >+ >+ subtest 'Test for a category' => sub { >+ my $category = build_a_test_category(); >+ Koha::Patron::Message::Preference->new({ >+ categorycode => $category->categorycode, >+ message_attribute_id => $attribute->message_attribute_id, >+ wants_digest => 0, >+ days_in_advance => undef, >+ })->store; >+ >+ my $preference = Koha::Patron::Message::Preferences->find({ >+ categorycode => $category->categorycode, >+ message_attribute_id => $attribute->message_attribute_id >+ }); >+ ok($preference->borrower_message_preference_id > 0, >+ 'Added a new messaging preference for category.'); >+ >+ $preference->delete; >+ is(Koha::Patron::Message::Preferences->search({ >+ categorycode => $category->categorycode, >+ message_attribute_id => $attribute->message_attribute_id >+ })->count, 0, 'Deleted the messaging preference.'); >+ }; >+ >+ $schema->storage->txn_rollback; >+}; >+ >+sub build_a_test_attribute { >+ my ($params) = @_; >+ >+ $params->{takes_days} = $params->{takes_days} && $params->{takes_days} > 0 >+ ? 1 : 0; >+ >+ my $attribute = $builder->build({ >+ source => 'MessageAttribute', >+ value => $params, >+ }); >+ >+ return Koha::Patron::Message::Attributes->find( >+ $attribute->{message_attribute_id} >+ ); >+} >+ >+sub build_a_test_category { >+ my $categorycode = $builder->build({ >+ source => 'Category' })->{categorycode}; >+ >+ return Koha::Patron::Categories->find($categorycode); >+} >+ >+sub build_a_test_patron { >+ my $categorycode = $builder->build({ >+ source => 'Category' })->{categorycode}; >+ my $branchcode = $builder->build({ >+ source => 'Branch' })->{branchcode}; >+ my $borrowernumber = $builder->build({ >+ source => 'Borrower' })->{borrowernumber}; >+ >+ return Koha::Patrons->find($borrowernumber); >+} >+ >+1; >diff --git a/t/db_dependent/Koha/Patron/Message/Transport/Preferences.t b/t/db_dependent/Koha/Patron/Message/Transport/Preferences.t >new file mode 100644 >index 0000000..b77415d >--- /dev/null >+++ b/t/db_dependent/Koha/Patron/Message/Transport/Preferences.t >@@ -0,0 +1,172 @@ >+#!/usr/bin/perl >+ >+# Copyright 2017 Koha-Suomi Oy >+# >+# 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 => 2; >+ >+use t::lib::Mocks; >+use t::lib::TestBuilder; >+ >+use Koha::Notice::Templates; >+use Koha::Patron::Categories; >+use Koha::Patron::Message::Attributes; >+use Koha::Patron::Message::Preferences; >+use Koha::Patron::Message::Transport::Types; >+use Koha::Patron::Message::Transports; >+use Koha::Patrons; >+ >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+subtest 'Test class imports' => sub { >+ plan tests => 2; >+ >+ use_ok('Koha::Patron::Message::Transport::Preference'); >+ use_ok('Koha::Patron::Message::Transport::Preferences'); >+}; >+ >+subtest 'Test Koha::Patron::Message::Transport::Preferences' => sub { >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $attribute = build_a_test_attribute(); >+ my $mtt = build_a_test_transport_type(); >+ my $letter = build_a_test_letter({ >+ mtt => $mtt->message_transport_type >+ }); >+ >+ subtest 'For a patron' => sub { >+ my $patron = build_a_test_patron(); >+ my $preference = Koha::Patron::Message::Preference->new({ >+ borrowernumber => $patron->borrowernumber, >+ message_attribute_id => $attribute->message_attribute_id, >+ wants_digest => 0, >+ days_in_advance => undef, >+ })->store; >+ >+ my $pref_id = $preference->borrower_message_preference_id; >+ my $transport_pref = Koha::Patron::Message::Transport::Preference->new({ >+ borrower_message_preference_id => $pref_id, >+ message_transport_type => $mtt->message_transport_type, >+ })->store; >+ is(ref($transport_pref), 'Koha::Patron::Message::Transport::Preference', >+ 'Added a new messaging transport preference for patron.'); >+ >+ $transport_pref->delete; >+ is(Koha::Patron::Message::Transport::Preferences->search({ >+ borrower_message_preference_id => $pref_id, >+ message_transport_type => $mtt->message_transport_type, >+ })->count, 0, 'Deleted the messaging transport preference.'); >+ }; >+ >+ subtest 'For a category' => sub { >+ my $category = build_a_test_category(); >+ my $preference = Koha::Patron::Message::Preference->new({ >+ categorycode => $category->categorycode, >+ message_attribute_id => $attribute->message_attribute_id, >+ wants_digest => 0, >+ days_in_advance => undef, >+ })->store; >+ >+ my $pref_id = $preference->borrower_message_preference_id; >+ my $transport_pref = Koha::Patron::Message::Transport::Preference->new({ >+ borrower_message_preference_id => $pref_id, >+ message_transport_type => $mtt->message_transport_type, >+ })->store; >+ is(ref($transport_pref), 'Koha::Patron::Message::Transport::Preference', >+ 'Added a new messaging transport preference for category.'); >+ >+ $transport_pref->delete; >+ is(Koha::Patron::Message::Transport::Preferences->search({ >+ borrower_message_preference_id => $pref_id, >+ message_transport_type => $mtt->message_transport_type, >+ })->count, 0, 'Deleted the messaging transport preference.'); >+ }; >+ >+ $schema->storage->txn_rollback; >+}; >+ >+sub build_a_test_attribute { >+ my ($params) = @_; >+ >+ $params->{takes_days} = $params->{takes_days} && $params->{takes_days} > 0 >+ ? 1 : 0; >+ >+ my $attribute = $builder->build({ >+ source => 'MessageAttribute', >+ value => $params, >+ }); >+ >+ return Koha::Patron::Message::Attributes->find( >+ $attribute->{message_attribute_id} >+ ); >+} >+ >+sub build_a_test_category { >+ my $categorycode = $builder->build({ >+ source => 'Category' })->{categorycode}; >+ >+ return Koha::Patron::Categories->find($categorycode); >+} >+ >+sub build_a_test_letter { >+ my ($params) = @_; >+ >+ my $mtt = $params->{mtt} ? $params->{mtt} : 'email'; >+ my $branchcode = $builder->build({ >+ source => 'Branch' })->{branchcode}; >+ my $letter = $builder->build({ >+ source => 'Letter', >+ value => { >+ branchcode => '', >+ is_html => 0, >+ message_transport_type => $mtt >+ } >+ }); >+ >+ return Koha::Notice::Templates->find({ >+ module => $letter->{module}, >+ code => $letter->{code}, >+ branchcode => $letter->{branchcode}, >+ }); >+} >+ >+sub build_a_test_patron { >+ my $categorycode = $builder->build({ >+ source => 'Category' })->{categorycode}; >+ my $branchcode = $builder->build({ >+ source => 'Branch' })->{branchcode}; >+ my $borrowernumber = $builder->build({ >+ source => 'Borrower' })->{borrowernumber}; >+ >+ return Koha::Patrons->find($borrowernumber); >+} >+ >+sub build_a_test_transport_type { >+ my $mtt = $builder->build({ >+ source => 'MessageTransportType' }); >+ >+ return Koha::Patron::Message::Transport::Types->find( >+ $mtt->{message_transport_type} >+ ); >+} >+ >+1; >diff --git a/t/db_dependent/Koha/Patron/Message/Transport/Types.t b/t/db_dependent/Koha/Patron/Message/Transport/Types.t >new file mode 100644 >index 0000000..cbba32b >--- /dev/null >+++ b/t/db_dependent/Koha/Patron/Message/Transport/Types.t >@@ -0,0 +1,54 @@ >+#!/usr/bin/perl >+ >+# Copyright 2017 Koha-Suomi Oy >+# >+# 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 => 2; >+ >+use Koha::Database; >+ >+my $schema = Koha::Database->new->schema; >+ >+subtest 'Test class imports' => sub { >+ plan tests => 2; >+ >+ use_ok('Koha::Patron::Message::Transport::Type'); >+ use_ok('Koha::Patron::Message::Transport::Types'); >+}; >+ >+subtest 'Test Koha::Patron::Message::Transport::Types' => sub { >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $transport_type = Koha::Patron::Message::Transport::Type->new({ >+ message_transport_type => 'test' >+ })->store; >+ >+ is($transport_type->message_transport_type, 'test', >+ 'Added a new message transport type.'); >+ >+ $transport_type->delete; >+ is(Koha::Patron::Message::Transport::Types->find('test'), undef, >+ 'Deleted the message transport type.'); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+1; >diff --git a/t/db_dependent/Koha/Patron/Message/Transports.t b/t/db_dependent/Koha/Patron/Message/Transports.t >new file mode 100644 >index 0000000..b9296fd >--- /dev/null >+++ b/t/db_dependent/Koha/Patron/Message/Transports.t >@@ -0,0 +1,119 @@ >+#!/usr/bin/perl >+ >+# Copyright 2017 Koha-Suomi Oy >+# >+# 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 => 2; >+ >+use t::lib::TestBuilder; >+ >+use Koha::Notice::Templates; >+use Koha::Patron::Message::Attributes; >+use Koha::Patron::Message::Transport::Types; >+ >+my $schema = Koha::Database->new->schema; >+my $builder = t::lib::TestBuilder->new; >+ >+subtest 'Test class imports' => sub { >+ plan tests => 2; >+ >+ use_ok('Koha::Patron::Message::Transport'); >+ use_ok('Koha::Patron::Message::Transports'); >+}; >+ >+subtest 'Test Koha::Patron::Message::Transports' => sub { >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $attribute = build_a_test_attribute(); >+ my $mtt = build_a_test_transport_type(); >+ my $letter = build_a_test_letter({ >+ mtt => $mtt->message_transport_type >+ }); >+ >+ my $transport = Koha::Patron::Message::Transport->new({ >+ message_attribute_id => $attribute->message_attribute_id, >+ message_transport_type => $mtt->message_transport_type, >+ is_digest => 0, >+ letter_module => $letter->module, >+ letter_code => $letter->code, >+ })->store; >+ >+ is($transport->message_attribute_id, $attribute->message_attribute_id, >+ 'Added a new messaging transport.'); >+ >+ $transport->delete; >+ is(Koha::Patron::Message::Transports->search({ >+ message_attribute_id => $attribute->message_attribute_id, >+ message_transport_type => $mtt->message_transport_type, >+ is_digest => 0 >+ })->count, 0, 'Deleted the messaging transport.'); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+sub build_a_test_attribute { >+ my ($params) = @_; >+ >+ $params->{takes_days} = $params->{takes_days} && $params->{takes_days} > 0 >+ ? 1 : 0; >+ >+ my $attribute = $builder->build({ >+ source => 'MessageAttribute', >+ value => $params, >+ }); >+ >+ return Koha::Patron::Message::Attributes->find( >+ $attribute->{message_attribute_id} >+ ); >+} >+ >+sub build_a_test_letter { >+ my ($params) = @_; >+ >+ my $mtt = $params->{mtt} ? $params->{mtt} : 'email'; >+ my $branchcode = $builder->build({ >+ source => 'Branch' })->{branchcode}; >+ my $letter = $builder->build({ >+ source => 'Letter', >+ value => { >+ branchcode => '', >+ is_html => 0, >+ message_transport_type => $mtt >+ } >+ }); >+ >+ return Koha::Notice::Templates->find({ >+ module => $letter->{module}, >+ code => $letter->{code}, >+ branchcode => $letter->{branchcode}, >+ }); >+} >+ >+sub build_a_test_transport_type { >+ my $mtt = $builder->build({ >+ source => 'MessageTransportType' }); >+ >+ return Koha::Patron::Message::Transport::Types->find( >+ $mtt->{message_transport_type} >+ ); >+} >+ >+1; >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17499
:
63427
|
63428
|
63429
|
63430
|
63431
|
63432
|
63433
|
63434
|
63786
|
63787
|
63788
|
63789
|
63790
|
63791
|
63792
|
63793
|
63801
|
63802
|
63803
|
63804
|
63805
|
63806
|
63807
|
63808
|
63809
|
63810
|
63811
|
63812
|
63878
|
63895
|
64035
|
64036
|
64037
|
64038
|
64039
|
64040
|
64041
|
64042
|
64043
|
64044
|
64795
|
66686
|
69434
|
69435
|
69458
|
91864
|
93863
|
93865
|
93872
|
94748
|
99479
|
99634
|
99668
|
99669
|
99670
|
103441
|
103442
|
103443
|
106653
|
106654
|
106655
|
106656
|
106657
|
107612
|
107613
|
107614
|
107615
|
107616
|
113010
|
113011
|
113127
|
113129
|
113686
|
113687
|
113765
|
113766
|
113767
|
113768
|
118452
|
118453
|
119470
|
119471
|
119472
|
119473
|
119474
|
119475
|
119476
|
119477
|
119478
|
119479
|
119480
|
119481
|
119482
|
119483
|
119484
|
119485
|
119486
|
119487
|
119488
|
119489
|
119490
|
119491
|
141408
|
141409
|
141410
|
141411
|
141412
|
141413
|
141414
|
141415
|
141416
|
141417
|
141418
|
146529
|
146530
|
146531
|
146532
|
146533
|
146534
|
146535
|
146536
|
146537
|
146538
|
146539
|
146540
|
151900
|
151901
|
151902
|
151903
|
151904
|
151905
|
151906
|
151907
|
151908
|
151909
|
151910
|
151911
|
151937
|
151938
|
151939
|
151940
|
151941
|
151942
|
151943
|
151944
|
151945
|
151946
|
151947
|
151948
|
155365
|
155366
|
155367
|
155368
|
155369
|
155370
|
155371
|
155372
|
155373
|
155374
|
155375
|
155376