Bugzilla – Attachment 69857 Details for
Bug 19828
Koha::Object->store should catch DBIC exceptions and raise Koha::Exceptions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19828: Unit tests
Bug-19828-Unit-tests.patch (text/plain), 1.93 KB, created by
Tomás Cohen Arazi (tcohen)
on 2017-12-18 16:54:04 UTC
(
hide
)
Description:
Bug 19828: Unit tests
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2017-12-18 16:54:04 UTC
Size:
1.93 KB
patch
obsolete
>From feb232900b10a7d2331729801930f6a6f52c6a98 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 18 Dec 2017 13:47:53 -0300 >Subject: [PATCH] Bug 19828: Unit tests > >This patch introduces unit tests for the changes this bug introduces to >Koha::Object->store. > >To test: >- Apply this patch >- Run: > $ kshell > k$ prove t/db_dependent/Koha/Object.t >=> FAIL: Tests should fail because the changes are not implemented on this patch >--- > t/db_dependent/Koha/Object.t | 36 +++++++++++++++++++++++++++++++++++- > 1 file changed, 35 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Object.t b/t/db_dependent/Koha/Object.t >index 5f91415596..edc67ecc8c 100755 >--- a/t/db_dependent/Koha/Object.t >+++ b/t/db_dependent/Koha/Object.t >@@ -17,7 +17,8 @@ > > use Modern::Perl; > >-use Test::More tests => 9; >+use Test::More tests => 10; >+use Test::Exception; > use Test::Warn; > > use C4::Context; >@@ -218,3 +219,36 @@ subtest "Test update method" => sub { > > $schema->storage->txn_rollback; > }; >+ >+subtest 'store() tests' => sub { >+ >+ plan tests => 3; >+ >+ $schema->storage->txn_begin; >+ >+ # Create a category to make sure its ID doesn't exist on the DB >+ my $category = $builder->build_object({ class => 'Koha::Patron::Categories' }); >+ my $category_id = $category->id; >+ $category->delete; >+ >+ my $patron = Koha::Patron->new({ categorycode => $category_id }); >+ >+ my $print_error = $schema->storage->dbh->{PrintError}; >+ $schema->storage->dbh->{PrintError} = 0; >+ throws_ok >+ { $patron->store } >+ 'Koha::Exceptions::Object::FKConstraint', >+ 'Exception is thrown correctly'; >+ is( >+ $@->message, >+ "Broken FK constraint", >+ 'Exception message is correct' >+ ); >+ is( >+ $@->broken_fk, >+ 'categorycode', >+ 'Exception message is correct' >+ ); >+ $schema->storage->dbh->{PrintError} = $print_error; >+ $schema->storage->txn_rollback; >+}; >-- >2.14.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 19828
:
69857
|
69858
|
69907
|
69908
|
69963
|
69964
|
69965
|
70048
|
70049
|
70050
|
70097
|
70098
|
70099
|
70100