Bugzilla – Attachment 72386 Details for
Bug 20052
Add Reports object class
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20052 - Add Koha Reports object class
Bug-20052---Add-Koha-Reports-object-class.patch (text/plain), 5.08 KB, created by
Maksim Sen
on 2018-03-02 21:15:13 UTC
(
hide
)
Description:
Bug 20052 - Add Koha Reports object class
Filename:
MIME Type:
Creator:
Maksim Sen
Created:
2018-03-02 21:15:13 UTC
Size:
5.08 KB
patch
obsolete
>From 0ccac10a79b3163611268661b9e60e6037a90519 Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Mon, 15 Jan 2018 14:38:13 +0000 >Subject: [PATCH] Bug 20052 - Add Koha Reports object class > >To test: >prove -v t/db_dependent/Koha/Reports.t > >Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de> >Signed-off-by: Maksim Sen <maksim.sen@inlibro.com> >--- > Koha/Report.pm | 44 +++++++++++++++++++++++++++++++++++ > Koha/Reports.pm | 50 ++++++++++++++++++++++++++++++++++++++++ > t/db_dependent/Koha/Reports.t | 53 +++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 147 insertions(+) > create mode 100644 Koha/Report.pm > create mode 100644 Koha/Reports.pm > create mode 100644 t/db_dependent/Koha/Reports.t > >diff --git a/Koha/Report.pm b/Koha/Report.pm >new file mode 100644 >index 0000000..a4b540d >--- /dev/null >+++ b/Koha/Report.pm >@@ -0,0 +1,44 @@ >+package Koha::Report; >+ >+# 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::Database; >+ >+use base qw(Koha::Object); >+ >+=head1 NAME >+ >+Koha::Report - Koha Report Object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'SavedSql'; >+} >+ >+1; >diff --git a/Koha/Reports.pm b/Koha/Reports.pm >new file mode 100644 >index 0000000..c0715ae >--- /dev/null >+++ b/Koha/Reports.pm >@@ -0,0 +1,50 @@ >+package Koha::Reports; >+ >+# 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::Database; >+ >+use Koha::Report; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::Reports - Koha Report Object set class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'SavedSql'; >+} >+ >+sub object_class { >+ return 'Koha::Report'; >+} >+ >+1; >diff --git a/t/db_dependent/Koha/Reports.t b/t/db_dependent/Koha/Reports.t >new file mode 100644 >index 0000000..4948e12 >--- /dev/null >+++ b/t/db_dependent/Koha/Reports.t >@@ -0,0 +1,53 @@ >+#!/usr/bin/perl >+ >+# Copyright 2015 Koha Development team >+# >+# 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 => 4; >+ >+use Koha::Report; >+use Koha::Reports; >+use Koha::Database; >+ >+use t::lib::TestBuilder; >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+my $builder = t::lib::TestBuilder->new; >+my $nb_of_reports = Koha::Reports->search->count; >+my $new_report_1 = Koha::Report->new({ >+ report_name => 'report_name_for_test_1', >+ savedsql => 'SELECT "I wrote a report"', >+})->store; >+my $new_report_2 = Koha::Report->new({ >+ report_name => 'report_name_for_test_1', >+ savedsql => 'SELECT "Oops, I did it again"', >+})->store; >+ >+like( $new_report_1->id, qr|^\d+$|, 'Adding a new report should have set the id'); >+is( Koha::Reports->search->count, $nb_of_reports + 2, 'The 2 reports should have been added' ); >+ >+my $retrieved_report_1 = Koha::Reports->find( $new_report_1->id ); >+is( $retrieved_report_1->report_name, $new_report_1->report_name, 'Find a report by id should return the correct report' ); >+ >+$retrieved_report_1->delete; >+is( Koha::Reports->search->count, $nb_of_reports + 1, 'Delete should have deleted the report' ); >+ >+$schema->storage->txn_rollback; >-- >2.7.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 20052
:
70784
|
70845
|
72386
|
73422
|
73455
|
73456