|
Lines 17-32
Link Here
|
| 17 |
|
17 |
|
| 18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
| 19 |
|
19 |
|
| 20 |
use Test::More tests => 11; |
20 |
use Test::More tests => 13; |
| 21 |
|
21 |
|
| 22 |
use C4::Context; |
22 |
use C4::Context; |
| 23 |
use C4::Branch; |
23 |
use C4::Branch; |
| 24 |
use C4::Members; |
24 |
use C4::Members; |
| 25 |
|
25 |
|
|
|
26 |
use C4::Members::Attributes; |
| 27 |
use C4::Members::AttributeTypes; |
| 28 |
|
| 29 |
use t::lib::Mocks; |
| 30 |
|
| 26 |
use_ok( "C4::Utils::DataTables::Members" ); |
31 |
use_ok( "C4::Utils::DataTables::Members" ); |
| 27 |
|
32 |
|
| 28 |
my $dbh = C4::Context->dbh; |
33 |
my $dbh = C4::Context->dbh; |
| 29 |
my $res; |
|
|
| 30 |
|
34 |
|
| 31 |
# Start transaction |
35 |
# Start transaction |
| 32 |
$dbh->{AutoCommit} = 0; |
36 |
$dbh->{AutoCommit} = 0; |
|
Lines 83-94
my %jane_doe = (
Link Here
|
| 83 |
userid => 'jane.doe' |
87 |
userid => 'jane.doe' |
| 84 |
); |
88 |
); |
| 85 |
|
89 |
|
| 86 |
$res = AddMember( %john_doe ); |
90 |
$john_doe{borrowernumber} = AddMember( %john_doe ); |
| 87 |
warn "Error adding John Doe, check your tests" unless $res; |
91 |
warn "Error adding John Doe, check your tests" unless $john_doe{borrowernumber}; |
| 88 |
$res = AddMember( %john_smith ); |
92 |
$john_smith{borrowernumber} = AddMember( %john_smith ); |
| 89 |
warn "Error adding John Smith, check your tests" unless $res; |
93 |
warn "Error adding John Smith, check your tests" unless $john_smith{borrowernumber}; |
| 90 |
$res = AddMember( %jane_doe ); |
94 |
$jane_doe{borrowernumber} = AddMember( %jane_doe ); |
| 91 |
warn "Error adding Jane Doe, check your tests" unless $res; |
95 |
warn "Error adding Jane Doe, check your tests" unless $jane_doe{borrowernumber}; |
| 92 |
|
96 |
|
| 93 |
# Set common datatables params |
97 |
# Set common datatables params |
| 94 |
my %dt_params = ( |
98 |
my %dt_params = ( |
|
Lines 168-173
is( $search_results->{ patrons }[1]->{ cardnumber },
Link Here
|
| 168 |
$jane_doe{ cardnumber }, |
172 |
$jane_doe{ cardnumber }, |
| 169 |
"Jane Doe is the second result"); |
173 |
"Jane Doe is the second result"); |
| 170 |
|
174 |
|
|
|
175 |
my $attribute_type = C4::Members::AttributeTypes->new( 'ATM_1', 'my attribute type' ); |
| 176 |
$attribute_type->{staff_searchable} = 1; |
| 177 |
$attribute_type->store; |
| 178 |
|
| 179 |
|
| 180 |
C4::Members::Attributes::SetBorrowerAttributes( |
| 181 |
$john_doe{borrowernumber}, [ { code => $attribute_type->{code}, value => 'the default value for a common user' } ] |
| 182 |
); |
| 183 |
C4::Members::Attributes::SetBorrowerAttributes( |
| 184 |
$jane_doe{borrowernumber}, [ { code => $attribute_type->{code}, value => 'the default value for another common user' } ] |
| 185 |
); |
| 186 |
|
| 187 |
t::lib::Mocks::mock_preference('ExtendedPatronAttributes', 1); |
| 188 |
$search_results = C4::Utils::DataTables::Members::search({ |
| 189 |
searchmember => "common user", |
| 190 |
searchfieldstype => 'standard', |
| 191 |
searchtype => 'contains', |
| 192 |
branchcode => $branchcode, |
| 193 |
dt_params => \%dt_params |
| 194 |
}); |
| 195 |
|
| 196 |
is( $search_results->{ iTotalDisplayRecords}, 2, "There are 2 common users" ); |
| 197 |
|
| 198 |
t::lib::Mocks::mock_preference('ExtendedPatronAttributes', 0); |
| 199 |
$search_results = C4::Utils::DataTables::Members::search({ |
| 200 |
searchmember => "common user", |
| 201 |
searchfieldstype => 'standard', |
| 202 |
searchtype => 'contains', |
| 203 |
branchcode => $branchcode, |
| 204 |
dt_params => \%dt_params |
| 205 |
}); |
| 206 |
is( $search_results->{ iTotalDisplayRecords}, 0, "There are still 2 common users, but the patron attribute is not searchable " ); |
| 207 |
|
| 171 |
$dbh->rollback; |
208 |
$dbh->rollback; |
| 172 |
|
209 |
|
| 173 |
1; |
210 |
1; |
| 174 |
- |
|
|