Lines 17-29
Link Here
|
17 |
|
17 |
|
18 |
use Modern::Perl; |
18 |
use Modern::Perl; |
19 |
|
19 |
|
20 |
use Test::More tests => 7; |
20 |
use Test::More tests => 8; |
21 |
use Test::Warn; |
21 |
use Test::Warn; |
22 |
|
22 |
|
23 |
use C4::Context; |
23 |
use C4::Context; |
24 |
use Koha::Database; |
24 |
use Koha::Database; |
25 |
use Koha::DateUtils qw( dt_from_string ); |
25 |
use Koha::DateUtils qw( dt_from_string ); |
26 |
|
26 |
|
|
|
27 |
use Scalar::Util qw( isvstring ); |
28 |
|
27 |
use t::lib::TestBuilder; |
29 |
use t::lib::TestBuilder; |
28 |
|
30 |
|
29 |
BEGIN { |
31 |
BEGIN { |
Lines 34-39
BEGIN {
Link Here
|
34 |
my $schema = Koha::Database->new->schema; |
36 |
my $schema = Koha::Database->new->schema; |
35 |
$schema->storage->txn_begin; |
37 |
$schema->storage->txn_begin; |
36 |
|
38 |
|
|
|
39 |
my $builder = t::lib::TestBuilder->new(); |
40 |
|
37 |
my $categorycode = $schema->resultset('Category')->first()->categorycode(); |
41 |
my $categorycode = $schema->resultset('Category')->first()->categorycode(); |
38 |
my $branchcode = $schema->resultset('Branch')->first()->branchcode(); |
42 |
my $branchcode = $schema->resultset('Branch')->first()->branchcode(); |
39 |
|
43 |
|
Lines 107-110
subtest 'discard_changes' => sub {
Link Here
|
107 |
); |
111 |
); |
108 |
}; |
112 |
}; |
109 |
|
113 |
|
|
|
114 |
subtest 'TO_JSON tests' => sub { |
115 |
|
116 |
plan tests => 5; |
117 |
|
118 |
my $borrowernumber = $builder->build( |
119 |
{ source => 'Borrower', |
120 |
value => { lost => 1, |
121 |
gonenoaddress => 0 } })->{borrowernumber}; |
122 |
|
123 |
my $patron = Koha::Patrons->find($borrowernumber); |
124 |
my $lost = $patron->TO_JSON()->{lost}; |
125 |
my $gonenoaddress = $patron->TO_JSON->{gonenoaddress}; |
126 |
|
127 |
ok( $lost->isa('Mojo::JSON::_Bool'), 'Boolean attribute type is correct' ); |
128 |
is( $lost, 1, 'Boolean attribute value is correct (true)' ); |
129 |
|
130 |
ok( $gonenoaddress->isa('Mojo::JSON::_Bool'), 'Boolean attribute type is correct' ); |
131 |
is( $gonenoaddress, 0, 'Boolean attribute value is correct (false)' ); |
132 |
|
133 |
ok( !isvstring($patron->borrowernumber), 'Integer values are not coded as strings' ); |
134 |
}; |
135 |
|
136 |
|
137 |
|
110 |
1; |
138 |
1; |
111 |
- |
|
|