From c3e534d53fdc93f4e1d04cf285825d4f07b5c368 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 2 Mar 2023 13:54:37 +0100 Subject: [PATCH] Bug 33103: Add tests for Aliases Koha classes Signed-off-by: Jonathan Field --- t/db_dependent/Koha/Acquisition/Booksellers.t | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Acquisition/Booksellers.t b/t/db_dependent/Koha/Acquisition/Booksellers.t index abd4e2ff45..1b6a5d4e1c 100755 --- a/t/db_dependent/Koha/Acquisition/Booksellers.t +++ b/t/db_dependent/Koha/Acquisition/Booksellers.t @@ -17,7 +17,7 @@ use Modern::Perl; -use Test::More tests => 3; +use Test::More tests => 4; use t::lib::TestBuilder; @@ -172,3 +172,23 @@ subtest '->contacts() tests' => sub { $schema->storage->txn_rollback(); }; + +subtest 'aliases' => sub { + + plan tests => 3; + + $schema->storage->txn_begin(); + + my $vendor = $builder->build_object( { class => 'Koha::Acquisition::Booksellers' } ); + + is( $vendor->aliases->count, 0, 'Vendor has no aliases' ); + + $vendor->aliases( [ { alias => 'alias 1' }, { alias => 'alias 2' } ] ); + + $vendor = $vendor->get_from_storage; + my $aliases = $vendor->aliases; + is( $aliases->count, 2 ); + is( ref($aliases), 'Koha::Acquisition::Bookseller::Aliases', 'Type is correct' ); + + $schema->storage->txn_rollback(); +}; -- 2.30.2