View | Details | Raw Unified | Return to bug 26290
Collapse All | Expand All

(-)a/Koha/SMTP/Servers.pm (-1 / +10 lines)
Lines 43-49 Returns the default I<Koha::SMTP::Server> object. Link Here
43
sub get_default {
43
sub get_default {
44
    my ($self) = @_;
44
    my ($self) = @_;
45
45
46
    my $default = Koha::SMTP::Server->new( $self->default_setting );
46
    my $default;
47
    my $smtp_config = C4::Context->config('smtp_server');
48
49
    if ( $smtp_config ) {
50
        $default = Koha::SMTP::Server->new( $smtp_config );
51
    }
52
    else {
53
        $default = Koha::SMTP::Server->new( $self->default_setting );
54
    }
55
47
    $default->{_is_system_default} = 1;
56
    $default->{_is_system_default} = 1;
48
    return $default;
57
    return $default;
49
}
58
}
(-)a/t/db_dependent/Koha/SMTP/Servers.t (-2 / +30 lines)
Lines 29-38 my $builder = t::lib::TestBuilder->new; Link Here
29
29
30
subtest 'get_default() tests' => sub {
30
subtest 'get_default() tests' => sub {
31
31
32
    plan tests => 3;
32
    plan tests => 5;
33
33
34
    $schema->storage->txn_begin;
34
    $schema->storage->txn_begin;
35
35
36
    t::lib::Mocks::mock_config( 'smtp_server', undef );
37
36
    my $server  = Koha::SMTP::Servers->get_default;
38
    my $server  = Koha::SMTP::Servers->get_default;
37
    is( ref($server), 'Koha::SMTP::Server',
39
    is( ref($server), 'Koha::SMTP::Server',
38
        'An object of the right type is returned' );
40
        'An object of the right type is returned' );
Lines 48-52 subtest 'get_default() tests' => sub { Link Here
48
        'The default setting is returned if no user-defined default'
50
        'The default setting is returned if no user-defined default'
49
    );
51
    );
50
52
53
    t::lib::Mocks::mock_config(
54
        'smtp_server',
55
        {
56
            host      => 'localhost.midway',
57
            port      => 1234,
58
            timeout   => 121,
59
            ssl_mode  => 'starttls',
60
            user_name => 'tomasito',
61
            password  => 'none',
62
            debug     => 1
63
        }
64
    );
65
66
    my $smtp_config = C4::Context->config('smtp_server');
67
68
    $server = Koha::SMTP::Servers->get_default;
69
    is( ref($server), 'Koha::SMTP::Server',
70
        'An object of the right type is returned' );
71
72
    $unblessed_server = $server->unblessed;
73
    delete $unblessed_server->{id};
74
    is_deeply(
75
        $unblessed_server,
76
        $smtp_config,
77
        'The default setting is overridden by the entry in koha-conf.xml'
78
    );
79
51
    $schema->storage->txn_rollback;
80
    $schema->storage->txn_rollback;
52
};
81
};
53
- 

Return to bug 26290