Lines 29-76
subtest 'Test Koha::Patrons::merge' => sub {
Link Here
|
29 |
plan tests => 4; |
29 |
plan tests => 4; |
30 |
my $builder = t::lib::TestBuilder->new; |
30 |
my $builder = t::lib::TestBuilder->new; |
31 |
|
31 |
|
32 |
my $keeper = $builder->build_object({ class => 'Koha::Patrons' }); |
32 |
my $keeper = $builder->build_object( { class => 'Koha::Patrons' } ); |
33 |
|
33 |
|
34 |
my $borrower1 = $builder->build({source => 'Borrower'}); |
34 |
my $borrower1 = $builder->build( { source => 'Borrower' } ); |
35 |
my $borrower2 = $builder->build({source => 'Borrower'}); |
35 |
my $borrower2 = $builder->build( { source => 'Borrower' } ); |
36 |
my $borrower3 = $builder->build({source => 'Borrower'}); |
36 |
my $borrower3 = $builder->build( { source => 'Borrower' } ); |
37 |
my $borrower4 = $builder->build({source => 'Borrower'}); |
37 |
my $borrower4 = $builder->build( { source => 'Borrower' } ); |
38 |
|
38 |
|
39 |
#test with BorrowersLog on |
39 |
#test with BorrowersLog on |
40 |
t::lib::Mocks::mock_preference('BorrowersLog', 1); |
40 |
t::lib::Mocks::mock_preference( 'BorrowersLog', 1 ); |
41 |
|
41 |
|
42 |
my $results = $keeper->merge_with([ $borrower1->{borrowernumber}, $borrower2->{borrowernumber} ]); |
42 |
my $results = $keeper->merge_with( [ $borrower1->{borrowernumber}, $borrower2->{borrowernumber} ] ); |
43 |
|
43 |
|
44 |
my $log=GetLogs("","","",["MEMBERS"],["PATRON_MERGE"],$keeper->id,""); |
44 |
my $log = GetLogs( "", "", "", ["MEMBERS"], ["PATRON_MERGE"], $keeper->id, "" ); |
45 |
|
45 |
|
46 |
my $info_borrower1 = $borrower1->{firstname} . " " . $borrower1->{surname} . " (" . $borrower1->{cardnumber} . ") has been merged into " . |
46 |
my $info_borrower1 = |
47 |
$keeper->firstname . " " . $keeper->surname . " (" . $keeper->cardnumber . ")"; |
47 |
$borrower1->{firstname} . " " |
|
|
48 |
. $borrower1->{surname} . " (" |
49 |
. $borrower1->{cardnumber} |
50 |
. ") has been merged into " |
51 |
. $keeper->firstname . " " |
52 |
. $keeper->surname . " (" |
53 |
. $keeper->cardnumber . ")"; |
48 |
my $info_log = $log->[0]{info}; |
54 |
my $info_log = $log->[0]{info}; |
49 |
|
55 |
|
50 |
is($info_log,$info_borrower1,"GetLogs returns results in the log viewer for the merge of " . $borrower1->{borrowernumber}); |
56 |
is( |
51 |
|
57 |
$info_log, $info_borrower1, |
52 |
my $info_borrower2 = $borrower2->{firstname} . " " . $borrower2->{surname} . " (" . $borrower2->{cardnumber} . ") has been merged into " . |
58 |
"GetLogs returns results in the log viewer for the merge of " . $borrower1->{borrowernumber} |
53 |
$keeper->firstname . " " . $keeper->surname . " (" . $keeper->cardnumber . ")"; |
59 |
); |
|
|
60 |
|
61 |
my $info_borrower2 = |
62 |
$borrower2->{firstname} . " " |
63 |
. $borrower2->{surname} . " (" |
64 |
. $borrower2->{cardnumber} |
65 |
. ") has been merged into " |
66 |
. $keeper->firstname . " " |
67 |
. $keeper->surname . " (" |
68 |
. $keeper->cardnumber . ")"; |
54 |
$info_log = $log->[1]{info}; |
69 |
$info_log = $log->[1]{info}; |
55 |
|
70 |
|
56 |
is($info_log,$info_borrower2,"GetLogs returns results in the log viewer for the merge of " . $borrower2->{borrowernumber}); |
71 |
is( |
57 |
|
72 |
$info_log, $info_borrower2, |
|
|
73 |
"GetLogs returns results in the log viewer for the merge of " . $borrower2->{borrowernumber} |
74 |
); |
58 |
|
75 |
|
59 |
#test with BorrowersLog off |
76 |
#test with BorrowersLog off |
60 |
t::lib::Mocks::mock_preference('BorrowersLog', 0); |
77 |
t::lib::Mocks::mock_preference( 'BorrowersLog', 0 ); |
61 |
|
78 |
|
62 |
$keeper = $builder->build_object({ class => 'Koha::Patrons' }); |
79 |
$keeper = $builder->build_object( { class => 'Koha::Patrons' } ); |
63 |
|
80 |
|
64 |
$results = $keeper->merge_with([ $borrower3->{borrowernumber}, $borrower4->{borrowernumber} ]); |
81 |
$results = $keeper->merge_with( [ $borrower3->{borrowernumber}, $borrower4->{borrowernumber} ] ); |
65 |
|
82 |
|
66 |
$log=GetLogs("","","",["MEMBERS"],["PATRON_MERGE"],$keeper->id,""); |
83 |
$log = GetLogs( "", "", "", ["MEMBERS"], ["PATRON_MERGE"], $keeper->id, "" ); |
67 |
$info_log = $log->[0]{info}; |
84 |
$info_log = $log->[0]{info}; |
68 |
|
85 |
|
69 |
is($info_log,undef,"GetLogs didn't returns results in the log viewer for the merge of " . $borrower3->{borrowernumber}); |
86 |
is( |
|
|
87 |
$info_log, undef, |
88 |
"GetLogs didn't returns results in the log viewer for the merge of " . $borrower3->{borrowernumber} |
89 |
); |
70 |
|
90 |
|
71 |
$info_log = $log->[1]{info}; |
91 |
$info_log = $log->[1]{info}; |
72 |
|
92 |
|
73 |
is($info_log,undef,"GetLogs didn't returns results in the log viewer for the merge of " . $borrower4->{borrowernumber}); |
93 |
is( |
|
|
94 |
$info_log, undef, |
95 |
"GetLogs didn't returns results in the log viewer for the merge of " . $borrower4->{borrowernumber} |
96 |
); |
74 |
}; |
97 |
}; |
75 |
|
98 |
|
76 |
$schema->storage->txn_rollback; |
99 |
$schema->storage->txn_rollback; |
77 |
- |
|
|