Lines 146-163
subtest 'discard_changes' => sub {
Link Here
|
146 |
|
146 |
|
147 |
subtest 'TO_JSON tests' => sub { |
147 |
subtest 'TO_JSON tests' => sub { |
148 |
|
148 |
|
149 |
plan tests => 5; |
149 |
plan tests => 7; |
150 |
|
150 |
|
151 |
$schema->storage->txn_begin; |
151 |
$schema->storage->txn_begin; |
152 |
|
152 |
|
|
|
153 |
my $dt = dt_from_string(); |
153 |
my $borrowernumber = $builder->build( |
154 |
my $borrowernumber = $builder->build( |
154 |
{ source => 'Borrower', |
155 |
{ source => 'Borrower', |
155 |
value => { lost => 1, |
156 |
value => { lost => 1, |
156 |
gonenoaddress => 0 } })->{borrowernumber}; |
157 |
gonenoaddress => 0, |
|
|
158 |
updated_on => $dt, |
159 |
lastseen => $dt, } })->{borrowernumber}; |
157 |
|
160 |
|
158 |
my $patron = Koha::Patrons->find($borrowernumber); |
161 |
my $patron = Koha::Patrons->find($borrowernumber); |
159 |
my $lost = $patron->TO_JSON()->{lost}; |
162 |
my $lost = $patron->TO_JSON()->{lost}; |
160 |
my $gonenoaddress = $patron->TO_JSON->{gonenoaddress}; |
163 |
my $gonenoaddress = $patron->TO_JSON->{gonenoaddress}; |
|
|
164 |
my $updated_on = $patron->TO_JSON->{updated_on}; |
165 |
my $lastseen = $patron->TO_JSON->{lastseen}; |
161 |
|
166 |
|
162 |
ok( $lost->isa('Mojo::JSON::_Bool'), 'Boolean attribute type is correct' ); |
167 |
ok( $lost->isa('Mojo::JSON::_Bool'), 'Boolean attribute type is correct' ); |
163 |
is( $lost, 1, 'Boolean attribute value is correct (true)' ); |
168 |
is( $lost, 1, 'Boolean attribute value is correct (true)' ); |
Lines 167-172
subtest 'TO_JSON tests' => sub {
Link Here
|
167 |
|
172 |
|
168 |
ok( !isvstring($patron->borrowernumber), 'Integer values are not coded as strings' ); |
173 |
ok( !isvstring($patron->borrowernumber), 'Integer values are not coded as strings' ); |
169 |
|
174 |
|
|
|
175 |
my $rfc3999_regex = qr/ |
176 |
(?<year>\d{4}) |
177 |
- |
178 |
(?<month>\d{2}) |
179 |
- |
180 |
(?<day>\d{2}) |
181 |
([Tt\s]) |
182 |
(?<hour>\d{2}) |
183 |
: |
184 |
(?<minute>\d{2}) |
185 |
: |
186 |
(?<second>\d{2}) |
187 |
(([Zz])|([\+|\-]([01][0-9]|2[0-3]):[0-5][0-9])) |
188 |
/xms; |
189 |
like( $updated_on, $rfc3999_regex, "Date-time $updated_on formatted correctly"); |
190 |
like( $lastseen, $rfc3999_regex, "Date-time $updated_on formatted correctly"); |
191 |
|
170 |
$schema->storage->txn_rollback; |
192 |
$schema->storage->txn_rollback; |
171 |
}; |
193 |
}; |
172 |
|
194 |
|
173 |
- |
|
|