View | Details | Raw Unified | Return to bug 26352
Collapse All | Expand All

(-)a/Koha/Patron.pm (-1 / +1 lines)
Lines 112-118 Autogenerate next cardnumber from highest value found in database Link Here
112
sub fixup_cardnumber {
112
sub fixup_cardnumber {
113
    my ( $self ) = @_;
113
    my ( $self ) = @_;
114
114
115
    my ( $max ) = Koha::Plugins->call( 'patron_barcode_transform', $self ) || undef;
115
    my ( $max ) = Koha::Plugins->call( 'patron_barcode_transform', $self->cardnumber ) || undef;
116
116
117
    $max ||= Koha::Patrons->search({
117
    $max ||= Koha::Patrons->search({
118
        cardnumber => {-regexp => '^-?[0-9]+$'}
118
        cardnumber => {-regexp => '^-?[0-9]+$'}
(-)a/t/db_dependent/Koha/Plugins/Barcode_transform_hooks.t (-5 / +20 lines)
Lines 42-48 t::lib::Mocks::mock_config( 'enable_plugins', 1 ); Link Here
42
42
43
subtest '() hook tests' => sub {
43
subtest '() hook tests' => sub {
44
44
45
    plan tests => 2;
45
    plan tests => 4;
46
46
47
    $schema->storage->txn_begin;
47
    $schema->storage->txn_begin;
48
48
Lines 51-62 subtest '() hook tests' => sub { Link Here
51
51
52
    my $plugin = Koha::Plugin::Test->new->enable;
52
    my $plugin = Koha::Plugin::Test->new->enable;
53
53
54
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
54
    my $patron = $builder->build_object(
55
    my $cardnumber = $patron->cardnumber;
55
        { class => 'Koha::Patrons', value => { cardnumber => undef } } );
56
56
57
    t::lib::Mocks::mock_preference( 'autoMemberNum', 1 );
58
    warnings_like { $patron->store(); }
59
    [
60
        qr/patron_barcode_transform called with parameter: /,
61
        qr/patron_barcode_transform called with parameter: /
62
    ],
63
    'Koha::Patron::store calls the patron_barcode_transform hook twice when autoMemberNum is enabled and cardnumber is undefined';
64
65
    $patron->cardnumber('TEST');
66
    warning_like { $patron->store(); }
67
        qr/patron_barcode_transform called with parameter: TEST/,
68
        'Koha::Patron::store calls the patron_barcode_transform hook once when autoMemberNum is enabled and cardnumber is set';
69
70
    t::lib::Mocks::mock_preference( 'autoMemberNum', 0 );
71
    $patron->cardnumber(undef);
57
    warning_like { $patron->store(); }
72
    warning_like { $patron->store(); }
58
        qr/patron_barcode_transform called with parameter: $cardnumber/,
73
        qr/patron_barcode_transform called with parameter: /,
59
        'Koha::Patron::store calls the patron_barcode_transform hook';
74
        'Koha::Patron::store calls the patron_barcode_transform hook once when autoMemberNum is disabled and cardnumber is undefined';
60
75
61
    t::lib::Mocks::mock_userenv(
76
    t::lib::Mocks::mock_userenv(
62
        {
77
        {
(-)a/t/lib/Koha/Plugin/Test.pm (-1 / +1 lines)
Lines 100-105 sub item_barcode_transform { Link Here
100
100
101
sub patron_barcode_transform {
101
sub patron_barcode_transform {
102
    my ( $self, $barcode ) = @_;
102
    my ( $self, $barcode ) = @_;
103
    $barcode //= '';
103
    Koha::Exceptions::Exception->throw("patron_barcode_transform called with parameter: $barcode");
104
    Koha::Exceptions::Exception->throw("patron_barcode_transform called with parameter: $barcode");
104
}
105
}
105
106
106
- 

Return to bug 26352