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

(-)a/t/db_dependent/Koha/Acquisition/Basket.t (-2 / +35 lines)
Lines 19-30 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 4;
22
use Test::More tests => 5;
23
use t::lib::TestBuilder;
23
use t::lib::TestBuilder;
24
use t::lib::Mocks;
24
use t::lib::Mocks;
25
25
26
use C4::Acquisition;
26
use C4::Acquisition;
27
use Koha::Database;
27
use Koha::Database;
28
use Koha::DateUtils qw(dt_from_string);
28
29
29
use_ok('Koha::Acquisition::Basket');
30
use_ok('Koha::Acquisition::Basket');
30
use_ok('Koha::Acquisition::Baskets');
31
use_ok('Koha::Acquisition::Baskets');
Lines 107-109 subtest 'basket_group' => sub { Link Here
107
108
108
    $schema->storage->txn_rollback;
109
    $schema->storage->txn_rollback;
109
};
110
};
110
- 
111
112
subtest 'to_api() tests' => sub {
113
114
    plan tests => 6;
115
116
    $schema->storage->txn_begin;
117
118
    my $vendor = $builder->build_object({ class => 'Koha::Acquisition::Booksellers' });
119
    my $basket = $builder->build_object(
120
        {
121
            class => 'Koha::Acquisition::Baskets',
122
            value => {
123
                closedate => undef
124
            }
125
        }
126
    );
127
128
    my $closed = $basket->to_api->{closed};
129
    ok( defined $closed, 'closed is defined' );
130
    ok( !$closed, 'closedate is undef, closed evaluates to false' );
131
132
    $basket->closedate( dt_from_string )->store->discard_changes;
133
    $closed = $basket->to_api->{closed};
134
    ok( defined $closed, 'closed is defined' );
135
    ok( $closed, 'closedate is defined, closed evaluates to true' );
136
137
    $basket->booksellerid( $vendor->id )->store->discard_changes;
138
    my $basket_json = $basket->to_api({ embed => { bookseller => {} } });
139
    ok( exists $basket_json->{bookseller} );
140
    is_deeply( $basket_json->{bookseller}, $vendor->to_api );
141
142
    $schema->storage->txn_rollback;
143
};

Return to bug 24457