Bugzilla – Attachment 95600 Details for
Bug 23591
Add a new "Suggestions details" tab on bibliographic record
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23591: Add some useful methods to Koha::Suggestions
Bug-23591-Add-some-useful-methods-to-KohaSuggestio.patch (text/plain), 5.09 KB, created by
Séverine Queune
on 2019-11-20 10:06:41 UTC
(
hide
)
Description:
Bug 23591: Add some useful methods to Koha::Suggestions
Filename:
MIME Type:
Creator:
Séverine Queune
Created:
2019-11-20 10:06:41 UTC
Size:
5.09 KB
patch
obsolete
>From e763fbbc115231f0c342e471dae0370e3760da5e Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 18 Nov 2019 15:52:57 +0100 >Subject: [PATCH] Bug 23591: Add some useful methods to Koha::Suggestions >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Those are methods initially written for bug 23991. I finally need them >before than expected. > >Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr> >--- > Koha/Suggestion.pm | 75 +++++++++++++++++++++++++++++++++++++++ > t/db_dependent/Koha/Suggestions.t | 63 ++++++++++++++++++++++++++++++-- > 2 files changed, 136 insertions(+), 2 deletions(-) > >diff --git a/Koha/Suggestion.pm b/Koha/Suggestion.pm >index 2fef425..2acf958 100644 >--- a/Koha/Suggestion.pm >+++ b/Koha/Suggestion.pm >@@ -53,6 +53,81 @@ sub store { > return $self->SUPER::store(); > } > >+=head3 manager >+ >+my $manager = $suggestion->manager; >+ >+Returns the manager of the suggestion (Koha::Patron for managedby field) >+ >+=cut >+ >+sub manager { >+ my ($self) = @_; >+ my $manager_rs = $self->_result->managedby; >+ return unless $manager_rs; >+ return Koha::Patron->_new_from_dbic($manager_rs); >+} >+ >+=head3 suggester >+ >+my $suggester = $suggestion->suggester; >+ >+Returns the suggester of the suggestion (Koha::Patron for suggestedby field) >+ >+=cut >+ >+sub suggester { >+ my ($self) = @_; >+ my $suggester_rs = $self->_result->managedby; >+ return unless $suggester_rs; >+ return Koha::Patron->_new_from_dbic($suggester_rs); >+} >+ >+=head3 rejecter >+ >+my $rejecter = $suggestion->rejecter; >+ >+Returns the rejecter of the suggestion (Koha::Patron for rejectebby field) >+ >+=cut >+ >+sub rejecter { >+ my ($self) = @_; >+ my $rejecter_rs = $self->_result->managedby; >+ return unless $rejecter_rs; >+ return Koha::Patron->_new_from_dbic($rejecter_rs); >+} >+ >+=head3 last_modifier >+ >+my $last_modifier = $suggestion->last_modifier; >+ >+Returns the librarian who last modified the suggestion (Koha::Patron for lastmodificationby field) >+ >+=cut >+ >+sub last_modifier { >+ my ($self) = @_; >+ my $last_modifier_rs = $self->_result->managedby; >+ return unless $last_modifier_rs; >+ return Koha::Patron->_new_from_dbic($last_modifier_rs); >+} >+ >+=head3 fund >+ >+my $fund = $suggestion->fund; >+ >+Return the fund associated to the suggestion >+ >+=cut >+ >+sub fund { >+ my ($self) = @_; >+ my $fund_rs = $self->_result->budgetid; >+ return unless $fund_rs; >+ return Koha::Acquisition::Fund->_new_from_dbic($fund_rs); >+} >+ > =head3 type > > =cut >diff --git a/t/db_dependent/Koha/Suggestions.t b/t/db_dependent/Koha/Suggestions.t >index 480c387..c176790 100644 >--- a/t/db_dependent/Koha/Suggestions.t >+++ b/t/db_dependent/Koha/Suggestions.t >@@ -1,6 +1,6 @@ > #!/usr/bin/perl > >-# Copyright 2015 Koha Development team >+# Copyright 2015-2019 Koha Development team > # > # This file is part of Koha > # >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 6; >+use Test::More tests => 8; > use Test::Exception; > > use Koha::Suggestion; >@@ -171,3 +171,62 @@ subtest 'constraints' => sub { > $schema->storage->dbh->{PrintError} = $print_error; > $schema->storage->txn_rollback; > }; >+ >+subtest 'manager, suggester, rejecter, last_modifier' => sub { >+ plan tests => 8; >+ $schema->storage->txn_begin; >+ >+ my $suggestion = $builder->build_object( { class => 'Koha::Suggestions' } ); >+ >+ is( ref( $suggestion->manager ), >+ 'Koha::Patron', >+ '->manager should have returned a Koha::Patron object' ); >+ is( ref( $suggestion->rejecter ), >+ 'Koha::Patron', >+ '->rejecter should have returned a Koha::Patron object' ); >+ is( ref( $suggestion->suggester ), >+ 'Koha::Patron', >+ '->suggester should have returned a Koha::Patron object' ); >+ is( ref( $suggestion->last_modifier ), >+ 'Koha::Patron', >+ '->last_modifier should have returned a Koha::Patron object' ); >+ >+ $suggestion->set( >+ { >+ managedby => undef, >+ rejectedby => undef, >+ suggestedby => undef, >+ lastmodificationby => undef >+ } >+ ); >+ >+ is( $suggestion->manager, undef, >+ '->manager should have returned undef if no manager set' ); >+ is( $suggestion->rejecter, undef, >+ '->rejecter should have returned undef if no rejecter set' ); >+ is( $suggestion->suggester, undef, >+ '->suggester should have returned undef if no suggester set' ); >+ is( $suggestion->last_modifier, >+ undef, >+ '->last_modifier should have returned undef if no last_modifier set' ); >+ >+ $schema->storage->txn_rollback; >+}; >+ >+subtest 'fund' => sub { >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $suggestion = $builder->build_object( { class => 'Koha::Suggestions' } ); >+ is( ref( $suggestion->fund ), >+ 'Koha::Acquisition::Fund', >+ '->fund should have returned a Koha::Acquisition::Fund object' ); >+ >+ $suggestion->set( { budgetid => undef } ); >+ >+ is( $suggestion->fund, undef, >+ '->fund should have returned undef if not fund set' ); >+ >+ $schema->storage->txn_rollback; >+ } : >-- >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 23591
:
95518
|
95519
|
95520
|
95521
|
95579
|
95600
|
95601
|
95602
|
95603
|
95604
|
100812
|
100813
|
100814
|
100815
|
100816
|
102799
|
102800
|
102801
|
102850
|
102851
|
102852
|
102853
|
102854