Lines 26-32
use Test::MockModule;
Link Here
|
26 |
use Time::Fake; |
26 |
use Time::Fake; |
27 |
use DateTime; |
27 |
use DateTime; |
28 |
use JSON; |
28 |
use JSON; |
29 |
use Data::Dumper; |
|
|
30 |
use utf8; |
29 |
use utf8; |
31 |
|
30 |
|
32 |
use C4::Circulation qw( AddIssue AddReturn ); |
31 |
use C4::Circulation qw( AddIssue AddReturn ); |
Lines 1658-1664
subtest 'Test Koha::Patrons::merge' => sub {
Link Here
|
1658 |
is( Koha::Patrons->search( { borrowernumber => $keeper->id } )->count, 1, "Patron from attempted merge with AnonymousPatron still exists" ); |
1657 |
is( Koha::Patrons->search( { borrowernumber => $keeper->id } )->count, 1, "Patron from attempted merge with AnonymousPatron still exists" ); |
1659 |
|
1658 |
|
1660 |
subtest 'extended attributes' => sub { |
1659 |
subtest 'extended attributes' => sub { |
1661 |
plan tests => 5; |
1660 |
plan tests => 8; |
1662 |
|
1661 |
|
1663 |
my $keep_patron = |
1662 |
my $keep_patron = |
1664 |
$builder->build_object( { class => 'Koha::Patrons' } ); |
1663 |
$builder->build_object( { class => 'Koha::Patrons' } ); |
Lines 1745-1751
subtest 'Test Koha::Patrons::merge' => sub {
Link Here
|
1745 |
$keep_patron->delete; |
1744 |
$keep_patron->delete; |
1746 |
$merge_patron->delete; |
1745 |
$merge_patron->delete; |
1747 |
|
1746 |
|
1748 |
# Recreate but expect an exception because 2 "normal" attributes will be in the resulting patron |
1747 |
# Recreate but don't expect an exception if 2 non-repeatable attributes exist, pick the one from the patron we keep |
1749 |
$keep_patron = |
1748 |
$keep_patron = |
1750 |
$builder->build_object( { class => 'Koha::Patrons' } ); |
1749 |
$builder->build_object( { class => 'Koha::Patrons' } ); |
1751 |
$merge_patron = |
1750 |
$merge_patron = |
Lines 1762-1772
subtest 'Test Koha::Patrons::merge' => sub {
Link Here
|
1762 |
] |
1761 |
] |
1763 |
); |
1762 |
); |
1764 |
|
1763 |
|
1765 |
throws_ok { |
1764 |
$keep_patron->merge_with( [ $merge_patron->borrowernumber ] ); |
1766 |
$keep_patron->merge_with( [ $merge_patron->borrowernumber ] ); |
1765 |
$merged_attributes = $keep_patron->extended_attributes; |
1767 |
} |
1766 |
is( $merged_attributes->count, 4 ); |
1768 |
'Koha::Exceptions::Patron::Attribute::NonRepeatable', |
1767 |
compare_attributes( |
1769 |
'Exception thrown trying to merge several non-repeatable attributes'; |
1768 |
$merged_attributes, |
|
|
1769 |
['from attr 1'], |
1770 |
$attribute_type_normal_1->code |
1771 |
); |
1772 |
compare_attributes( |
1773 |
$merged_attributes, |
1774 |
['to attr 2'], |
1775 |
$attribute_type_normal_2->code |
1776 |
); |
1777 |
compare_attributes( |
1778 |
$merged_attributes, |
1779 |
[ 'from attr repeatable', 'to attr repeatable' ], |
1780 |
$attribute_type_repeatable->code |
1781 |
); |
1782 |
|
1770 |
}; |
1783 |
}; |
1771 |
|
1784 |
|
1772 |
t::lib::Mocks::mock_preference( 'AnonymousPatron', '' ); |
1785 |
t::lib::Mocks::mock_preference( 'AnonymousPatron', '' ); |
1773 |
- |
|
|