|
Lines 60-66
my $builder = t::lib::TestBuilder->new;
Link Here
|
| 60 |
my $schema = Koha::Database->schema; |
60 |
my $schema = Koha::Database->schema; |
| 61 |
|
61 |
|
| 62 |
subtest 'Search patrons' => sub { |
62 |
subtest 'Search patrons' => sub { |
| 63 |
plan tests => 26; |
63 |
plan tests => 27; |
| 64 |
|
64 |
|
| 65 |
if ( Koha::Patrons->search({surname => {-like => "test_patron_%"}})->count ) { |
65 |
if ( Koha::Patrons->search({surname => {-like => "test_patron_%"}})->count ) { |
| 66 |
BAIL_OUT("Cannot run this test, data we need to create already exist in the DB"); |
66 |
BAIL_OUT("Cannot run this test, data we need to create already exist in the DB"); |
|
Lines 141-147
subtest 'Search patrons' => sub {
Link Here
|
| 141 |
description => 'my description1', |
141 |
description => 'my description1', |
| 142 |
} |
142 |
} |
| 143 |
)->store; |
143 |
)->store; |
| 144 |
my $attribute_type_searchable = Koha::Patron::Attribute::Type->new( |
144 |
my $attribute_type_searchable_1 = Koha::Patron::Attribute::Type->new( |
| 145 |
{ |
145 |
{ |
| 146 |
code => 'my code2', |
146 |
code => 'my code2', |
| 147 |
description => 'my description2', |
147 |
description => 'my description2', |
|
Lines 149-161
subtest 'Search patrons' => sub {
Link Here
|
| 149 |
staff_searchable => 1 |
149 |
staff_searchable => 1 |
| 150 |
} |
150 |
} |
| 151 |
)->store; |
151 |
)->store; |
|
|
152 |
my $attribute_type_searchable_2 = Koha::Patron::Attribute::Type->new( |
| 153 |
{ |
| 154 |
code => 'my code3', |
| 155 |
description => 'my description3', |
| 156 |
opac_display => 1, |
| 157 |
staff_searchable => 1 |
| 158 |
} |
| 159 |
)->store; |
| 160 |
|
| 152 |
$patrons[0]->extended_attributes([ |
161 |
$patrons[0]->extended_attributes([ |
| 153 |
{ code => $attribute_type->code, attribute => 'test_attr_1' }, |
162 |
{ code => $attribute_type->code, attribute => 'test_attr_1' }, |
| 154 |
{ code => $attribute_type_searchable->code, attribute => 'test_attr_2'}, |
163 |
{ code => $attribute_type_searchable_1->code, attribute => 'test_attr_2'}, |
|
|
164 |
{ code => $attribute_type_searchable_2->code, attribute => 'yyy'}, |
| 155 |
]); |
165 |
]); |
| 156 |
$patrons[1]->extended_attributes([ |
166 |
$patrons[1]->extended_attributes([ |
| 157 |
{ code => $attribute_type->code, attribute => 'test_attr_1' }, |
167 |
{ code => $attribute_type->code, attribute => 'test_attr_1' }, |
| 158 |
{ code => $attribute_type_searchable->code, attribute => 'test_attr_2'}, |
168 |
{ code => $attribute_type_searchable_1->code, attribute => 'test_attr_2'}, |
|
|
169 |
{ code => $attribute_type_searchable_2->code, attribute => 'yyy'}, |
| 159 |
]); |
170 |
]); |
| 160 |
|
171 |
|
| 161 |
my $total_number_of_patrons = Koha::Patrons->search->count; |
172 |
my $total_number_of_patrons = Koha::Patrons->search->count; |
|
Lines 269-274
subtest 'Search patrons' => sub {
Link Here
|
| 269 |
# clear form |
280 |
# clear form |
| 270 |
$driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click(); |
281 |
$driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click(); |
| 271 |
|
282 |
|
|
|
283 |
$s->fill_form( { search_patron_filter => 'test_attr yyy' } ); # Terms must be split |
| 284 |
$s->submit_form; |
| 285 |
$s->wait_for_ajax; |
| 286 |
|
| 287 |
is( $driver->find_element('//div[@id="'.$table_id.'_info"]')->get_text, sprintf('Showing 1 to %s of %s entries (filtered from %s total entries)', 2, 2, $total_number_of_patrons), 'Searching on a searchable attribute returns correct results' ); |
| 288 |
|
| 289 |
# clear form |
| 290 |
$driver->find_element('//form[@id="patron_search_form"]//*[@id="clear_search"]')->click(); |
| 291 |
|
| 272 |
# Search on searchable attribute, we expect 2 patrons |
292 |
# Search on searchable attribute, we expect 2 patrons |
| 273 |
$s->fill_form( { search_patron_filter => 'test_attr_2' } ); |
293 |
$s->fill_form( { search_patron_filter => 'test_attr_2' } ); |
| 274 |
$s->submit_form; |
294 |
$s->submit_form; |
|
Lines 395-401
subtest 'Search patrons' => sub {
Link Here
|
| 395 |
push @cleanup, $library; |
415 |
push @cleanup, $library; |
| 396 |
push @cleanup, $library_2; |
416 |
push @cleanup, $library_2; |
| 397 |
push @cleanup, $patron_category; |
417 |
push @cleanup, $patron_category; |
| 398 |
push @cleanup, $attribute_type, $attribute_type_searchable; |
418 |
push @cleanup, $attribute_type, $attribute_type_searchable_1, $attribute_type_searchable_2; |
| 399 |
|
419 |
|
| 400 |
$driver->quit(); |
420 |
$driver->quit(); |
| 401 |
}; |
421 |
}; |
| 402 |
- |
|
|