Bugzilla – Attachment 104587 Details for
Bug 25423
Methods update and empty from Koha::Objects are not class methods
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 25423: Add Koha::Exceptions::Object::NotInstantiated
Bug-25423-Add-KohaExceptionsObjectNotInstantiated.patch (text/plain), 2.91 KB, created by
Tomás Cohen Arazi (tcohen)
on 2020-05-08 11:47:47 UTC
(
hide
)
Description:
Bug 25423: Add Koha::Exceptions::Object::NotInstantiated
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2020-05-08 11:47:47 UTC
Size:
2.91 KB
patch
obsolete
>From 4ae8a725f52c49fb0a6be19b8fd2106f10c8bd33 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 8 May 2020 08:39:10 -0300 >Subject: [PATCH] Bug 25423: Add Koha::Exceptions::Object::NotInstantiated > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > Koha/Exceptions/Object.pm | 8 ++++++++ > t/Koha/Exceptions.t | 24 +++++++++++++++++++++++- > 2 files changed, 31 insertions(+), 1 deletion(-) > >diff --git a/Koha/Exceptions/Object.pm b/Koha/Exceptions/Object.pm >index 53bd44ca90..688a97cd5a 100644 >--- a/Koha/Exceptions/Object.pm >+++ b/Koha/Exceptions/Object.pm >@@ -55,6 +55,11 @@ use Exception::Class ( > description => 'Invalid data passed', > fields => ['type', 'property', 'value'], > }, >+ 'Koha::Exceptions::Object::NotInstantiated' => { >+ isa => 'Koha::Exceptions::Object', >+ description => 'Tried to access a method on an uninstantiated object', >+ fields => ['class','method'] >+ }, > 'Koha::Exceptions::Object::NotInStorage' => { > isa => 'Koha::Exceptions::Object', > description => 'The object is not in storage yet', >@@ -76,6 +81,9 @@ sub full_message { > elsif ( $self->isa('Koha::Exceptions::Object::ReadOnlyProperty') ) { > $msg = sprintf("Invalid attempt to change readonly property: %s", $self->property ); > } >+ elsif ( $self->isa('Koha::Exceptions::Object::NotInstantiated') ) { >+ $msg = sprintf("Tried to access the '%s' method, but %s is not instantiated", $self->method, $self->class ); >+ } > } > > return $msg; >diff --git a/t/Koha/Exceptions.t b/t/Koha/Exceptions.t >index bb36df3496..a63de79b9b 100644 >--- a/t/Koha/Exceptions.t >+++ b/t/Koha/Exceptions.t >@@ -17,7 +17,7 @@ > > use Modern::Perl; > >-use Test::More tests => 5; >+use Test::More tests => 6; > use Test::MockObject; > use Test::Exception; > >@@ -176,3 +176,25 @@ subtest 'Koha::Exceptions::Patron::Relationship tests' => sub { > 'Exception is thrown :-D'; > is( "$@", 'Manual message exception', 'Exception not stringified if manually passed' ); > }; >+ >+subtest 'Koha::Exceptions::Object::NotInstantiated tests' => sub { >+ >+ plan tests => 5; >+ >+ use_ok('Koha::Exceptions::Object::NotInstantiated'); >+ >+ throws_ok >+ { Koha::Exceptions::Object::NotInstantiated->throw( >+ method => 'brain_explode', class => 'Koha::JD' ); } >+ 'Koha::Exceptions::Object::NotInstantiated', >+ 'Exception is thrown :-D'; >+ >+ # stringify the exception >+ is( "$@", 'Tried to access the \'brain_explode\' method, but Koha::JD is not instantiated', 'Exception stringified correctly' ); >+ >+ throws_ok >+ { Koha::Exceptions::Object::NotInstantiated->throw( "Manual message exception" ) } >+ 'Koha::Exceptions::Object::NotInstantiated', >+ 'Exception is thrown :-D'; >+ is( "$@", 'Manual message exception', 'Exception not stringified if manually passed' ); >+}; >-- >2.26.2
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 25423
:
104587
|
104588
|
104589
|
104590
|
104591
|
104592
|
104593
|
104594
|
104595
|
104596
|
104618