warn "Exiting anonymize: patron ".$self->borrowernumber." still has issues";
return;
}
- my $mandatory = { map { (lc $_, 1); }
+ # Mandatory fields come from the corresponding pref, but email fields
+ # are removed since scrambled email addresses only generate errors
+ my $mandatory = { map { (lc $_, 1); } grep { !/email/ }
split /\s*\|\s*/, C4::Context->preference('BorrowerMandatoryField') };
$mandatory->{userid} = 1; # needed since sub store does not clear field
my @columns = $self->_result->result_source->columns;
};
subtest 'anonymize' => sub {
- plan tests => 9;
+ plan tests => 10;
my $patron1 = $builder->build_object( { class => 'Koha::Patrons' } );
my $patron2 = $builder->build_object( { class => 'Koha::Patrons' } );
isnt( $patron1->surname, $surname, 'Surname changed' );
ok( $patron1->surname =~ /^\w{10}$/, 'Mandatory surname randomized' );
is( $patron1->branchcode, $branchcode, 'Branch code skipped' );
+ is( $patron1->email, undef, 'Email was mandatory, must be cleared' );
# Test wrapper in Koha::Patrons
$patron1->surname($surname)->store; # restore