Lines 97-103
subtest 'new() tests' => sub {
Link Here
|
97 |
|
97 |
|
98 |
subtest 'store( extended_attributes ) tests' => sub { |
98 |
subtest 'store( extended_attributes ) tests' => sub { |
99 |
|
99 |
|
100 |
plan tests => 4; |
100 |
plan tests => 6; |
101 |
|
101 |
|
102 |
$schema->storage->txn_begin; |
102 |
$schema->storage->txn_begin; |
103 |
|
103 |
|
Lines 106-113
subtest 'store( extended_attributes ) tests' => sub {
Link Here
|
106 |
my $patron |
106 |
my $patron |
107 |
= $builder->build( { source => 'Borrower' } )->{borrowernumber}; |
107 |
= $builder->build( { source => 'Borrower' } )->{borrowernumber}; |
108 |
my $verification_token = md5_hex( time().{}.rand().{}.$$ ); |
108 |
my $verification_token = md5_hex( time().{}.rand().{}.$$ ); |
109 |
my $valid_json_text = '[{"code":"CODE","value":"VALUE"}]'; |
109 |
$builder->build( |
110 |
my $invalid_json_text = '[{"code":"CODE";"value":"VALUE"}]'; |
110 |
{ source => 'BorrowerAttributeType', value => { code => 'CODE_1' } } |
|
|
111 |
); |
112 |
$builder->build( |
113 |
{ source => 'BorrowerAttributeType', value => { code => 'CODE_2' } } |
114 |
); |
115 |
my $valid_json_text = '[{"code":"CODE_1","value":"VALUE"}]'; |
116 |
my $invalid_json_text = '[{"code":"CODE_2";"value":"VALUE"}]'; |
111 |
|
117 |
|
112 |
Koha::Patron::Modification->new( |
118 |
Koha::Patron::Modification->new( |
113 |
{ verification_token => $verification_token, |
119 |
{ verification_token => $verification_token, |
Lines 142-147
subtest 'store( extended_attributes ) tests' => sub {
Link Here
|
142 |
|
148 |
|
143 |
is( $@, 'The passed extended_attributes is not valid JSON' ); |
149 |
is( $@, 'The passed extended_attributes is not valid JSON' ); |
144 |
|
150 |
|
|
|
151 |
Koha::Patrons->find($patron)->surname('Hall')->store; |
152 |
throws_ok { |
153 |
Koha::Patron::Modification->new( |
154 |
{ verification_token => $verification_token, |
155 |
borrowernumber => $patron, |
156 |
surname => 'Hall', |
157 |
} |
158 |
)->store(); |
159 |
} |
160 |
'Koha::Exceptions::NoChanges', |
161 |
'Trying to create a modification request without changing anything' |
162 |
.' raises exception'; |
163 |
|
164 |
$patron_modification->approve; |
165 |
throws_ok { |
166 |
Koha::Patron::Modification->new( |
167 |
{ verification_token => $verification_token, |
168 |
borrowernumber => $patron, |
169 |
extended_attributes => $valid_json_text, |
170 |
} |
171 |
)->store(); |
172 |
} |
173 |
'Koha::Exceptions::NoChanges', |
174 |
'Trying to create a modification request without changing anything' |
175 |
.' raises exception'; |
176 |
|
145 |
$schema->storage->txn_rollback; |
177 |
$schema->storage->txn_rollback; |
146 |
}; |
178 |
}; |
147 |
|
179 |
|
148 |
- |
|
|