Bugzilla – Attachment 118598 Details for
Bug 27858
Make Koha::Patron::Attribute->store raise an exception on invalid type/code
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27858: Unit tests
Bug-27858-Unit-tests.patch (text/plain), 2.46 KB, created by
Joonas Kylmälä
on 2021-03-22 14:00:09 UTC
(
hide
)
Description:
Bug 27858: Unit tests
Filename:
MIME Type:
Creator:
Joonas Kylmälä
Created:
2021-03-22 14:00:09 UTC
Size:
2.46 KB
patch
obsolete
>From c8888eb62bf2b1925307b90c2a6b604d4f9ad04b Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Thu, 4 Mar 2021 08:23:09 -0300 >Subject: [PATCH] Bug 27858: Unit tests >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch introduces unit tests for the new exception to be thrown. >It generates a new extended attribute type, keeps the randomly generated >'code' and deletes the object. This way we can be sure the code doesn't >exist on the DB. It then tries to generate an attribute of that type, to >force the exception to be thrown. > >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Signed-off-by: Joonas Kylmälä <joonas.kylmala@helsinki.fi> >--- > t/db_dependent/Koha/Patron/Attribute.t | 39 +++++++++++++++++++++++++++++++++- > 1 file changed, 38 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Patron/Attribute.t b/t/db_dependent/Koha/Patron/Attribute.t >index f4bec78d4c..631279dbdf 100755 >--- a/t/db_dependent/Koha/Patron/Attribute.t >+++ b/t/db_dependent/Koha/Patron/Attribute.t >@@ -33,7 +33,7 @@ my $builder = t::lib::TestBuilder->new; > > subtest 'store() tests' => sub { > >- plan tests => 2; >+ plan tests => 3; > > subtest 'repeatable attributes tests' => sub { > >@@ -178,6 +178,43 @@ subtest 'store() tests' => sub { > > $schema->storage->txn_rollback; > }; >+ >+ subtest 'invalid type tests' => sub { >+ >+ plan tests => 2; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron = $builder->build_object({ class => 'Koha::Patrons' }); >+ my $attribute_type = $builder->build_object( >+ { >+ class => 'Koha::Patron::Attribute::Types', >+ value => { >+ unique_id => 0, >+ repeatable => 0 >+ } >+ } >+ ); >+ >+ my $code = $attribute_type->code; >+ $attribute_type->delete; >+ >+ throws_ok >+ { Koha::Patron::Attribute->new( >+ { >+ borrowernumber => $patron->borrowernumber, >+ code => $code, >+ attribute => 'Who knows' >+ >+ })->store; >+ } >+ 'Koha::Exceptions::Patron::Attribute::InvalidType', >+ 'Exception thrown on invalid attribute code'; >+ >+ is( $@->type, $code, 'type exception parameter passed' ); >+ >+ $schema->storage->txn_rollback; >+ }; > }; > > subtest 'type() tests' => sub { >-- >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 27858
:
117678
|
117679
|
117680
|
117713
|
117714
|
117715
|
118465
|
118596
|
118597
| 118598 |
118599
|
118600