Browse Source

Bug 23770: (follow-up) Add tests for Koha::Objects->TO_JSON

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
remotes/origin/19.11.x
Tomás Cohen Arazi 5 years ago
committed by Martin Renvoize
parent
commit
1800a2e6b8
Signed by: martin.renvoize GPG Key ID: 422B469130441A0F
  1. 27
      t/db_dependent/Koha/Objects.t

27
t/db_dependent/Koha/Objects.t

@ -19,7 +19,7 @@
use Modern::Perl;
use Test::More tests => 16;
use Test::More tests => 17;
use Test::Exception;
use Test::Warn;
@ -305,3 +305,28 @@ subtest "to_api() tests" => sub {
$schema->storage->txn_rollback;
};
subtest "TO_JSON() tests" => sub {
plan tests => 4;
$schema->storage->txn_begin;
my $city_1 = $builder->build_object( { class => 'Koha::Cities' } );
my $city_2 = $builder->build_object( { class => 'Koha::Cities' } );
my $cities = Koha::Cities->search(
{
cityid => [ $city_1->cityid, $city_2->cityid ]
},
{ -orderby => { -desc => 'cityid' } }
);
is( $cities->count, 2, 'Count is correct' );
my $cities_json = $cities->TO_JSON;
is( ref($cities_json), 'ARRAY', 'to_api returns an array' );
is_deeply( $cities_json->[0], $city_1->TO_JSON, 'TO_JSON returns the individual objects with ->TO_JSON' );
is_deeply( $cities_json->[1], $city_2->TO_JSON,'TO_JSON returns the individual objects with ->TO_JSON' );
$schema->storage->txn_rollback;
};

Loading…
Cancel
Save