Bug 22343: Add exec flag on .t files
[koha.git] / t / db_dependent / Koha / SMTP / Server.t
blob1e86fe4f8d5cc8a9b45e62c7d77c5d6b63b1d2bd
1 #!/usr/bin/perl
3 # This file is part of Koha.
5 # Koha is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # Koha is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with Koha; if not, see <http://www.gnu.org/licenses>.
18 use Modern::Perl;
20 use Test::More tests => 2;
21 use Test::Exception;
22 use Test::Warn;
24 use Koha::SMTP::Servers;
26 use t::lib::TestBuilder;
27 use t::lib::Mocks;
29 my $schema = Koha::Database->new->schema;
30 my $builder = t::lib::TestBuilder->new;
32 subtest 'transport() tests' => sub {
34 plan tests => 4;
36 $schema->storage->txn_begin;
38 my $server = $builder->build_object(
40 class => 'Koha::SMTP::Servers',
41 value => { ssl_mode => 'disabled' }
45 my $transport = $server->transport;
47 is( ref($transport), 'Email::Sender::Transport::SMTP', 'Type is correct' );
48 is( $transport->ssl, 0, 'SSL is not set' );
50 $server->set({ ssl_mode => 'ssl' })->store;
51 $transport = $server->transport;
53 is( ref($transport), 'Email::Sender::Transport::SMTP', 'Type is correct' );
54 is( $transport->ssl, 'ssl', 'SSL is set' );
56 $schema->storage->txn_rollback;
59 subtest 'is_system_default() tests' => sub {
61 plan tests => 2;
63 $schema->storage->txn_begin;
65 my $smtp_server = $builder->build_object({ class => 'Koha::SMTP::Servers' });
66 ok( !$smtp_server->is_system_default, 'A generated server is not the system default' );
68 my $system_default_server = Koha::SMTP::Servers->get_default;
69 ok( $system_default_server->is_system_default, 'The server returned by get_default is the system default' );
71 $schema->storage->txn_rollback;