View | Details | Raw Unified | Return to bug 23770
Collapse All | Expand All

(-)a/t/db_dependent/Koha/Objects.t (-2 / +26 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 16;
22
use Test::More tests => 17;
23
use Test::Exception;
23
use Test::Exception;
24
use Test::Warn;
24
use Test::Warn;
25
25
Lines 305-307 subtest "to_api() tests" => sub { Link Here
305
305
306
    $schema->storage->txn_rollback;
306
    $schema->storage->txn_rollback;
307
};
307
};
308
- 
308
309
subtest "TO_JSON() tests" => sub {
310
311
    plan tests => 4;
312
313
    $schema->storage->txn_begin;
314
315
    my $city_1 = $builder->build_object( { class => 'Koha::Cities' } );
316
    my $city_2 = $builder->build_object( { class => 'Koha::Cities' } );
317
318
    my $cities = Koha::Cities->search(
319
        {
320
            cityid => [ $city_1->cityid, $city_2->cityid ]
321
        },
322
        { -orderby => { -desc => 'cityid' } }
323
    );
324
325
    is( $cities->count, 2, 'Count is correct' );
326
    my $cities_json = $cities->TO_JSON;
327
    is( ref($cities_json), 'ARRAY', 'to_api returns an array' );
328
    is_deeply( $cities_json->[0], $city_1->TO_JSON, 'TO_JSON returns the individual objects with ->TO_JSON' );
329
    is_deeply( $cities_json->[1], $city_2->TO_JSON,'TO_JSON returns the individual objects with ->TO_JSON' );
330
331
    $schema->storage->txn_rollback;
332
};

Return to bug 23770