Bugzilla – Attachment 186650 Details for
Bug 19871
Use new exceptions Koha::Exceptions::Object::DuplicateID and FKConstraint
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19871: (QA follow-up) Replace symbolic refs with proper mock object class
Bug-19871-QA-follow-up-Replace-symbolic-refs-with-.patch (text/plain), 2.17 KB, created by
Martin Renvoize (ashimema)
on 2025-09-21 15:15:16 UTC
(
hide
)
Description:
Bug 19871: (QA follow-up) Replace symbolic refs with proper mock object class
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2025-09-21 15:15:16 UTC
Size:
2.17 KB
patch
obsolete
>From 6ec185abbe2827c0ab050125500853274e607f32 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@openfifth.co.uk> >Date: Sun, 21 Sep 2025 16:10:08 +0100 >Subject: [PATCH] Bug 19871: (QA follow-up) Replace symbolic refs with proper > mock object class > >Replace 'no strict refs' usage with a proper TestObject package to avoid >Perl::Critic violations while maintaining the same test functionality. > >The mock object now uses standard OOP patterns instead of symbolic >references for method creation. >--- > .../Koha/Schema/Util/ExceptionTranslator.t | 27 ++++++++++++------- > 1 file changed, 18 insertions(+), 9 deletions(-) > >diff --git a/t/db_dependent/Koha/Schema/Util/ExceptionTranslator.t b/t/db_dependent/Koha/Schema/Util/ExceptionTranslator.t >index 0a978a4124d..3e3626bd7d5 100755 >--- a/t/db_dependent/Koha/Schema/Util/ExceptionTranslator.t >+++ b/t/db_dependent/Koha/Schema/Util/ExceptionTranslator.t >@@ -149,19 +149,28 @@ subtest 'enum_truncation_with_object_value' => sub { > > $schema->storage->txn_begin; > >- # Create a mock object with a property accessor >- my $mock_object = bless { test_enum => 'invalid_value' }, 'TestObject'; >+ # Create a mock object class with proper methods >+ package TestObject { > >- # Add the can method to simulate a real object >- { >- no strict 'refs'; >- *{"TestObject::can"} = sub { >+ sub new { >+ my ( $class, %args ) = @_; >+ return bless \%args, $class; >+ } >+ >+ sub can { > my ( $self, $method ) = @_; >- return $method eq 'test_enum' ? sub { return $self->{test_enum} } : undef; >- }; >- *{"TestObject::test_enum"} = sub { return $_[0]->{test_enum} }; >+ return $method eq 'test_enum' ? \&test_enum : undef; >+ } >+ >+ sub test_enum { >+ my ($self) = @_; >+ return $self->{test_enum}; >+ } > } > >+ # Create a mock object with a property accessor >+ my $mock_object = TestObject->new( test_enum => 'invalid_value' ); >+ > # Create a mock DBIx::Class::Exception for enum data truncation > my $exception = bless { msg => "Data truncated for column 'test_enum'" }, 'DBIx::Class::Exception'; > >-- >2.51.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 19871
:
186634
|
186635
|
186644
|
186645
|
186646
|
186647
|
186648
|
186649
| 186650