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

(-)a/Koha/Objects.pm (+15 lines)
Lines 320-325 sub to_api { Link Here
320
    return [ map { $_->to_api } $self->as_list ];
320
    return [ map { $_->to_api } $self->as_list ];
321
}
321
}
322
322
323
=head3 attributes_from_api
324
325
    my $attributes = $objects->attributes_from_api( $api_attributes );
326
327
Translates attributes from the API to DBIC
328
329
=cut
330
331
sub attributes_from_api {
332
    my ( $self, $attributes ) = @_;
333
334
    $self->{_singular_object} ||= $self->object_class->new();
335
    return $self->{_singular_object}->attributes_from_api( $attributes );
336
}
337
323
=head3 Koha::Objects->_wrap
338
=head3 Koha::Objects->_wrap
324
339
325
wraps the DBIC object in a corresponding Koha object
340
wraps the DBIC object in a corresponding Koha object
(-)a/t/db_dependent/Koha/Objects.t (-2 / +23 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 17;
22
use Test::More tests => 18;
23
use Test::Exception;
23
use Test::Exception;
24
use Test::Warn;
24
use Test::Warn;
25
25
Lines 330-332 subtest "TO_JSON() tests" => sub { Link Here
330
330
331
    $schema->storage->txn_rollback;
331
    $schema->storage->txn_rollback;
332
};
332
};
333
- 
333
334
subtest "attributes_from_api() tests" => sub {
335
336
    plan tests => 1;
337
338
    $schema->storage->txn_begin;
339
340
    my $cities_rs = Koha::Cities->new;
341
    my $city      = Koha::City->new;
342
343
    my $api_attributes = {
344
        name        => 'Cordoba',
345
        postal_code => 5000
346
    };
347
348
    is_deeply(
349
        $cities_rs->attributes_from_api($api_attributes),
350
        $city->attributes_from_api($api_attributes)
351
    );
352
353
    $schema->storage->txn_rollback;
354
};

Return to bug 24321