From 2db25134222c9d295ef336e06327e80b8825c8b5 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 2 Mar 2023 14:15:15 +0100 Subject: [PATCH] Bug 33104: Add tests Signed-off-by: Jonathan Field --- t/db_dependent/Koha/Acquisition/Booksellers.t | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/t/db_dependent/Koha/Acquisition/Booksellers.t b/t/db_dependent/Koha/Acquisition/Booksellers.t index 1b6a5d4e1c..32106b86c1 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 => 4; +use Test::More tests => 5; use t::lib::TestBuilder; @@ -192,3 +192,36 @@ subtest 'aliases' => sub { $schema->storage->txn_rollback(); }; + +subtest 'interfaces' => sub { + + plan tests => 11; + + $schema->storage->txn_begin(); + + my $vendor = $builder->build_object( { class => 'Koha::Acquisition::Booksellers' } ); + + is( $vendor->interfaces->count, 0, 'Vendor has no interfaces' ); + + $vendor->interfaces( [ { name => 'first interface' }, { name => 'second interface', login => 'one_login' } ] ); + + $vendor = $vendor->get_from_storage; + my $interfaces = $vendor->interfaces; + is( $interfaces->count, 2, '2 interfaces stored' ); + is( ref($interfaces), 'Koha::Acquisition::Bookseller::Interfaces', 'Type is correct' ); + + $vendor->interfaces( [ { name => 'first interface', login => 'one_login', password => 'oneP@sswOrd' } ] ); + $vendor = $vendor->get_from_storage; + $interfaces = $vendor->interfaces; + is( $interfaces->count, 1, '1 interface stored' ); + my $interface = $interfaces->next; + is( $interface->name, 'first interface', 'name correctly saved' ); + is( $interface->login, 'one_login', 'login correctly saved' ); + is( $interface->uri, undef, 'no value is stored as NULL' ); + isnt( $interface->password, 'oneP@sswOrd', 'Password is not stored in plain text' ); + isnt( $interface->password, '', 'Password is not removed' ); + isnt( $interface->password, undef, 'Password is not set to NULL' ); + is( $interface->plain_text_password, 'oneP@sswOrd', 'Password can be retrieved using ->plain_text_password' ); + + $schema->storage->txn_rollback(); +}; -- 2.30.2