Bug 24434: Add Unit Tests for relations
This patch adds unit tests for the newly introduced to_library (and also add the missing test for the existing from_library). Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
b031ec5845
commit
fb413a87d1
1 changed files with 45 additions and 1 deletions
|
@ -24,7 +24,7 @@ use Koha::DateUtils;
|
||||||
|
|
||||||
use t::lib::TestBuilder;
|
use t::lib::TestBuilder;
|
||||||
|
|
||||||
use Test::More tests => 5;
|
use Test::More tests => 7;
|
||||||
use Test::Exception;
|
use Test::Exception;
|
||||||
|
|
||||||
my $schema = Koha::Database->new->schema;
|
my $schema = Koha::Database->new->schema;
|
||||||
|
@ -52,6 +52,50 @@ subtest 'item relation tests' => sub {
|
||||||
$schema->storage->txn_rollback;
|
$schema->storage->txn_rollback;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
subtest 'from_library relation tests' => sub {
|
||||||
|
plan tests => 2;
|
||||||
|
|
||||||
|
$schema->storage->txn_begin;
|
||||||
|
|
||||||
|
my $library = $builder->build_object( { class => 'Koha::Libraries' } );
|
||||||
|
my $transfer = $builder->build_object(
|
||||||
|
{
|
||||||
|
class => 'Koha::Item::Transfers',
|
||||||
|
value => {
|
||||||
|
frombranch => $library->branchcode,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
my $from_library = $transfer->from_library;
|
||||||
|
is( ref( $from_library ), 'Koha::Library', 'Koha::Item::Transfer->from_library should return a Koha::Library' );
|
||||||
|
is( $from_library->branchcode, $library->branchcode, 'Koha::Item::Transfer->from_library should return the correct library' );
|
||||||
|
|
||||||
|
$schema->storage->txn_rollback;
|
||||||
|
};
|
||||||
|
|
||||||
|
subtest 'to_library relation tests' => sub {
|
||||||
|
plan tests => 2;
|
||||||
|
|
||||||
|
$schema->storage->txn_begin;
|
||||||
|
|
||||||
|
my $library = $builder->build_object( { class => 'Koha::Libraries' } );
|
||||||
|
my $transfer = $builder->build_object(
|
||||||
|
{
|
||||||
|
class => 'Koha::Item::Transfers',
|
||||||
|
value => {
|
||||||
|
tobranch => $library->branchcode,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
my $to_library = $transfer->to_library;
|
||||||
|
is( ref( $to_library ), 'Koha::Library', 'Koha::Item::Transfer->to_library should return a Koha::Library' );
|
||||||
|
is( $to_library->branchcode, $library->branchcode, 'Koha::Item::Transfer->to_library should return the correct library' );
|
||||||
|
|
||||||
|
$schema->storage->txn_rollback;
|
||||||
|
};
|
||||||
|
|
||||||
subtest 'transit tests' => sub {
|
subtest 'transit tests' => sub {
|
||||||
plan tests => 7;
|
plan tests => 7;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue