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 1688-1694
subtest 'Test Koha::Patrons::merge' => sub {
Link Here
|
1688 |
is( Koha::Patrons->search( { borrowernumber => $keeper->id } )->count, 1, "Patron from attempted merge with AnonymousPatron still exists" ); |
1687 |
is( Koha::Patrons->search( { borrowernumber => $keeper->id } )->count, 1, "Patron from attempted merge with AnonymousPatron still exists" ); |
1689 |
|
1688 |
|
1690 |
subtest 'extended attributes' => sub { |
1689 |
subtest 'extended attributes' => sub { |
1691 |
plan tests => 5; |
1690 |
plan tests => 8; |
1692 |
|
1691 |
|
1693 |
my $keep_patron = |
1692 |
my $keep_patron = |
1694 |
$builder->build_object( { class => 'Koha::Patrons' } ); |
1693 |
$builder->build_object( { class => 'Koha::Patrons' } ); |
Lines 1775-1781
subtest 'Test Koha::Patrons::merge' => sub {
Link Here
|
1775 |
$keep_patron->delete; |
1774 |
$keep_patron->delete; |
1776 |
$merge_patron->delete; |
1775 |
$merge_patron->delete; |
1777 |
|
1776 |
|
1778 |
# Recreate but expect an exception because 2 "normal" attributes will be in the resulting patron |
1777 |
# Recreate but don't expect an exception if 2 non-repeatable attributes exist, pick the one from the patron we keep |
1779 |
$keep_patron = |
1778 |
$keep_patron = |
1780 |
$builder->build_object( { class => 'Koha::Patrons' } ); |
1779 |
$builder->build_object( { class => 'Koha::Patrons' } ); |
1781 |
$merge_patron = |
1780 |
$merge_patron = |
Lines 1792-1802
subtest 'Test Koha::Patrons::merge' => sub {
Link Here
|
1792 |
] |
1791 |
] |
1793 |
); |
1792 |
); |
1794 |
|
1793 |
|
1795 |
throws_ok { |
1794 |
$keep_patron->merge_with( [ $merge_patron->borrowernumber ] ); |
1796 |
$keep_patron->merge_with( [ $merge_patron->borrowernumber ] ); |
1795 |
$merged_attributes = $keep_patron->extended_attributes; |
1797 |
} |
1796 |
is( $merged_attributes->count, 4 ); |
1798 |
'Koha::Exceptions::Patron::Attribute::NonRepeatable', |
1797 |
compare_attributes( |
1799 |
'Exception thrown trying to merge several non-repeatable attributes'; |
1798 |
$merged_attributes, |
|
|
1799 |
['from attr 1'], |
1800 |
$attribute_type_normal_1->code |
1801 |
); |
1802 |
compare_attributes( |
1803 |
$merged_attributes, |
1804 |
['to attr 2'], |
1805 |
$attribute_type_normal_2->code |
1806 |
); |
1807 |
compare_attributes( |
1808 |
$merged_attributes, |
1809 |
[ 'from attr repeatable', 'to attr repeatable' ], |
1810 |
$attribute_type_repeatable->code |
1811 |
); |
1812 |
|
1800 |
}; |
1813 |
}; |
1801 |
|
1814 |
|
1802 |
t::lib::Mocks::mock_preference( 'AnonymousPatron', '' ); |
1815 |
t::lib::Mocks::mock_preference( 'AnonymousPatron', '' ); |
1803 |
- |
|
|