|
Lines 132-138
subtest 'store( extended_attributes ) tests' => sub {
Link Here
|
| 132 |
|
132 |
|
| 133 |
subtest 'approve tests' => sub { |
133 |
subtest 'approve tests' => sub { |
| 134 |
|
134 |
|
| 135 |
plan tests => 7; |
135 |
plan tests => 14; |
| 136 |
|
136 |
|
| 137 |
$schema->storage->txn_begin; |
137 |
$schema->storage->txn_begin; |
| 138 |
|
138 |
|
|
Lines 191-196
subtest 'approve tests' => sub {
Link Here
|
| 191 |
$patron = Koha::Patrons->find( $patron_hashref->{borrowernumber} ); |
191 |
$patron = Koha::Patrons->find( $patron_hashref->{borrowernumber} ); |
| 192 |
isnt( $patron->firstname, 'Kylie', 'Patron modification didn\'t apply' ); |
192 |
isnt( $patron->firstname, 'Kylie', 'Patron modification didn\'t apply' ); |
| 193 |
|
193 |
|
|
|
194 |
# Try changing only a portion of the attributes |
| 195 |
my $bigger_json |
| 196 |
= '[{"code":"CODE_2","value":"Tomasito"},{"code":"CODE_2","value":"None"}]'; |
| 197 |
$verification_token = md5_hex( time() . {} . rand() . {} . $$ ); |
| 198 |
|
| 199 |
$patron_modification = Koha::Patron::Modification->new( |
| 200 |
{ borrowernumber => $patron->borrowernumber, |
| 201 |
extended_attributes => $bigger_json, |
| 202 |
verification_token => $verification_token |
| 203 |
} |
| 204 |
)->store(); |
| 205 |
ok( $patron_modification->approve, |
| 206 |
'Patron modification correctly approved' ); |
| 207 |
@patron_attributes |
| 208 |
= map { $_->unblessed } |
| 209 |
Koha::Patron::Attributes->search( |
| 210 |
{ borrowernumber => $patron->borrowernumber } ); |
| 211 |
|
| 212 |
is( $patron_attributes[0]->{code}, |
| 213 |
'CODE_1', 'Untouched attribute type is preserved (code)' ); |
| 214 |
is( $patron_attributes[0]->{attribute}, |
| 215 |
'VALUE_1', 'Untouched attribute type is preserved (attribute)' ); |
| 216 |
|
| 217 |
is( $patron_attributes[1]->{code}, |
| 218 |
'CODE_2', 'Attribute updated correctly (code)' ); |
| 219 |
is( $patron_attributes[1]->{attribute}, |
| 220 |
'Tomasito', 'Attribute updated correctly (attribute)' ); |
| 221 |
|
| 222 |
is( $patron_attributes[2]->{code}, |
| 223 |
'CODE_2', 'Attribute updated correctly (code)' ); |
| 224 |
is( $patron_attributes[2]->{attribute}, |
| 225 |
'None', 'Attribute updated correctly (attribute)' ); |
| 226 |
|
| 194 |
$schema->storage->txn_rollback; |
227 |
$schema->storage->txn_rollback; |
| 195 |
}; |
228 |
}; |
| 196 |
|
229 |
|
| 197 |
- |
|
|