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 1676-1682
subtest 'Test Koha::Patrons::merge' => sub {
Link Here
|
1676 |
is( Koha::Patrons->search( { borrowernumber => $keeper->id } )->count, 1, "Patron from attempted merge with AnonymousPatron still exists" ); |
1675 |
is( Koha::Patrons->search( { borrowernumber => $keeper->id } )->count, 1, "Patron from attempted merge with AnonymousPatron still exists" ); |
1677 |
|
1676 |
|
1678 |
subtest 'extended attributes' => sub { |
1677 |
subtest 'extended attributes' => sub { |
1679 |
plan tests => 5; |
1678 |
plan tests => 8; |
1680 |
|
1679 |
|
1681 |
my $keep_patron = |
1680 |
my $keep_patron = |
1682 |
$builder->build_object( { class => 'Koha::Patrons' } ); |
1681 |
$builder->build_object( { class => 'Koha::Patrons' } ); |
Lines 1763-1769
subtest 'Test Koha::Patrons::merge' => sub {
Link Here
|
1763 |
$keep_patron->delete; |
1762 |
$keep_patron->delete; |
1764 |
$merge_patron->delete; |
1763 |
$merge_patron->delete; |
1765 |
|
1764 |
|
1766 |
# Recreate but expect an exception because 2 "normal" attributes will be in the resulting patron |
1765 |
# Recreate but don't expect an exception if 2 non-repeatable attributes exist, pick the one from the patron we keep |
1767 |
$keep_patron = |
1766 |
$keep_patron = |
1768 |
$builder->build_object( { class => 'Koha::Patrons' } ); |
1767 |
$builder->build_object( { class => 'Koha::Patrons' } ); |
1769 |
$merge_patron = |
1768 |
$merge_patron = |
Lines 1780-1790
subtest 'Test Koha::Patrons::merge' => sub {
Link Here
|
1780 |
] |
1779 |
] |
1781 |
); |
1780 |
); |
1782 |
|
1781 |
|
1783 |
throws_ok { |
1782 |
$keep_patron->merge_with( [ $merge_patron->borrowernumber ] ); |
1784 |
$keep_patron->merge_with( [ $merge_patron->borrowernumber ] ); |
1783 |
$merged_attributes = $keep_patron->extended_attributes; |
1785 |
} |
1784 |
is( $merged_attributes->count, 4 ); |
1786 |
'Koha::Exceptions::Patron::Attribute::NonRepeatable', |
1785 |
compare_attributes( |
1787 |
'Exception thrown trying to merge several non-repeatable attributes'; |
1786 |
$merged_attributes, |
|
|
1787 |
['from attr 1'], |
1788 |
$attribute_type_normal_1->code |
1789 |
); |
1790 |
compare_attributes( |
1791 |
$merged_attributes, |
1792 |
['to attr 2'], |
1793 |
$attribute_type_normal_2->code |
1794 |
); |
1795 |
compare_attributes( |
1796 |
$merged_attributes, |
1797 |
[ 'from attr repeatable', 'to attr repeatable' ], |
1798 |
$attribute_type_repeatable->code |
1799 |
); |
1800 |
|
1788 |
}; |
1801 |
}; |
1789 |
|
1802 |
|
1790 |
t::lib::Mocks::mock_preference( 'AnonymousPatron', '' ); |
1803 |
t::lib::Mocks::mock_preference( 'AnonymousPatron', '' ); |
1791 |
- |
|
|