Lines 85-91
subtest 'new() tests' => sub {
Link Here
|
85 |
|
85 |
|
86 |
subtest 'store( extended_attributes ) tests' => sub { |
86 |
subtest 'store( extended_attributes ) tests' => sub { |
87 |
|
87 |
|
88 |
plan tests => 4; |
88 |
plan tests => 6; |
89 |
|
89 |
|
90 |
$schema->storage->txn_begin; |
90 |
$schema->storage->txn_begin; |
91 |
|
91 |
|
Lines 94-101
subtest 'store( extended_attributes ) tests' => sub {
Link Here
|
94 |
my $patron |
94 |
my $patron |
95 |
= $builder->build( { source => 'Borrower' } )->{borrowernumber}; |
95 |
= $builder->build( { source => 'Borrower' } )->{borrowernumber}; |
96 |
my $verification_token = md5_hex( time().{}.rand().{}.$$ ); |
96 |
my $verification_token = md5_hex( time().{}.rand().{}.$$ ); |
97 |
my $valid_json_text = '[{"code":"CODE","value":"VALUE"}]'; |
97 |
$builder->build( |
98 |
my $invalid_json_text = '[{"code":"CODE";"value":"VALUE"}]'; |
98 |
{ source => 'BorrowerAttributeType', value => { code => 'CODE_1' } } |
|
|
99 |
); |
100 |
$builder->build( |
101 |
{ source => 'BorrowerAttributeType', value => { code => 'CODE_2' } } |
102 |
); |
103 |
my $valid_json_text = '[{"code":"CODE_1","value":"VALUE"}]'; |
104 |
my $invalid_json_text = '[{"code":"CODE_2";"value":"VALUE"}]'; |
99 |
|
105 |
|
100 |
Koha::Patron::Modification->new( |
106 |
Koha::Patron::Modification->new( |
101 |
{ verification_token => $verification_token, |
107 |
{ verification_token => $verification_token, |
Lines 130-135
subtest 'store( extended_attributes ) tests' => sub {
Link Here
|
130 |
|
136 |
|
131 |
is( $@, 'The passed extended_attributes is not valid JSON' ); |
137 |
is( $@, 'The passed extended_attributes is not valid JSON' ); |
132 |
|
138 |
|
|
|
139 |
Koha::Patrons->find($patron)->surname('Hall')->store; |
140 |
throws_ok { |
141 |
Koha::Patron::Modification->new( |
142 |
{ verification_token => $verification_token, |
143 |
borrowernumber => $patron, |
144 |
surname => 'Hall', |
145 |
} |
146 |
)->store(); |
147 |
} |
148 |
'Koha::Exceptions::NoChanges', |
149 |
'Trying to create a modification request without changing anything' |
150 |
.' raises exception'; |
151 |
|
152 |
$patron_modification->approve; |
153 |
throws_ok { |
154 |
Koha::Patron::Modification->new( |
155 |
{ verification_token => $verification_token, |
156 |
borrowernumber => $patron, |
157 |
extended_attributes => $valid_json_text, |
158 |
} |
159 |
)->store(); |
160 |
} |
161 |
'Koha::Exceptions::NoChanges', |
162 |
'Trying to create a modification request without changing anything' |
163 |
.' raises exception'; |
164 |
|
133 |
$schema->storage->txn_rollback; |
165 |
$schema->storage->txn_rollback; |
134 |
}; |
166 |
}; |
135 |
|
167 |
|
136 |
- |
|
|