Browse Source

Bug 28640: Unit tests for edi_order relation

Test plan
1/ Run t/db_dependent/Koha/Acquisition/Basket.t

Signed-off-by: Benjamin Veasey <B.T.Veasey@lboro.ac.uk>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
master
Martin Renvoize 3 months ago
committed by Jonathan Druart
parent
commit
b17b691e01
  1. 42
      t/db_dependent/Koha/Acquisition/Basket.t

42
t/db_dependent/Koha/Acquisition/Basket.t

@ -19,7 +19,7 @@
use Modern::Perl;
use Test::More tests => 12;
use Test::More tests => 13;
use Test::Exception;
use t::lib::TestBuilder;
@ -303,6 +303,46 @@ subtest 'orders' => sub {
$schema->storage->txn_rollback;
};
subtest 'edi_order' => sub {
plan tests => 3;
$schema->storage->txn_begin;
my $basket = $builder->build_object(
{
class => 'Koha::Acquisition::Baskets'
}
);
is( $basket->edi_order, undef,
'edi_order returns undefined if there are no edi_messages of type "ORDER" attached' );
my $order_message_1 = $builder->build(
{
source => 'EdifactMessage',
value => { basketno => $basket->basketno, message_type => 'ORDERS', transfer_date => '2019-07-30' }
}
);
my $edi_message = $basket->edi_order;
is( ref($edi_message), 'Koha::Schema::Result::EdifactMessage',
'edi_order returns an EdifactMessage if one is attached' );
my $order_message_2 = $builder->build(
{
source => 'EdifactMessage',
value => { basketno => $basket->basketno, message_type => 'ORDERS' }
}
);
$edi_message = $basket->edi_order;
is( $edi_message->id, $order_message_2->{id},
'edi_order returns the most recently associated ORDERS EdifactMessage' );
$schema->storage->txn_rollback;
};
subtest 'is_closed() tests' => sub {
plan tests => 2;

Loading…
Cancel
Save