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

(-)a/t/db_dependent/Koha/Edifact/Order.t (-2 / +41 lines)
Lines 23-28 use Test::More tests => 2; Link Here
23
23
24
use Koha::Edifact::Order;
24
use Koha::Edifact::Order;
25
25
26
use t::lib::Mocks;
26
use t::lib::TestBuilder;
27
use t::lib::TestBuilder;
27
28
28
my $schema = Koha::Database->new->schema;
29
my $schema = Koha::Database->new->schema;
Lines 32-38 my $builder = t::lib::TestBuilder->new; Link Here
32
subtest 'order_line() tests' => sub {
33
subtest 'order_line() tests' => sub {
33
    # TODO: Split up order_line() to smaller methods in order
34
    # TODO: Split up order_line() to smaller methods in order
34
    #       to allow better testing
35
    #       to allow better testing
35
    plan tests => 24;
36
    plan tests => 27;
36
37
37
    $schema->storage->txn_begin;
38
    $schema->storage->txn_begin;
38
39
Lines 45-50 subtest 'order_line() tests' => sub { Link Here
45
        {
46
        {
46
            biblionumber   => $biblio->biblionumber,
47
            biblionumber   => $biblio->biblionumber,
47
            location       => 'PROCESSING',
48
            location       => 'PROCESSING',
49
            ccode          => 'COLLECTION',
48
            itemcallnumber => '000.101'
50
            itemcallnumber => '000.101'
49
        }
51
        }
50
    );
52
    );
Lines 54-59 subtest 'order_line() tests' => sub { Link Here
54
        {
56
        {
55
            biblionumber   => $biblio->biblionumber,
57
            biblionumber   => $biblio->biblionumber,
56
            location       => 'PROCESSING',
58
            location       => 'PROCESSING',
59
            ccode          => 'COLLECTION',
57
            itemcallnumber => '000.102'
60
            itemcallnumber => '000.102'
58
        }
61
        }
59
    );
62
    );
Lines 105-110 subtest 'order_line() tests' => sub { Link Here
105
108
106
    # FIXME: Add test for an order where the attached biblio has been deleted.
109
    # FIXME: Add test for an order where the attached biblio has been deleted.
107
110
111
    # Set EdifactLSQ field to default
112
    t::lib::Mocks::mock_preference( 'EdifactLSQ', 'location' );
113
108
    $order->basket->create_items('ordering')->store;
114
    $order->basket->create_items('ordering')->store;
109
    is( $edi_order->order_line( 1, $orders[0] ),
115
    is( $edi_order->order_line( 1, $orders[0] ),
110
        undef, 'order_line run for message formed with effective_create_items = "ordering"' );
116
        undef, 'order_line run for message formed with effective_create_items = "ordering"' );
Lines 178-183 subtest 'order_line() tests' => sub { Link Here
178
    is( $segs->[9], "RFF+LI:$ordernumber'", 'RFF segment added containing koha orderline id' );
184
    is( $segs->[9], "RFF+LI:$ordernumber'", 'RFF segment added containing koha orderline id' );
179
    is( $segs->[10], "RFF+$supplier_qualifier:$supplier_ordernumber'", 'RFF segment added containing supplier orderline id' );
185
    is( $segs->[10], "RFF+$supplier_qualifier:$supplier_ordernumber'", 'RFF segment added containing supplier orderline id' );
180
186
187
    # Reset segments for testing EdifactLSQ preference
188
    $edi_order->{segs} = [];
189
190
    # Set EdifactLSQ field to ccode
191
    t::lib::Mocks::mock_preference( 'EdifactLSQ', 'ccode' );
192
193
    $order->basket->create_items('ordering')->store;
194
    is( $edi_order->order_line( 1, $orders[0] ),
195
        undef, 'order_line run for message formed with EdifactLSQ = "ccode"' );
196
197
    $segs = $edi_order->{segs};
198
    is(
199
        $segs->[5],
200
        'GIR+001'
201
          . "+$budgetcode:LFN"
202
          . "+$item1_homebranch:LLO"
203
          . "+$item1_itype:LST"
204
          . "+COLLECTION:LSQ"
205
          . "+000.101:LSM"
206
          . "'",
207
        'GIR segment added for first item and contains item ccode data'
208
    );
209
    is(
210
        $segs->[6],
211
        'GIR+002'
212
          . "+$budgetcode:LFN"
213
          . "+$item2_homebranch:LLO"
214
          . "+$item2_itype:LST"
215
          . "+COLLECTION:LSQ"
216
          . "+000.102:LSM"
217
          . "'",
218
        'GIR segment added for second item and contains item ccode data'
219
    );
220
181
    $schema->storage->txn_rollback;
221
    $schema->storage->txn_rollback;
182
};
222
};
183
223
184
- 

Return to bug 30135