[Koha-patches] [PATCH] Bug 16504: Add regression tests

Srdjan srdjan at catalyst.net.nz
Mon May 16 08:07:41 CEST 2016


From: Jonathan Druart <jonathan.druart at bugs.koha-community.org>

Signed-off-by: Srdjan <srdjan at catalyst.net.nz>
---
 t/db_dependent/Members/Attributes.t | 34 +++++++++++++++++++++++++++++++++-
 1 file changed, 33 insertions(+), 1 deletion(-)

diff --git a/t/db_dependent/Members/Attributes.t b/t/db_dependent/Members/Attributes.t
index f38ae41..e2ab1fe 100644
--- a/t/db_dependent/Members/Attributes.t
+++ b/t/db_dependent/Members/Attributes.t
@@ -25,7 +25,7 @@ use C4::Members::AttributeTypes;
 use Koha::Database;
 use t::lib::TestBuilder;
 
-use Test::More tests => 53;
+use Test::More tests => 55;
 
 use_ok('C4::Members::Attributes');
 
@@ -220,3 +220,35 @@ is( $borrower_attributes->[0]->{value}, $attributes->[1]->{value}, 'DeleteBorrow
 C4::Members::Attributes::DeleteBorrowerAttribute($borrowernumber, $attributes->[1]);
 $borrower_attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
 is( @$borrower_attributes, 1, 'DeleteBorrowerAttribute deletes a borrower attribute' );
+
+# Regression tests for bug 16504
+C4::Context->set_userenv(123, 'userid', 'usercnum', 'First name', 'Surname', $new_library->{branchcode}, 'My Library', 0);
+my $another_patron = $builder->build(
+    {   source => 'Borrower',
+        value  => {
+            firstname    => 'my another firstname',
+            surname      => 'my another surname',
+            categorycode => 'S',
+            branchcode => $new_library->{branchcode},
+        }
+    }
+);
+$attributes = [
+    {
+        value => 'my attribute1',
+        code => $attribute_type1->code(),
+    },
+    {
+        value => 'my attribute2',
+        code => $attribute_type2->code(),
+    },
+    {
+        value => 'my attribute limited',
+        code => $attribute_type_limited->code(),
+    }
+];
+C4::Members::Attributes::SetBorrowerAttributes($another_patron->{borrowernumber}, $attributes);
+$borrower_attributes = C4::Members::Attributes::GetBorrowerAttributes($another_patron->{borrowernumber});
+is( @$borrower_attributes, 3, 'SetBorrowerAttributes should have added the 3 attributes for another patron');
+$borrower_attributes = C4::Members::Attributes::GetBorrowerAttributes($borrowernumber);
+is( @$borrower_attributes, 1, 'SetBorrowerAttributes should not have removed the attributes of other patrons' );
-- 
2.7.4


More information about the Koha-patches mailing list