Lines 18-24
use t::lib::Mocks;
Link Here
|
18 |
use C4::AuthoritiesMarc; |
18 |
use C4::AuthoritiesMarc; |
19 |
use C4::Biblio; |
19 |
use C4::Biblio; |
20 |
use C4::Circulation; |
20 |
use C4::Circulation; |
|
|
21 |
use C4::Items; |
21 |
use Koha::Database; |
22 |
use Koha::Database; |
|
|
23 |
use Koha::SearchEngine::Elasticsearch; |
22 |
use Koha::SearchEngine::Indexer; |
24 |
use Koha::SearchEngine::Indexer; |
23 |
|
25 |
|
24 |
use t::lib::TestBuilder; |
26 |
use t::lib::TestBuilder; |
Lines 58-70
subtest 'Test indexer object creation' => sub {
Link Here
|
58 |
}; |
60 |
}; |
59 |
|
61 |
|
60 |
subtest 'Test indexer calls' => sub { |
62 |
subtest 'Test indexer calls' => sub { |
61 |
plan tests => 24; |
63 |
plan tests => 40; |
62 |
|
64 |
|
63 |
my @engines = ('Zebra'); |
65 |
my @engines = ('Zebra'); |
64 |
eval { Koha::SearchEngine::Elasticsearch->get_elasticsearch_params; }; |
66 |
eval { Koha::SearchEngine::Elasticsearch->get_elasticsearch_params; }; |
65 |
push @engines, 'Elasticsearch' unless $@; |
67 |
push @engines, 'Elasticsearch' unless $@; |
66 |
SKIP: { |
68 |
SKIP: { |
67 |
skip 'Elasticsearch configuration not available', 12 |
69 |
skip 'Elasticsearch configuration not available', 20 |
68 |
if scalar @engines == 1; |
70 |
if scalar @engines == 1; |
69 |
} |
71 |
} |
70 |
|
72 |
|
Lines 109-121
subtest 'Test indexer calls' => sub {
Link Here
|
109 |
my $item; |
111 |
my $item; |
110 |
my $item2; |
112 |
my $item2; |
111 |
warnings_are{ |
113 |
warnings_are{ |
112 |
$item = $builder->build_sample_item({biblionumber => $biblio->biblionumber}); |
114 |
$item = $builder->build_sample_item({ |
113 |
$item2 = $builder->build_sample_item({biblionumber => $biblio->biblionumber}); |
115 |
biblionumber => $biblio->biblionumber, |
|
|
116 |
onloan => '2020-02-02', |
117 |
datelastseen => '2020-01-01' |
118 |
}); |
119 |
$item2 = $builder->build_sample_item({ |
120 |
biblionumber => $biblio->biblionumber, |
121 |
onloan => '2020-12-12', |
122 |
datelastseen => '2020-11-11' |
123 |
}); |
114 |
} [$engine,"Koha::Item",$engine,"Koha::Item"], "index_records is called for $engine when adding an item (Item->store)"; |
124 |
} [$engine,"Koha::Item",$engine,"Koha::Item"], "index_records is called for $engine when adding an item (Item->store)"; |
115 |
warnings_are{ |
125 |
warnings_are{ |
116 |
$item->store({ skip_record_index => 1 }); |
126 |
$item->store({ skip_record_index => 1 }); |
117 |
} undef, "index_records is not called for $engine when adding an item (Item->store) if skip_record_index passed"; |
127 |
} undef, "index_records is not called for $engine when adding an item (Item->store) if skip_record_index passed"; |
118 |
|
128 |
|
|
|
129 |
my $issue = $builder->build({ |
130 |
source => 'Issue', |
131 |
value => { |
132 |
itemnumber => $item->itemnumber |
133 |
} |
134 |
}); |
135 |
my $issue2 = $builder->build({ |
136 |
source => 'Issue', |
137 |
value => { |
138 |
itemnumber => $item2->itemnumber |
139 |
} |
140 |
}); |
141 |
warnings_are{ |
142 |
MarkIssueReturned( $issue->{borrowernumber}, $item->itemnumber); |
143 |
} [$engine,"Koha::Item"], "index_records is called for $engine when calling MarkIssueReturned"; |
144 |
warnings_are{ |
145 |
MarkIssueReturned( $issue2->{borrowernumber}, $item2->itemnumber, undef, undef, { skip_record_index => 1}); |
146 |
} undef, "index_records is not called for $engine when calling MarkIssueReturned if skip_record_index passed"; |
147 |
|
148 |
warnings_are{ |
149 |
AddReturn($item->barcode, $item->homebranch, 0, undef); |
150 |
} [$engine,'C4::Circulation'], "index_records is called once for $engine when calling AddReturn if item not issued"; |
151 |
$issue = $builder->build({ |
152 |
source => 'Issue', |
153 |
value => { |
154 |
itemnumber => $item->itemnumber |
155 |
} |
156 |
}); |
157 |
warnings_are{ |
158 |
AddReturn($item->barcode, $item->homebranch, 0, undef); |
159 |
} [$engine,'C4::Circulation'], "index_records is called once for $engine when calling AddReturn if item not issued"; |
160 |
|
119 |
$builder->build({ |
161 |
$builder->build({ |
120 |
source => 'Branchtransfer', |
162 |
source => 'Branchtransfer', |
121 |
value => { |
163 |
value => { |
Lines 135-140
subtest 'Test indexer calls' => sub {
Link Here
|
135 |
LostItem( $item->itemnumber, "tests", undef, { skip_record_index => 1 }); |
177 |
LostItem( $item->itemnumber, "tests", undef, { skip_record_index => 1 }); |
136 |
} undef, "index_records is not called for $engine when calling LostItem and transfer exists if skip_record_index"; |
178 |
} undef, "index_records is not called for $engine when calling LostItem and transfer exists if skip_record_index"; |
137 |
|
179 |
|
|
|
180 |
$item->datelastseen('2020-02-02'); |
181 |
$item->store({skip_record_index=>1}); |
182 |
warnings_are{ |
183 |
my $t1 = ModDateLastSeen( $item->itemnumber, 1, undef ); |
184 |
} [$engine, "Koha::Item"], "index_records is called for $engine when calling ModDateLastSeen"; |
185 |
warnings_are{ |
186 |
ModDateLastSeen( $item->itemnumber, 1, { skip_record_index =>1 } ); |
187 |
} undef, "index_records is not called for $engine when calling ModDateLastSeen if skip_record_index"; |
188 |
|
189 |
warnings_are{ |
190 |
ModItemTransfer( $item->itemnumber, $item->homebranch, $item2->homebranch,'Manual'); |
191 |
} [$engine,"Koha::Item"], "index_records is called for $engine when calling ModItemTransfer"; |
192 |
warnings_are{ |
193 |
ModItemTransfer( $item->itemnumber, $item2->homebranch, $item->homebranch,'Manual',{skip_record_index=>1}); |
194 |
} undef, "index_records is not called for $engine when calling ModItemTransfer with skip_record_index"; |
195 |
|
138 |
warnings_are{ |
196 |
warnings_are{ |
139 |
$item->delete(); |
197 |
$item->delete(); |
140 |
} [$engine,"Koha::Item"], "index_records is called for $engine when deleting an item (Item->delete)"; |
198 |
} [$engine,"Koha::Item"], "index_records is called for $engine when deleting an item (Item->delete)"; |
141 |
- |
|
|