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

(-)a/Koha/Patron.pm (+23 lines)
Lines 43-48 use Koha::CurbsidePickups; Link Here
43
use Koha::Old::Checkouts;
43
use Koha::Old::Checkouts;
44
use Koha::Patron::Attributes;
44
use Koha::Patron::Attributes;
45
use Koha::Patron::Categories;
45
use Koha::Patron::Categories;
46
use Koha::Patron::Consents;
46
use Koha::Patron::Debarments;
47
use Koha::Patron::Debarments;
47
use Koha::Patron::HouseboundProfile;
48
use Koha::Patron::HouseboundProfile;
48
use Koha::Patron::HouseboundRole;
49
use Koha::Patron::HouseboundRole;
Lines 2247-2252 sub virtualshelves { Link Here
2247
    return Koha::Virtualshelves->_new_from_dbic( scalar $self->_result->virtualshelves );
2248
    return Koha::Virtualshelves->_new_from_dbic( scalar $self->_result->virtualshelves );
2248
}
2249
}
2249
2250
2251
=head3 consent
2252
2253
    my $consent = $patron->consent(TYPE);
2254
2255
    Returns the first consent of type TYPE (there should be only one) or a new instance
2256
    of Koha::Patron::Consent.
2257
2258
=cut
2259
2260
sub consent {
2261
    my ( $self, $type ) = @_;
2262
    Koha::Exceptions::MissingParameter->throw('Missing consent type')
2263
        if !$type;
2264
    my $consents = Koha::Patron::Consents->search({
2265
        borrowernumber => $self->borrowernumber,
2266
        type => $type,
2267
    });
2268
    return $consents && $consents->count
2269
        ? $consents->next
2270
        : Koha::Patron::Consent->new({ borrowernumber => $self->borrowernumber, type => $type });
2271
}
2272
2250
=head2 Internal methods
2273
=head2 Internal methods
2251
2274
2252
=head3 _type
2275
=head3 _type
(-)a/t/db_dependent/Koha/Patron.t (-2 / +19 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 19;
22
use Test::More tests => 20;
23
use Test::Exception;
23
use Test::Exception;
24
use Test::Warn;
24
use Test::Warn;
25
25
Lines 28-33 use Koha::Database; Link Here
28
use Koha::DateUtils qw(dt_from_string);
28
use Koha::DateUtils qw(dt_from_string);
29
use Koha::ArticleRequests;
29
use Koha::ArticleRequests;
30
use Koha::Patrons;
30
use Koha::Patrons;
31
use Koha::Patron::Consents;
31
use Koha::Patron::Relationships;
32
use Koha::Patron::Relationships;
32
33
33
use t::lib::TestBuilder;
34
use t::lib::TestBuilder;
Lines 1345-1350 subtest 'notify_library_of_registration()' => sub { Link Here
1345
    $to_address = $sth->fetchrow_array;
1346
    $to_address = $sth->fetchrow_array;
1346
    is( $to_address, 'root@localhost', 'OPAC_REG email queued to go to KohaAdminEmailAddress syspref when EmailPatronRegistration equals KohaAdminEmailAddress' );
1347
    is( $to_address, 'root@localhost', 'OPAC_REG email queued to go to KohaAdminEmailAddress syspref when EmailPatronRegistration equals KohaAdminEmailAddress' );
1347
    $dbh->do(q|DELETE FROM message_queue|);
1348
    $dbh->do(q|DELETE FROM message_queue|);
1349
    $schema->storage->txn_rollback;
1350
};
1351
1352
subtest 'test patron_consent' => sub {
1353
    plan tests => 4;
1354
    $schema->storage->txn_begin;
1355
1356
    my $patron = $builder->build_object({ class => 'Koha::Patrons' });
1357
    throws_ok { $patron->consent } 'Koha::Exceptions::MissingParameter', 'missing type';
1358
1359
    my $consent = $patron->consent('GDPR_PROCESSING');
1360
    is( ref $consent, 'Koha::Patron::Consent', 'return type check' );
1361
    $consent->given_on( '2021-02-03' )->store;
1362
    undef $consent;
1363
    is( $patron->consent('GDPR_PROCESSING')->given_on, '2021-02-03 00:00:00', 'check date' );
1364
1365
    is( $patron->consent('NOT_EXIST')->refused_on, undef, 'New empty object for new type' );
1348
1366
1349
    $schema->storage->txn_rollback;
1367
    $schema->storage->txn_rollback;
1350
};
1368
};
1351
- 

Return to bug 31503