Lines 18-23
use Test::More tests => 1;
Link Here
|
18 |
|
18 |
|
19 |
use C4::Log; |
19 |
use C4::Log; |
20 |
|
20 |
|
|
|
21 |
use Koha::ActionLogs; |
22 |
|
21 |
use t::lib::Mocks; |
23 |
use t::lib::Mocks; |
22 |
use t::lib::TestBuilder; |
24 |
use t::lib::TestBuilder; |
23 |
|
25 |
|
Lines 26-32
$schema->storage->txn_begin;
Link Here
|
26 |
|
28 |
|
27 |
subtest 'Test Koha::Patrons::merge' => sub { |
29 |
subtest 'Test Koha::Patrons::merge' => sub { |
28 |
|
30 |
|
29 |
plan tests => 4; |
31 |
plan tests => 3; |
30 |
my $builder = t::lib::TestBuilder->new; |
32 |
my $builder = t::lib::TestBuilder->new; |
31 |
|
33 |
|
32 |
my $keeper = $builder->build_object( { class => 'Koha::Patrons' } ); |
34 |
my $keeper = $builder->build_object( { class => 'Koha::Patrons' } ); |
Lines 41-47
subtest 'Test Koha::Patrons::merge' => sub {
Link Here
|
41 |
|
43 |
|
42 |
my $results = $keeper->merge_with( [ $borrower1->{borrowernumber}, $borrower2->{borrowernumber} ] ); |
44 |
my $results = $keeper->merge_with( [ $borrower1->{borrowernumber}, $borrower2->{borrowernumber} ] ); |
43 |
|
45 |
|
44 |
my $log = GetLogs( "", "", "", ["MEMBERS"], ["PATRON_MERGE"], $keeper->id, "" ); |
46 |
# Action logs records the merges under the 'object' of the kept borrowernumber |
|
|
47 |
my $logs = Koha::ActionLogs->search( |
48 |
{ |
49 |
module => "MEMBERS", |
50 |
action => "PATRON_MERGE", |
51 |
object => $keeper->id |
52 |
} |
53 |
); |
45 |
|
54 |
|
46 |
my $info_borrower1 = |
55 |
my $info_borrower1 = |
47 |
$borrower1->{firstname} . " " |
56 |
$borrower1->{firstname} . " " |
Lines 51-61
subtest 'Test Koha::Patrons::merge' => sub {
Link Here
|
51 |
. $keeper->firstname . " " |
60 |
. $keeper->firstname . " " |
52 |
. $keeper->surname . " (" |
61 |
. $keeper->surname . " (" |
53 |
. $keeper->cardnumber . ")"; |
62 |
. $keeper->cardnumber . ")"; |
54 |
my $info_log = $log->[0]{info}; |
63 |
my $info_log = $logs->next->info; |
55 |
|
64 |
|
56 |
is( |
65 |
is( |
57 |
$info_log, $info_borrower1, |
66 |
$info_log, $info_borrower1, |
58 |
"GetLogs returns results in the log viewer for the merge of " . $borrower1->{borrowernumber} |
67 |
"ActionLogs returns results for the merge of " |
|
|
68 |
. $borrower1->{borrowernumber} |
69 |
. " into " |
70 |
. $keeper->borrowernumber |
59 |
); |
71 |
); |
60 |
|
72 |
|
61 |
my $info_borrower2 = |
73 |
my $info_borrower2 = |
Lines 66-76
subtest 'Test Koha::Patrons::merge' => sub {
Link Here
|
66 |
. $keeper->firstname . " " |
78 |
. $keeper->firstname . " " |
67 |
. $keeper->surname . " (" |
79 |
. $keeper->surname . " (" |
68 |
. $keeper->cardnumber . ")"; |
80 |
. $keeper->cardnumber . ")"; |
69 |
$info_log = $log->[1]{info}; |
81 |
$info_log = $logs->next->info; |
70 |
|
82 |
|
71 |
is( |
83 |
is( |
72 |
$info_log, $info_borrower2, |
84 |
$info_log, $info_borrower2, |
73 |
"GetLogs returns results in the log viewer for the merge of " . $borrower2->{borrowernumber} |
85 |
"ActionLogs returns results in the log viewer for the merge of " |
|
|
86 |
. $borrower2->{borrowernumber} |
87 |
. " into " |
88 |
. $keeper->borrowernumber |
74 |
); |
89 |
); |
75 |
|
90 |
|
76 |
#test with BorrowersLog off |
91 |
#test with BorrowersLog off |
Lines 80-99
subtest 'Test Koha::Patrons::merge' => sub {
Link Here
|
80 |
|
95 |
|
81 |
$results = $keeper->merge_with( [ $borrower3->{borrowernumber}, $borrower4->{borrowernumber} ] ); |
96 |
$results = $keeper->merge_with( [ $borrower3->{borrowernumber}, $borrower4->{borrowernumber} ] ); |
82 |
|
97 |
|
83 |
$log = GetLogs( "", "", "", ["MEMBERS"], ["PATRON_MERGE"], $keeper->id, "" ); |
98 |
$logs = Koha::ActionLogs->search( |
84 |
$info_log = $log->[0]{info}; |
99 |
{ |
85 |
|
100 |
module => "MEMBERS", |
86 |
is( |
101 |
action => "PATRON_MERGE", |
87 |
$info_log, undef, |
102 |
object => $keeper->id |
88 |
"GetLogs didn't returns results in the log viewer for the merge of " . $borrower3->{borrowernumber} |
103 |
} |
89 |
); |
104 |
); |
90 |
|
105 |
|
91 |
$info_log = $log->[1]{info}; |
|
|
92 |
|
93 |
is( |
106 |
is( |
94 |
$info_log, undef, |
107 |
$logs->count, 0, |
95 |
"GetLogs didn't returns results in the log viewer for the merge of " . $borrower4->{borrowernumber} |
108 |
"Koha::ActionLogs didn't returns results in the log viewer for the merge of " . $borrower3->{borrowernumber} |
96 |
); |
109 |
); |
|
|
110 |
|
97 |
}; |
111 |
}; |
98 |
|
112 |
|
99 |
$schema->storage->txn_rollback; |
113 |
$schema->storage->txn_rollback; |
100 |
- |
|
|