Bugzilla – Attachment 162416 Details for
Bug 28869
Optionally restrict authorised values to tinyint
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 28869: Unit tests
Bug-28869-Unit-tests.patch (text/plain), 3.80 KB, created by
Victor Grousset/tuxayo
on 2024-02-26 06:01:42 UTC
(
hide
)
Description:
Bug 28869: Unit tests
Filename:
MIME Type:
Creator:
Victor Grousset/tuxayo
Created:
2024-02-26 06:01:42 UTC
Size:
3.80 KB
patch
obsolete
>From 0aa3fe980cbcc3e1254e5c5c08aa9e29a874d921 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Tue, 30 Jan 2024 13:53:05 +0000 >Subject: [PATCH] Bug 28869: Unit tests > >Test plan: >Run t/db_dependent/AuthorisedValues.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> >--- > t/db_dependent/AuthorisedValues.t | 50 ++++++++++++++++++++++++++++++- > t/lib/TestBuilder.pm | 3 ++ > 2 files changed, 52 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/AuthorisedValues.t b/t/db_dependent/AuthorisedValues.t >index 368e9e9186..02fcbc5ac8 100755 >--- a/t/db_dependent/AuthorisedValues.t >+++ b/t/db_dependent/AuthorisedValues.t >@@ -1,7 +1,8 @@ > #!/usr/bin/perl > > use Modern::Perl; >-use Test::More tests => 16; >+use Test::More tests => 17; >+use Test::Exception; > use Try::Tiny; > > use t::lib::TestBuilder; >@@ -11,6 +12,7 @@ use C4::Context; > use Koha::AuthorisedValue; > use Koha::AuthorisedValues; > use Koha::AuthorisedValueCategories; >+use Koha::Exceptions; > use Koha::MarcSubfieldStructures; > > my $schema = Koha::Database->new->schema; >@@ -332,4 +334,50 @@ subtest 'search_by_*_field + find_by_koha_field + get_description + authorised_v > }; > }; > >+subtest 'is_integer_only' => sub { >+ plan tests => 13; >+ $schema->storage->txn_begin; >+ >+ my $avcat1 = $builder->build_object( { class => 'Koha::AuthorisedValueCategories' } ); >+ my $avcat2 = $builder->build_object( { class => 'Koha::AuthorisedValueCategories' } ); >+ $avcat2->is_integer_only(1)->store; >+ is( $avcat1->is_integer_only, 0, 'No numeric requirement expected' ); >+ is( $avcat2->is_integer_only, 1, 'Numeric requirement expected' ); >+ >+ my $avval1 = $builder->build_object( >+ { >+ class => 'Koha::AuthorisedValues', >+ value => { category => $avcat1->category_name, authorised_value => 'abc' } >+ } >+ ); >+ my $avval2 = $builder->build_object( >+ { >+ class => 'Koha::AuthorisedValues', >+ value => { category => $avcat2->category_name, authorised_value => '123' } >+ } >+ ); >+ >+ # Test helper method on child (authval) >+ is( $avval1->is_integer_only, 0, 'No numeric requirement expected' ); >+ is( $avval2->is_integer_only, 1, 'Numeric requirement expected' ); >+ >+ lives_ok { $avval2->authorised_value(-1)->store } 'No exception expected'; >+ lives_ok { $avval2->authorised_value(0)->store } 'No exception expected'; >+ lives_ok { $avval2->authorised_value(22)->store } 'No exception expected'; >+ >+ # Test ->store with bad data >+ throws_ok { $avval2->authorised_value(undef)->store } 'Koha::Exceptions::NoInteger', >+ 'Exception expected (undefined)'; >+ throws_ok { $avval2->authorised_value('')->store } 'Koha::Exceptions::NoInteger', 'Exception expected (empty)'; >+ throws_ok { $avval2->authorised_value('abc')->store } 'Koha::Exceptions::NoInteger', 'Exception expected for abc'; >+ throws_ok { $avval2->authorised_value('+12')->store } 'Koha::Exceptions::NoInteger', >+ 'Exception expected for + sign'; >+ throws_ok { $avval2->authorised_value(' 12')->store } 'Koha::Exceptions::NoInteger', >+ 'Exception expected for preceding space'; >+ throws_ok { $avval2->authorised_value('12 ')->store } 'Koha::Exceptions::NoInteger', >+ 'Exception expected for trailing space'; >+ >+ $schema->storage->txn_rollback; >+}; >+ > $schema->storage->txn_rollback; >diff --git a/t/lib/TestBuilder.pm b/t/lib/TestBuilder.pm >index 91fb518494..84b663fcac 100644 >--- a/t/lib/TestBuilder.pm >+++ b/t/lib/TestBuilder.pm >@@ -569,6 +569,9 @@ sub _gen_blob { > sub _gen_default_values { > my ($self) = @_; > return { >+ AuthorisedValueCategory => { >+ is_integer_only => 0, >+ }, > BackgroundJob => { > context => '{}' > }, >-- >2.44.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 28869
:
161745
|
161746
|
161747
|
161748
|
161749
|
162412
|
162413
|
162414
|
162415
|
162416
|
163996
|
163997
|
163998
|
163999
|
164000
|
164001
|
166697
|
166698
|
166699
|
166700
|
166701
|
166702
|
166906