Bugzilla – Attachment 48166 Details for
Bug 15839
Move the reviews related code to Koha::Reviews
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15839: Koha::Reviews - Add Koha::Review[s] classes
Bug-15839-KohaReviews---Add-KohaReviews-classes.patch (text/plain), 6.28 KB, created by
Jonathan Druart
on 2016-02-17 13:45:23 UTC
(
hide
)
Description:
Bug 15839: Koha::Reviews - Add Koha::Review[s] classes
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-02-17 13:45:23 UTC
Size:
6.28 KB
patch
obsolete
>From c09b4011d2f040e32f554cd01735b9bfdd4ba699 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 16 Feb 2016 16:41:22 +0000 >Subject: [PATCH] Bug 15839: Koha::Reviews - Add Koha::Review[s] classes > >The subroutines in C4::Reviews are only doing CRUD operations. >This patch set moves them to 2 new Koha::Review[s] classes. > >Test plan for the whole patch set: >0/ Set the reviewson syspref >1/ At the OPAC, create a couple of reviews for a record >Try and create a review without html tags different that br b i em big >small strong: You should get a warning. >2/ Edit a review >3/ On the Staff interface, you should see a "Comments pending approval" >link on the mainpage >4/ Approve 1 review and delete the other >5/ At the OPAC you should only see 1 review (the approved one) in the >"Comments" tab >6/ Modify the review >7/ The review should appear again in the "comments awaiting moderation" >tab. >Note that even the comment has not been changed, it will have to be >reapproved (FIXME later). This behavior already existed prior to this >patch. >--- > Koha/Review.pm | 44 +++++++++++++++++++++++++++++ > Koha/Reviews.pm | 50 ++++++++++++++++++++++++++++++++ > t/db_dependent/Koha/Reviews.t | 66 +++++++++++++++++++++++++++++++++++++++++++ > 3 files changed, 160 insertions(+) > create mode 100644 Koha/Review.pm > create mode 100644 Koha/Reviews.pm > create mode 100644 t/db_dependent/Koha/Reviews.t > >diff --git a/Koha/Review.pm b/Koha/Review.pm >new file mode 100644 >index 0000000..082f71f >--- /dev/null >+++ b/Koha/Review.pm >@@ -0,0 +1,44 @@ >+package Koha::Review; >+ >+# 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::Review - Koha Review Object class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'Review'; >+} >+ >+1; >diff --git a/Koha/Reviews.pm b/Koha/Reviews.pm >new file mode 100644 >index 0000000..13b0314 >--- /dev/null >+++ b/Koha/Reviews.pm >@@ -0,0 +1,50 @@ >+package Koha::Reviews; >+ >+# 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::Review; >+ >+use base qw(Koha::Objects); >+ >+=head1 NAME >+ >+Koha::Reviews - Koha Review Object set class >+ >+=head1 API >+ >+=head2 Class Methods >+ >+=cut >+ >+=head3 type >+ >+=cut >+ >+sub _type { >+ return 'Review'; >+} >+ >+sub object_class { >+ return 'Koha::Review'; >+} >+ >+1; >diff --git a/t/db_dependent/Koha/Reviews.t b/t/db_dependent/Koha/Reviews.t >new file mode 100644 >index 0000000..321a536 >--- /dev/null >+++ b/t/db_dependent/Koha/Reviews.t >@@ -0,0 +1,66 @@ >+#!/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::Review; >+use Koha::Reviews; >+use Koha::Database; >+ >+use t::lib::TestBuilder; >+ >+my $schema = Koha::Database->new->schema; >+$schema->storage->txn_begin; >+ >+my $builder = t::lib::TestBuilder->new; >+my $patron_1 = $builder->build({ source => 'Borrower' }); >+my $patron_2 = $builder->build({ source => 'Borrower' }); >+my $biblio_1 = $builder->build({ source => 'Biblio' }); >+my $biblio_2 = $builder->build({ source => 'Biblio' }); >+my $nb_of_reviews = Koha::Reviews->search->count; >+my $new_review_1_1 = Koha::Review->new({ >+ borrowernumber => $patron_1->{borrowernumber}, >+ biblionumber => $biblio_1->{biblionumber}, >+ review => 'a kind review', >+})->store; >+my $new_review_1_2 = Koha::Review->new({ >+ borrowernumber => $patron_1->{borrowernumber}, >+ biblionumber => $biblio_2->{biblionumber}, >+ review => 'anoter kind review', >+})->store; >+my $new_review_2_1 = Koha::Review->new({ >+ borrowernumber => $patron_2->{borrowernumber}, >+ biblionumber => $biblio_1->{biblionumber}, >+ review => 'just anoter review', >+})->store; >+ >+like( $new_review_1_1->reviewid, qr|^\d+$|, 'Adding a new review should have set the reviewid'); >+is( Koha::Reviews->search->count, $nb_of_reviews + 3, 'The 3 reviews should have been added' ); >+ >+my $retrieved_review_1_1 = Koha::Reviews->find( $new_review_1_1->reviewid ); >+is( $retrieved_review_1_1->review, $new_review_1_1->review, 'Find a review by id should return the correct review' ); >+ >+$retrieved_review_1_1->delete; >+is( Koha::Reviews->search->count, $nb_of_reviews + 2, 'Delete should have deleted the review' ); >+ >+$schema->storage->txn_rollback; >+ >+1; >-- >2.7.0
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 15839
:
48166
|
48167
|
48168
|
48169
|
48170
|
48171
|
48172
|
48173
|
48174
|
48175
|
48176
|
48280
|
48281
|
48282
|
48283
|
48284
|
48285
|
48286
|
48287
|
48288
|
48289
|
48290
|
51197
|
51198
|
51199
|
51200
|
51201
|
51202
|
51203
|
51204
|
51205
|
51206
|
51207
|
53794
|
53795
|
53796
|
53797
|
53798
|
53799
|
53800
|
53801
|
53802
|
53803
|
53804
|
53805
|
53806
|
53807