Koha/t/Members_Attributes.t
Jonathan Druart 38094a260e Bug 12267: Remove borrower_attributes.password
When creating a patron attribute type, there is a "Allow password"
checkbox. If checked, the librarian will be able to enter a password for
this patron attribute when editing a patron.
The goal was to allow a patron to log in with a secondary password.
However, this feature has never been implemented.

"""
commit 6fc62bcd32
  CommitDate: Mon May 12 09:03:00 2008 -0500
  extended patron attributes tables & syspref (DB rev 081)

- password_allowed (if set, staff patron editor will
  allow a password to be associated with a value; this
  is mostly a hook for functionality to be implemented
  in the future.
"""

To decrease maintainability, this patch suggest to remove the 2 DB fields
borrower_attributes.password and
borrower_attribute_types.password_allowed
If they have not used by the library.

Test plan:
- Edit a patron attribute type and select "allow password"
- Edit a patron and defined a password for this attribute
- Execute the DB entry
- Note that you get a warning
- Empty the password field
- Execute the DB entry
- You do not get the warning and the 2 DB fields have been removed

Signed-off-by: Marc Veron <veron@veron.ch>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
2016-04-22 23:08:32 +00:00

98 lines
3.9 KiB
Perl
Executable file

#!/usr/bin/perl
#
#
use strict;
use warnings;
use Test::More tests => 11;
BEGIN {
use_ok('C4::Members::Attributes', qw(:all));
}
INIT {
$C4::Members::Attributes::AttributeTypes = {
'grade' => {
'opac_display' => '1',
'staff_searchable' => '1',
'description' => 'Grade level',
'authorised_value_category' => '',
'repeatable' => '0',
'code' => 'grade',
'unique_id' => '0'
},
'deanslist' => {
'opac_display' => '0',
'staff_searchable' => '1',
'description' => 'Deans List (annual)',
'authorised_value_category' => '',
'repeatable' => '1',
'code' => 'deanslist',
'unique_id' => '0'
},
'somedata' => {
'opac_display' => '0',
'staff_searchable' => '0',
'description' => 'Some Ext. Attribute',
'authorised_value_category' => '',
'repeatable' => '0',
'code' => 'somedata',
'unique_id' => '0'
},
'extradata' => {
'opac_display' => '0',
'staff_searchable' => '0',
'description' => 'Another Ext. Attribute',
'authorised_value_category' => '',
'repeatable' => '0',
'code' => 'extradata',
'unique_id' => '0'
},
'school_id' => {
'opac_display' => '1',
'staff_searchable' => '1',
'description' => 'School ID Number',
'authorised_value_category' => '',
'repeatable' => '0',
'code' => 'school_id',
'unique_id' => '1'
},
'homeroom' => {
'opac_display' => '1',
'staff_searchable' => '1',
'description' => 'Homeroom',
'authorised_value_category' => '',
'repeatable' => '0',
'code' => 'homeroom',
'unique_id' => '0'
}
}; # This is important to prevent extended_attributes_merge from touching DB.
}
my @merge_tests = (
{
line1 => "homeroom:501",
line2 => "grade:01",
merge => "homeroom:501,grade:01",
},
{
line1 => "homeroom:224,grade:04,deanslist:2008,deanslist:2007,somedata:xxx",
line2 => "homeroom:115,grade:05,deanslist:2009,extradata:foobar",
merge => "homeroom:115,grade:05,deanslist:2008,deanslist:2007,deanslist:2009,extradata:foobar,somedata:xxx",
},
);
can_ok('C4::Members::Attributes', qw(extended_attributes_merge extended_attributes_code_value_arrayref));
ok(ref($C4::Members::Attributes::AttributeTypes) eq 'HASH', '$C4::Members::Attributes::AttributeTypes is a hashref');
foreach my $test (@merge_tests) {
my ($old, $new, $merged);
ok($old = extended_attributes_code_value_arrayref($test->{line1}), "extended_attributes_code_value_arrayref('$test->{line1}')");
ok($new = extended_attributes_code_value_arrayref($test->{line2}), "extended_attributes_code_value_arrayref('$test->{line2}')");
ok($merged = extended_attributes_merge($old, $new), "extended_attributes_merge(\$old, \$new)");
ok($merged = extended_attributes_merge($old, $new, 1), "extended_attributes_merge(\$old, \$new, 1)");
}