Bugzilla – Attachment 109036 Details for
Bug 26290
Add the ability to set a default SMTP server in koha-conf.xml
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 26290: Make Koha::SMTP::Servers->get_default use koha-conf.xml
Bug-26290-Make-KohaSMTPServers-getdefault-use-koha.patch (text/plain), 2.77 KB, created by
Tomás Cohen Arazi (tcohen)
on 2020-08-24 20:06:53 UTC
(
hide
)
Description:
Bug 26290: Make Koha::SMTP::Servers->get_default use koha-conf.xml
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2020-08-24 20:06:53 UTC
Size:
2.77 KB
patch
obsolete
>From 23ea002c8517587cd47ef6bf81d491a172f5b9e1 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 24 Aug 2020 16:47:58 -0300 >Subject: [PATCH] Bug 26290: Make Koha::SMTP::Servers->get_default use > koha-conf.xml > >This patch makes the mentioned method use the configured entry in >koha-conf.xml if present, instead of the hardcoded one, which is kept >for people that carries an old koha-conf.xml >--- > Koha/SMTP/Servers.pm | 11 ++++++++++- > t/db_dependent/Koha/SMTP/Servers.t | 31 +++++++++++++++++++++++++++++- > 2 files changed, 40 insertions(+), 2 deletions(-) > >diff --git a/Koha/SMTP/Servers.pm b/Koha/SMTP/Servers.pm >index a4354c3775..d7451e9a87 100644 >--- a/Koha/SMTP/Servers.pm >+++ b/Koha/SMTP/Servers.pm >@@ -43,7 +43,16 @@ Returns the default I<Koha::SMTP::Server> object. > sub get_default { > my ($self) = @_; > >- my $default = Koha::SMTP::Server->new( $self->default_setting ); >+ my $default; >+ my $smtp_config = C4::Context->config('smtp_server'); >+ >+ if ( $smtp_config ) { >+ $default = Koha::SMTP::Server->new( $smtp_config ); >+ } >+ else { >+ $default = Koha::SMTP::Server->new( $self->default_setting ); >+ } >+ > $default->{_is_system_default} = 1; > return $default; > } >diff --git a/t/db_dependent/Koha/SMTP/Servers.t b/t/db_dependent/Koha/SMTP/Servers.t >index adefdaed12..b3506b76b1 100644 >--- a/t/db_dependent/Koha/SMTP/Servers.t >+++ b/t/db_dependent/Koha/SMTP/Servers.t >@@ -29,10 +29,12 @@ my $builder = t::lib::TestBuilder->new; > > subtest 'get_default() tests' => sub { > >- plan tests => 3; >+ plan tests => 5; > > $schema->storage->txn_begin; > >+ t::lib::Mocks::mock_config( 'smtp_server', undef ); >+ > my $server = Koha::SMTP::Servers->get_default; > is( ref($server), 'Koha::SMTP::Server', > 'An object of the right type is returned' ); >@@ -48,5 +50,32 @@ subtest 'get_default() tests' => sub { > 'The default setting is returned if no user-defined default' > ); > >+ t::lib::Mocks::mock_config( >+ 'smtp_server', >+ { >+ host => 'localhost.midway', >+ port => 1234, >+ timeout => 121, >+ ssl_mode => 'starttls', >+ user_name => 'tomasito', >+ password => 'none', >+ debug => 1 >+ } >+ ); >+ >+ my $smtp_config = C4::Context->config('smtp_server'); >+ >+ $server = Koha::SMTP::Servers->get_default; >+ is( ref($server), 'Koha::SMTP::Server', >+ 'An object of the right type is returned' ); >+ >+ $unblessed_server = $server->unblessed; >+ delete $unblessed_server->{id}; >+ is_deeply( >+ $unblessed_server, >+ $smtp_config, >+ 'The default setting is overridden by the entry in koha-conf.xml' >+ ); >+ > $schema->storage->txn_rollback; > }; >-- >2.28.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 26290
:
109035
|
109036
|
109617
|
109618
|
109949
|
110758
|
110759
|
110760
|
111141