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

(-)a/t/db_dependent/Koha/Acquisition/Booksellers.t (-7 / +9 lines)
Lines 23-29 use t::lib::TestBuilder; Link Here
23
23
24
use C4::Acquisition qw( NewBasket );
24
use C4::Acquisition qw( NewBasket );
25
use C4::Biblio      qw( AddBiblio );
25
use C4::Biblio      qw( AddBiblio );
26
use C4::Contract    qw( AddContract );
27
use C4::Budgets     qw( AddBudgetPeriod AddBudget );
26
use C4::Budgets     qw( AddBudgetPeriod AddBudget );
28
use C4::Serials     qw( NewSubscription SearchSubscriptions );
27
use C4::Serials     qw( NewSubscription SearchSubscriptions );
29
28
Lines 270-287 subtest 'contracts' => sub { Link Here
270
269
271
    my $vendor = $builder->build_object( { class => 'Koha::Acquisition::Booksellers' } );
270
    my $vendor = $builder->build_object( { class => 'Koha::Acquisition::Booksellers' } );
272
271
273
    is( scalar( @{ $vendor->contracts } ), 0, 'Vendor has no contracts' );
272
    is( scalar( @{ $vendor->contracts->as_list } ), 0, 'Vendor has no contracts' );
274
273
275
    AddContract(
274
    my $contract = $builder->build_object(
276
        {
275
        {
277
            booksellerid => $vendor->id,
276
            class => 'Koha::Acquisition::Contracts',
278
            contractname => 'Test contract',
277
            value => {
278
                booksellerid => $vendor->id,
279
                contractname => 'Test contract',
280
            }
279
        }
281
        }
280
    );
282
    );
281
283
282
    $vendor = $vendor->get_from_storage;
284
    $vendor = $vendor->get_from_storage;
283
    my $contracts = $vendor->contracts;
285
    my @contracts = $vendor->contracts->as_list;
284
    is( scalar( @{$contracts} ), 1, '1 contract stored' );
286
    is( scalar(@contracts), 1, '1 contract stored' );
285
287
286
    $schema->storage->txn_rollback();
288
    $schema->storage->txn_rollback();
287
};
289
};
(-)a/t/db_dependent/Koha/Acquisition/Contracts.t (-1 / +63 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
#
3
# This file is part of Koha
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Test::More tests => 3;
21
use Test::Exception;
22
23
use t::lib::TestBuilder;
24
use t::lib::Mocks;
25
26
use Koha::Database;
27
28
use_ok('Koha::Acquisition::Contract');
29
use_ok('Koha::Acquisition::Contracts');
30
31
my $schema  = Koha::Database->schema;
32
my $builder = t::lib::TestBuilder->new;
33
34
subtest 'store' => sub {
35
36
    plan tests => 2;
37
38
    $schema->storage->txn_begin;
39
40
    my $starting_contract_count = Koha::Acquisition::Contracts->count;
41
42
    my $new_contract = Koha::Acquisition::Contract->new(
43
        {
44
            contractname => 'Test contract',
45
            booksellerid => 1,
46
        }
47
    )->store;
48
    my $contract_count_1 = Koha::Acquisition::Contracts->count;
49
50
    is( $contract_count_1, $starting_contract_count + 1, '1 contract stored' );
51
52
    throws_ok {
53
        my $contract_with_missing_vendor = Koha::Acquisition::Contract->new(
54
            {
55
                contractname => 'Test contract',
56
            }
57
        )->store;
58
    }
59
    'Koha::Exceptions::MissingParameter',
60
61
        $schema->storage->txn_rollback;
62
};
63

Return to bug 39711