Bugzilla – Attachment 96888 Details for
Bug 21684
Koha::Object[s]->delete methods must behave identically as the corresponding DBIx::Class ones
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 21684: Koha::Object->delete must return a Koha::Object
Bug-21684-KohaObject-delete-must-return-a-KohaObje.patch (text/plain), 3.43 KB, created by
Jonathan Druart
on 2020-01-07 12:31:40 UTC
(
hide
)
Description:
Bug 21684: Koha::Object->delete must return a Koha::Object
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2020-01-07 12:31:40 UTC
Size:
3.43 KB
patch
obsolete
>From 7affac7dd1e751f1907df8bda4b5a9eb21c323f2 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 7 Jan 2020 13:30:32 +0100 >Subject: [PATCH] Bug 21684: Koha::Object->delete must return a Koha::Object > >Not a DBIx::Class object. > >Tests have been added, add Bookseller.t fixed >--- > Koha/Object.pm | 7 ++++++- > t/db_dependent/Bookseller.t | 2 +- > t/db_dependent/Koha/Objects.t | 7 +++++-- > 3 files changed, 12 insertions(+), 4 deletions(-) > >diff --git a/Koha/Object.pm b/Koha/Object.pm >index 2139e070b3..589ea8c5d8 100644 >--- a/Koha/Object.pm >+++ b/Koha/Object.pm >@@ -216,7 +216,12 @@ Returns: > sub delete { > my ($self) = @_; > >- return $self->_result()->delete; >+ my $deleted = $self->_result()->delete; >+ if ( ref $deleted ) { >+ my $object_class = Koha::Object::_get_object_class( $self->_result->result_class ); >+ $deleted = $object_class->_new_from_dbic($deleted); >+ } >+ return $deleted; > } > > =head3 $object->set( $properties_hashref ) >diff --git a/t/db_dependent/Bookseller.t b/t/db_dependent/Bookseller.t >index c6f4c7fa24..ace46b86ed 100644 >--- a/t/db_dependent/Bookseller.t >+++ b/t/db_dependent/Bookseller.t >@@ -105,7 +105,7 @@ is( Koha::Acquisition::Booksellers->search()->count, > > #Test DelBookseller > my $del = $supplier1->delete; >-is( $del, 1, "DelBookseller returns 1 - 1 supplier has been deleted " ); >+is( ref($del), 'Koha::Acquisition::Bookseller', "DelBookseller returns the supplier object - supplier has been deleted " ); > my $b = Koha::Acquisition::Booksellers->find( $id_supplier1 ); > is( $b, > undef, "Supplier1 has been deleted - id_supplier1 $id_supplier1 doesnt exist anymore" ); >diff --git a/t/db_dependent/Koha/Objects.t b/t/db_dependent/Koha/Objects.t >index 43810fde02..f6a3ecd4e9 100644 >--- a/t/db_dependent/Koha/Objects.t >+++ b/t/db_dependent/Koha/Objects.t >@@ -345,7 +345,7 @@ subtest 'Return same values as DBIx::Class' => sub { > > subtest 'Koha::Object->delete' => sub { > >- plan tests => 4; >+ plan tests => 5; > > my ( $r_us, $e_us, $r_them, $e_them ); > >@@ -358,6 +358,7 @@ subtest 'Return same values as DBIx::Class' => sub { > 'Successful delete should return the object ' ); > ok( !defined $e_us && !defined $e_them, > 'Successful delete should not raise an exception' ); >+ is( ref($r_us), 'Koha::City', 'Successful delete should return our Koha::Obect based object' ); > > # CASE 2 - Delete an object that is not in storage > try { $r_us = $r_us->delete; } catch { $e_us = $_ }; >@@ -463,7 +464,7 @@ subtest 'Return same values as DBIx::Class' => sub { > > subtest 'Koha::Object->delete' => sub { > >- plan tests => 6; >+ plan tests => 7; > > my ( $r_us, $e_us, $r_them, $e_them ); > >@@ -480,6 +481,8 @@ subtest 'Return same values as DBIx::Class' => sub { > 'Successful delete should return the patron object' ); > ok( !defined $e_us && !defined $e_them, > 'Successful delete should not raise an exception' ); >+ is( ref($r_us), 'Koha::Patron', >+ 'Successful delete should return our Koha::Obect based object' ); > > # CASE 2 - Delete a patron that is not in storage > try { $r_us = $r_us->delete; } catch { $e_us = $_ }; >-- >2.11.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 21684
:
81317
|
81318
|
81319
|
90937
|
96218
|
96254
|
96270
|
96271
|
96272
|
96429
|
96430
|
96431
|
96872
| 96888 |
96895
|
96898