Bugzilla – Attachment 96270 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: Add tests to show some of the discrepancies
Bug-21684-Add-tests-to-show-some-of-the-discrepanc.patch (text/plain), 4.03 KB, created by
Nick Clemens (kidclamp)
on 2019-12-13 16:53:06 UTC
(
hide
)
Description:
Bug 21684: Add tests to show some of the discrepancies
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2019-12-13 16:53:06 UTC
Size:
4.03 KB
patch
obsolete
>From ce08c71bf1b5b374c3c38e89e2bce2418cafecd2 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Fri, 26 Oct 2018 13:54:47 -0300 >Subject: [PATCH] Bug 21684: Add tests to show some of the discrepancies > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > t/db_dependent/Koha/Objects.t | 97 +++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 97 insertions(+) > >diff --git a/t/db_dependent/Koha/Objects.t b/t/db_dependent/Koha/Objects.t >index 592ab40866..87efa3caea 100644 >--- a/t/db_dependent/Koha/Objects.t >+++ b/t/db_dependent/Koha/Objects.t >@@ -330,3 +330,100 @@ subtest "TO_JSON() tests" => sub { > > $schema->storage->txn_rollback; > }; >+ >+# Koha::Object[s] must behave the same as DBIx::Class >+subtest 'Return same values as DBIx::Class' => sub { >+ plan tests => 1; >+ >+ subtest 'Delete' => sub { >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ subtest 'Simple Koha::Objects - Koha::Cities' => sub { >+ plan tests => 3; >+ >+ my ( $r_us, $e_us, $r_them, $e_them ); >+ { >+ my $c = Koha::City->new({ city_name => 'city4test' }); >+ try {$r_us = $c->delete;} catch { $e_us = ref($_) }; >+ >+ >+ $c = $schema->resultset('City')->new({ city_name => 'city4test' }); >+ try {$r_them = $c->delete;} catch { $e_them = ref($_) }; >+ >+ is( $r_us, $r_them ); >+ is( $e_us, $e_them ); # FIXME This is need adjustment, we want to throw a Koha::Exception >+ } >+ >+ { >+ >+ my $city = $builder->build_object({ class => 'Koha::Cities' }); >+ try{ >+ $schema->storage->txn_do(sub{ >+ my $c = Koha::Cities->find($city->cityid); >+ $r_us = $c->delete; >+ $c->update({force_fail=>'foo'}); >+ });}; >+ try{ >+ $schema->storage->txn_do(sub{ >+ my $c = $schema->resultset('City')->find($city->cityid); >+ $r_them = $c->delete; >+ $c->update({force_fail=>'foo'}); >+ });}; >+ is( $r_us, $r_them ); >+ } >+ }; >+ >+ subtest 'Overwritten Koha::Objects->delete - Koha::Patrons' => sub { >+ plan tests => 4; >+ >+ my ( $r_us, $e_us, $r_them, $e_them ); >+ >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $patron_data = $patron->unblessed; >+ $patron->delete; >+ >+ { >+ my $p = Koha::Patron->new( $patron_data ); >+ try {$r_us = $p->delete;} catch { $e_us = ref($_) }; >+ >+ >+ $p = $schema->resultset('Borrower')->new( $patron_data ); >+ try {$r_them = $p->delete;} catch { $e_them = ref($_) }; >+ >+ is( $r_us, $r_them ); >+ is( $e_us, $e_them ); # FIXME This is need adjustment, we want to throw a Koha::Exception >+ } >+ >+ { >+ try { >+ $schema->storage->txn_do( >+ sub { >+ my $p = Koha::Patrons->find( $patron->borrowernumber ); >+ $r_us = $p->delete; >+ $p->update( { force_fail => 'foo' } ); >+ } >+ ); >+ }; >+ try { >+ $schema->storage->txn_do( >+ sub { >+ my $p = $schema->resultset('City')->find( $patron->borrowernumber ); >+ $r_them = $p->delete; >+ $p->update( { force_fail => 'foo' } ); >+ } >+ ); >+ }; >+ is( $r_us, $r_them ); >+ } >+ >+ # TODO Test value of Koha::Object->delete when the row cannot be deleted >+ >+ # TODO Add tests for Koha::Objects->delete >+ }; >+ >+ $schema->storage->txn_rollback; >+ >+ }; >+}; >-- >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