Bugzilla – Attachment 50614 Details for
Bug 16331
TestBuilder does not allow undef/NULL values
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 16331: TestBuilder - Allow undef/NULL as a valid value
Bug-16331-TestBuilder---Allow-undefNULL-as-a-valid.patch (text/plain), 2.04 KB, created by
Jonathan Druart
on 2016-04-25 09:07:47 UTC
(
hide
)
Description:
Bug 16331: TestBuilder - Allow undef/NULL as a valid value
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-04-25 09:07:47 UTC
Size:
2.04 KB
patch
obsolete
>From 232267e81db31a11d73be43e68ce822c96921cbd Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Sun, 24 Apr 2016 17:05:01 +0100 >Subject: [PATCH] Bug 16331: TestBuilder - Allow undef/NULL as a valid value > >When building new entities with TestBuilder, sometimes we would like to >assign undef to a value. >See bug 16276 patch 4 - Change to GetBorrowersToExpunge to take >last_seen into account for a use case. > >Test plan: >Confirm that the TestBuilder tests still pass >--- > t/db_dependent/TestBuilder.t | 5 ++++- > t/lib/TestBuilder.pm | 4 ++-- > 2 files changed, 6 insertions(+), 3 deletions(-) > >diff --git a/t/db_dependent/TestBuilder.t b/t/db_dependent/TestBuilder.t >index a3cb813..f7c34a4 100644 >--- a/t/db_dependent/TestBuilder.t >+++ b/t/db_dependent/TestBuilder.t >@@ -19,7 +19,7 @@ > > use Modern::Perl; > >-use Test::More tests => 41; >+use Test::More tests => 42; > > use Koha::Database; > >@@ -274,6 +274,9 @@ subtest 'Auto-increment values tests' => sub { > > }; > >+my $patron = $builder->build({ source => 'Borrower', value => { guarantorid => undef } }); >+is( $patron->{guarantorid}, undef, 'TestBuilder should not populate a value the dev would like to keep undef' ); >+ > $schema->storage->txn_rollback; > > 1; >diff --git a/t/lib/TestBuilder.pm b/t/lib/TestBuilder.pm >index 254af61..4ade849 100644 >--- a/t/lib/TestBuilder.pm >+++ b/t/lib/TestBuilder.pm >@@ -111,7 +111,7 @@ sub build { > if( ref( $col_values->{$col_name} ) eq 'HASH' ) { > $fk_value = $col_values->{$col_name}; > } >- elsif( defined( $col_values->{$col_name} ) ) { >+ elsif( exists $col_values->{$col_name} ) { > next; > } > >@@ -166,7 +166,7 @@ sub _buildColumnValues { > column_name => $col_name, > value => $original_value, > }); >- $col_values->{$col_name} = $col_value if( defined( $col_value ) ); >+ $col_values->{$col_name} = $col_value if defined( $col_value ) or exists $original_value->{$col_name}; > } > $build_value = 0; > >-- >2.7.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 16331
: 50614