Bugzilla – Attachment 100812 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), 4.68 KB, created by
Jonathan Druart
on 2020-03-16 18:16:06 UTC
(
hide
)
Description:
Bug 23591: Add some useful methods to Koha::Suggestions
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-03-16 18:16:06 UTC
Size:
4.68 KB
patch
obsolete
>From 592b3d08058e0b7b4e9f52ea21cb8c8248ede8dc 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 > >Those are methods initially written for bug 23991. I finally need them >before than expected. >--- > Koha/Suggestion.pm | 62 +++++++++++++++++++++++++++++- > t/db_dependent/Koha/Suggestions.t | 63 ++++++++++++++++++++++++++++++- > 2 files changed, 121 insertions(+), 4 deletions(-) > >diff --git a/Koha/Suggestion.pm b/Koha/Suggestion.pm >index 320369161d..f9f8c2a490 100644 >--- a/Koha/Suggestion.pm >+++ b/Koha/Suggestion.pm >@@ -71,9 +71,67 @@ sub suggester { > return Koha::Patron->_new_from_dbic($suggester_rs); > } > >-=head2 Internal methods >+=head3 manager > >-=head3 _type >+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 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 480c387cb2..f4c4974548 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.20.1
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