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

(-)a/t/db_dependent/Koha/Acquisition/Booksellers.t (-7 / +9 lines)
Lines 25-31 use t::lib::TestBuilder; Link Here
25
25
26
use C4::Acquisition qw( NewBasket );
26
use C4::Acquisition qw( NewBasket );
27
use C4::Biblio      qw( AddBiblio );
27
use C4::Biblio      qw( AddBiblio );
28
use C4::Contract    qw( AddContract );
29
use C4::Budgets     qw( AddBudgetPeriod AddBudget );
28
use C4::Budgets     qw( AddBudgetPeriod AddBudget );
30
use C4::Serials     qw( NewSubscription SearchSubscriptions );
29
use C4::Serials     qw( NewSubscription SearchSubscriptions );
31
30
Lines 272-289 subtest 'contracts' => sub { Link Here
272
271
273
    my $vendor = $builder->build_object( { class => 'Koha::Acquisition::Booksellers' } );
272
    my $vendor = $builder->build_object( { class => 'Koha::Acquisition::Booksellers' } );
274
273
275
    is( scalar( @{ $vendor->contracts } ), 0, 'Vendor has no contracts' );
274
    is( scalar( @{ $vendor->contracts->as_list } ), 0, 'Vendor has no contracts' );
276
275
277
    AddContract(
276
    my $contract = $builder->build_object(
278
        {
277
        {
279
            booksellerid => $vendor->id,
278
            class => 'Koha::Acquisition::Contracts',
280
            contractname => 'Test contract',
279
            value => {
280
                booksellerid => $vendor->id,
281
                contractname => 'Test contract',
282
            }
281
        }
283
        }
282
    );
284
    );
283
285
284
    $vendor = $vendor->get_from_storage;
286
    $vendor = $vendor->get_from_storage;
285
    my $contracts = $vendor->contracts;
287
    my @contracts = $vendor->contracts->as_list;
286
    is( scalar( @{$contracts} ), 1, '1 contract stored' );
288
    is( scalar(@contracts), 1, '1 contract stored' );
287
289
288
    $schema->storage->txn_rollback();
290
    $schema->storage->txn_rollback();
289
};
291
};
(-)a/t/db_dependent/Koha/Acquisition/Contracts.t (-1 / +62 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
};

Return to bug 39711