|
Lines 17-23
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 19; |
20 |
use Test::More tests => 27; |
| 21 |
|
21 |
|
| 22 |
use C4::Context; |
22 |
use C4::Context; |
| 23 |
use C4::Members; |
23 |
use C4::Members; |
|
Lines 98-103
my %jeanpaul_dupont = (
Link Here
|
| 98 |
userid => 'jeanpaul.dupont' |
98 |
userid => 'jeanpaul.dupont' |
| 99 |
); |
99 |
); |
| 100 |
|
100 |
|
|
|
101 |
my %dupont_brown = ( |
| 102 |
cardnumber => '567890', |
| 103 |
firstname => 'Dupont', |
| 104 |
surname => 'Brown', |
| 105 |
categorycode => $categorycode, |
| 106 |
branchcode => $branchcode, |
| 107 |
dateofbirth => '', |
| 108 |
dateexpiry => '9999-12-31', |
| 109 |
userid => 'dupont.brown' |
| 110 |
); |
| 111 |
|
| 101 |
$john_doe{borrowernumber} = AddMember( %john_doe ); |
112 |
$john_doe{borrowernumber} = AddMember( %john_doe ); |
| 102 |
warn "Error adding John Doe, check your tests" unless $john_doe{borrowernumber}; |
113 |
warn "Error adding John Doe, check your tests" unless $john_doe{borrowernumber}; |
| 103 |
$john_smith{borrowernumber} = AddMember( %john_smith ); |
114 |
$john_smith{borrowernumber} = AddMember( %john_smith ); |
|
Lines 106-111
$jane_doe{borrowernumber} = AddMember( %jane_doe );
Link Here
|
| 106 |
warn "Error adding Jane Doe, check your tests" unless $jane_doe{borrowernumber}; |
117 |
warn "Error adding Jane Doe, check your tests" unless $jane_doe{borrowernumber}; |
| 107 |
$jeanpaul_dupont{borrowernumber} = AddMember( %jeanpaul_dupont ); |
118 |
$jeanpaul_dupont{borrowernumber} = AddMember( %jeanpaul_dupont ); |
| 108 |
warn "Error adding Jean Paul Dupont, check your tests" unless $jeanpaul_dupont{borrowernumber}; |
119 |
warn "Error adding Jean Paul Dupont, check your tests" unless $jeanpaul_dupont{borrowernumber}; |
|
|
120 |
$dupont_brown{borrowernumber} = AddMember( %dupont_brown ); |
| 121 |
warn "Error adding Dupont Brown, check your tests" unless $dupont_brown{borrowernumber}; |
| 109 |
|
122 |
|
| 110 |
# Set common datatables params |
123 |
# Set common datatables params |
| 111 |
my %dt_params = ( |
124 |
my %dt_params = ( |
|
Lines 185-190
is( $search_results->{ patrons }[1]->{ cardnumber },
Link Here
|
| 185 |
$jane_doe{ cardnumber }, |
198 |
$jane_doe{ cardnumber }, |
| 186 |
"Jane Doe is the second result"); |
199 |
"Jane Doe is the second result"); |
| 187 |
|
200 |
|
|
|
201 |
# Search "Smith" as surname - there is only one occurrence of Smith |
| 202 |
$search_results = C4::Utils::DataTables::Members::search({ |
| 203 |
searchmember => "Smith", |
| 204 |
searchfieldstype => 'surname', |
| 205 |
searchtype => 'contain', |
| 206 |
branchcode => $branchcode, |
| 207 |
dt_params => \%dt_params |
| 208 |
}); |
| 209 |
|
| 210 |
is( $search_results->{ iTotalDisplayRecords }, 1, |
| 211 |
"There is one Smith at $branchcode when searching for surname"); |
| 212 |
|
| 213 |
is( $search_results->{ patrons }[0]->{ cardnumber }, |
| 214 |
$john_smith{ cardnumber }, |
| 215 |
"John Smith is the first result"); |
| 216 |
|
| 217 |
# Search "Dupont" as surname - Dupont is used both as firstname and surname, we |
| 218 |
# Should only fin d the user with Dupont as surname |
| 219 |
$search_results = C4::Utils::DataTables::Members::search({ |
| 220 |
searchmember => "Dupont", |
| 221 |
searchfieldstype => 'surname', |
| 222 |
searchtype => 'contain', |
| 223 |
branchcode => $branchcode, |
| 224 |
dt_params => \%dt_params |
| 225 |
}); |
| 226 |
|
| 227 |
is( $search_results->{ iTotalDisplayRecords }, 1, |
| 228 |
"There is one Dupont at $branchcode when searching for surname"); |
| 229 |
|
| 230 |
is( $search_results->{ patrons }[0]->{ cardnumber }, |
| 231 |
$jeanpaul_dupont{ cardnumber }, |
| 232 |
"Jean Paul Dupont is the first result"); |
| 233 |
|
| 234 |
# Search "Doe" as surname - Doe is used twice as surname |
| 235 |
$search_results = C4::Utils::DataTables::Members::search({ |
| 236 |
searchmember => "Doe", |
| 237 |
searchfieldstype => 'surname', |
| 238 |
searchtype => 'contain', |
| 239 |
branchcode => $branchcode, |
| 240 |
dt_params => \%dt_params |
| 241 |
}); |
| 242 |
|
| 243 |
is( $search_results->{ iTotalDisplayRecords }, 2, |
| 244 |
"There are two Doe at $branchcode when searching for surname"); |
| 245 |
|
| 246 |
is( $search_results->{ patrons }[0]->{ cardnumber }, |
| 247 |
$john_doe{ cardnumber }, |
| 248 |
"John Doe is the first result"); |
| 249 |
|
| 250 |
is( $search_results->{ patrons }[1]->{ cardnumber }, |
| 251 |
$jane_doe{ cardnumber }, |
| 252 |
"Jane Doe is the second result"); |
| 253 |
|
| 188 |
# Search by userid |
254 |
# Search by userid |
| 189 |
$search_results = C4::Utils::DataTables::Members::search({ |
255 |
$search_results = C4::Utils::DataTables::Members::search({ |
| 190 |
searchmember => "john.doe", |
256 |
searchmember => "john.doe", |
|
Lines 208-213
$search_results = C4::Utils::DataTables::Members::search({
Link Here
|
| 208 |
is( $search_results->{ iTotalDisplayRecords }, 1, |
274 |
is( $search_results->{ iTotalDisplayRecords }, 1, |
| 209 |
"John Doe is found by userid, userid search (Bug 14782)"); |
275 |
"John Doe is found by userid, userid search (Bug 14782)"); |
| 210 |
|
276 |
|
|
|
277 |
$search_results = C4::Utils::DataTables::Members::search({ |
| 278 |
searchmember => "john.doe", |
| 279 |
searchfieldstype => 'surname', |
| 280 |
searchtype => 'contain', |
| 281 |
branchcode => $branchcode, |
| 282 |
dt_params => \%dt_params |
| 283 |
}); |
| 284 |
|
| 285 |
is( $search_results->{ iTotalDisplayRecords }, 0, |
| 286 |
"No members are found by userid, surname search"); |
| 287 |
|
| 211 |
my $attribute_type = C4::Members::AttributeTypes->new( 'ATM_1', 'my attribute type' ); |
288 |
my $attribute_type = C4::Members::AttributeTypes->new( 'ATM_1', 'my attribute type' ); |
| 212 |
$attribute_type->{staff_searchable} = 1; |
289 |
$attribute_type->{staff_searchable} = 1; |
| 213 |
$attribute_type->store; |
290 |
$attribute_type->store; |
| 214 |
- |
|
|