|
Line 0
Link Here
|
|
|
1 |
#!/usr/bin/perl |
| 2 |
|
| 3 |
# This file is part of Koha. |
| 4 |
# |
| 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. |
| 9 |
# |
| 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. |
| 14 |
# |
| 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>. |
| 17 |
|
| 18 |
use Modern::Perl; |
| 19 |
|
| 20 |
use Test::More tests => 2; |
| 21 |
use Test::Exception; |
| 22 |
use Test::Warn; |
| 23 |
|
| 24 |
use Koha::SMTP::Servers; |
| 25 |
|
| 26 |
use t::lib::TestBuilder; |
| 27 |
use t::lib::Mocks; |
| 28 |
|
| 29 |
my $schema = Koha::Database->new->schema; |
| 30 |
my $builder = t::lib::TestBuilder->new; |
| 31 |
|
| 32 |
subtest 'transport() tests' => sub { |
| 33 |
|
| 34 |
plan tests => 4; |
| 35 |
|
| 36 |
$schema->storage->txn_begin; |
| 37 |
|
| 38 |
my $server = $builder->build_object( |
| 39 |
{ |
| 40 |
class => 'Koha::SMTP::Servers', |
| 41 |
value => { ssl_mode => 'disabled' } |
| 42 |
} |
| 43 |
); |
| 44 |
|
| 45 |
my $transport = $server->transport; |
| 46 |
|
| 47 |
is( ref($transport), 'Email::Sender::Transport::SMTP', 'Type is correct' ); |
| 48 |
is( $transport->ssl, 0, 'SSL is not set' ); |
| 49 |
|
| 50 |
$server->set({ ssl_mode => 'ssl' })->store; |
| 51 |
$transport = $server->transport; |
| 52 |
|
| 53 |
is( ref($transport), 'Email::Sender::Transport::SMTP', 'Type is correct' ); |
| 54 |
is( $transport->ssl, 'ssl', 'SSL is set' ); |
| 55 |
|
| 56 |
$schema->storage->txn_rollback; |
| 57 |
}; |
| 58 |
|
| 59 |
subtest 'is_system_default() tests' => sub { |
| 60 |
|
| 61 |
plan tests => 2; |
| 62 |
|
| 63 |
$schema->storage->txn_begin; |
| 64 |
|
| 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' ); |
| 67 |
|
| 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' ); |
| 70 |
|
| 71 |
$schema->storage->txn_rollback; |
| 72 |
}; |