|
Lines 39-44
use Koha::Holds;
Link Here
|
| 39 |
use Koha::Old::Holds; |
39 |
use Koha::Old::Holds; |
| 40 |
use Koha::Patrons; |
40 |
use Koha::Patrons; |
| 41 |
use Koha::Old::Patrons; |
41 |
use Koha::Old::Patrons; |
|
|
42 |
use Koha::Patron::Attribute; |
| 43 |
use Koha::Patron::Attribute::Type; |
| 42 |
use Koha::Patron::Attribute::Types; |
44 |
use Koha::Patron::Attribute::Types; |
| 43 |
use Koha::Patron::Categories; |
45 |
use Koha::Patron::Categories; |
| 44 |
use Koha::Patron::Relationship; |
46 |
use Koha::Patron::Relationship; |
|
Lines 3764-3770
subtest 'filter_by_expired_opac_registrations' => sub {
Link Here
|
| 3764 |
|
3766 |
|
| 3765 |
subtest 'find_by_identifier() tests' => sub { |
3767 |
subtest 'find_by_identifier() tests' => sub { |
| 3766 |
|
3768 |
|
| 3767 |
plan tests => 7; |
3769 |
plan tests => 9; |
| 3768 |
|
3770 |
|
| 3769 |
$schema->storage->txn_begin; |
3771 |
$schema->storage->txn_begin; |
| 3770 |
|
3772 |
|
|
Lines 3804-3809
subtest 'find_by_identifier() tests' => sub {
Link Here
|
| 3804 |
$found_patron = Koha::Patrons->find_by_identifier(undef); |
3806 |
$found_patron = Koha::Patrons->find_by_identifier(undef); |
| 3805 |
is( $found_patron, undef, 'Returns undef for undef identifier' ); |
3807 |
is( $found_patron, undef, 'Returns undef for undef identifier' ); |
| 3806 |
|
3808 |
|
|
|
3809 |
# Test with unique attributes |
| 3810 |
my $unique_code = 'UA_' . int( rand(100000) ); |
| 3811 |
Koha::Patron::Attribute::Type->new( |
| 3812 |
{ |
| 3813 |
code => $unique_code, |
| 3814 |
description => 'Unique Attribute', |
| 3815 |
unique_id => 1, |
| 3816 |
repeatable => 0, |
| 3817 |
} |
| 3818 |
)->store; |
| 3819 |
|
| 3820 |
my $non_unique_code = 'NUA_' . int( rand(100000) ); |
| 3821 |
Koha::Patron::Attribute::Type->new( |
| 3822 |
{ |
| 3823 |
code => $non_unique_code, |
| 3824 |
description => 'Non-Unique Attribute', |
| 3825 |
unique_id => 0, |
| 3826 |
repeatable => 0, |
| 3827 |
} |
| 3828 |
)->store; |
| 3829 |
|
| 3830 |
my $patron_u = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 3831 |
my $val_u = 'VAL_U_' . int( rand(100000) ); |
| 3832 |
Koha::Patron::Attribute->new( |
| 3833 |
{ |
| 3834 |
borrowernumber => $patron_u->borrowernumber, |
| 3835 |
code => $unique_code, |
| 3836 |
attribute => $val_u, |
| 3837 |
} |
| 3838 |
)->store; |
| 3839 |
|
| 3840 |
my $patron_nu = $builder->build_object( { class => 'Koha::Patrons' } ); |
| 3841 |
my $val_nu = 'VAL_NU_' . int( rand(100000) ); |
| 3842 |
Koha::Patron::Attribute->new( |
| 3843 |
{ |
| 3844 |
borrowernumber => $patron_nu->borrowernumber, |
| 3845 |
code => $non_unique_code, |
| 3846 |
attribute => $val_nu, |
| 3847 |
} |
| 3848 |
)->store; |
| 3849 |
|
| 3850 |
$found_patron = Koha::Patrons->find_by_identifier($val_u); |
| 3851 |
is( $found_patron ? $found_patron->id : undef, $patron_u->id, 'Found patron by unique attribute' ); |
| 3852 |
|
| 3853 |
$found_patron = Koha::Patrons->find_by_identifier($val_nu); |
| 3854 |
is( $found_patron, undef, 'Did not find patron by non-unique attribute' ); |
| 3855 |
|
| 3807 |
$schema->storage->txn_rollback; |
3856 |
$schema->storage->txn_rollback; |
| 3808 |
}; |
3857 |
}; |
| 3809 |
|
3858 |
|
| 3810 |
- |
|
|