Bugzilla – Attachment 181590 Details for
Bug 32767
Optionally allow for trimming whitespace from patron attribute values
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32767: Add tests for the trims attributes feature
Bug-32767-Add-tests-for-the-trims-attributes-featu.patch (text/plain), 3.65 KB, created by
Peter Vashchuk
on 2025-04-28 11:20:14 UTC
(
hide
)
Description:
Bug 32767: Add tests for the trims attributes feature
Filename:
MIME Type:
Creator:
Peter Vashchuk
Created:
2025-04-28 11:20:14 UTC
Size:
3.65 KB
patch
obsolete
>From 2bb03b7a3043b2e1c874263d71f9faf880c990e6 Mon Sep 17 00:00:00 2001 >From: Petro Vashchuk <stalkernoid@gmail.com> >Date: Mon, 28 Apr 2025 14:18:56 +0300 >Subject: [PATCH] Bug 32767: Add tests for the trims attributes feature > >--- > t/db_dependent/Koha/Patron/Attribute.t | 75 +++++++++++++++++++++++++- > 1 file changed, 74 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Koha/Patron/Attribute.t b/t/db_dependent/Koha/Patron/Attribute.t >index 97015d0c217..4fd3189972a 100755 >--- a/t/db_dependent/Koha/Patron/Attribute.t >+++ b/t/db_dependent/Koha/Patron/Attribute.t >@@ -37,7 +37,7 @@ my $builder = t::lib::TestBuilder->new; > > subtest 'store() tests' => sub { > >- plan tests => 6; >+ plan tests => 7; > > subtest 'Update an attribute should update the patron "updated_on" field' => sub { > >@@ -282,6 +282,79 @@ subtest 'store() tests' => sub { > $schema->storage->txn_rollback; > }; > >+subtest 'trim identifier tests (Bug 32767)' => sub { >+ >+ plan tests => 5; >+ >+ $schema->storage->txn_begin; >+ >+ my $patron_1 = $builder->build( { source => 'Borrower' } )->{borrowernumber}; >+ my $patron_2 = $builder->build( { source => 'Borrower' } )->{borrowernumber}; >+ >+ my $attribute_type_1 = $builder->build( >+ { source => 'BorrowerAttributeType', >+ value => { unique_id => 1, trim_value => 0 } >+ } >+ ); >+ Koha::Patron::Attribute->new( >+ { borrowernumber => $patron_1, >+ code => $attribute_type_1->{code}, >+ attribute => '123' >+ } >+ )->store; >+ Koha::Patron::Attribute->new( >+ { borrowernumber => $patron_2, >+ code => $attribute_type_1->{code}, >+ attribute => ' 123' >+ } >+ )->store; >+ my $attr_count >+ = Koha::Patron::Attributes->search( >+ { code => $attribute_type_1->{code} } ) >+ ->count; >+ is( $attr_count, 2, >+ 'Two identical attributes stored and retrieved correctly because one of them had whitespace at the start' ); >+ >+ my $attribute_type_2 = $builder->build( >+ { source => 'BorrowerAttributeType', >+ value => { unique_id => 1, trim_value => 1 } >+ } >+ ); >+ >+ Koha::Patron::Attribute->new( >+ { borrowernumber => $patron_1, >+ code => $attribute_type_2->{code}, >+ attribute => '123' >+ } >+ )->store; >+ throws_ok { >+ Koha::Patron::Attribute->new( >+ { borrowernumber => $patron_2, >+ code => $attribute_type_2->{code}, >+ attribute => ' 123' >+ } >+ )->store; >+ } >+ 'Koha::Exceptions::Patron::Attribute::UniqueIDConstraint', >+ 'Exception thrown trying to store more than one unique attribute now that we enabled trim_value'; >+ >+ is( >+ "$@", >+ "Your action breaks a unique constraint on the attribute. type=" >+ . $attribute_type_2->{code} >+ . " value=123", >+ 'Exception stringified correctly, attribute passed correctly' >+ ); >+ >+ my $attributes = Koha::Patron::Attributes->search( >+ { borrowernumber => $patron_1, code => $attribute_type_2->{code} } ); >+ is( $attributes->count, 1, '1 unique attribute stored' ); >+ is( $attributes->next->attribute, >+ '123', 'our unique attribute remains unchanged' ); >+ >+ $schema->storage->txn_rollback; >+ }; >+ > subtest 'invalid type tests' => sub { > > plan tests => 2; >-- >2.49.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 32767
:
145846
|
151540
|
153651
|
153678
|
156985
|
159891
|
170815
|
181006
|
181007
|
181589
| 181590