From f63bb8b0ca90849e32d40d6191c9160f35d525cc Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Wed, 30 May 2018 16:39:25 +0200 Subject: [PATCH] Bug 20727: (QA follow-up) Fix Upload.t and Plugins.t Trivial changes. Adding C4::Context->temporary_directory to subsequent tmpdir call in Plugins. Signed-off-by: Marcel de Rooy Signed-off-by: Jonathan Druart Signed-off-by: Nick Clemens --- Koha/UploadedFile.pm | 5 +++-- t/db_dependent/Plugins.t | 5 ++--- t/db_dependent/Upload.t | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Koha/UploadedFile.pm b/Koha/UploadedFile.pm index cee92653d8..20fc608c68 100644 --- a/Koha/UploadedFile.pm +++ b/Koha/UploadedFile.pm @@ -102,8 +102,9 @@ Returns the fully qualified path name for an uploaded file. sub full_path { my ( $self ) = @_; my $path = File::Spec->catfile( - $self->permanent? - $self->permanent_directory: $self->temporary_directory, + $self->permanent + ? $self->permanent_directory + : C4::Context->temporary_directory, $self->dir, $self->hashvalue. '_'. $self->filename, ); diff --git a/t/db_dependent/Plugins.t b/t/db_dependent/Plugins.t index 24150593ba..f82d3b25be 100755 --- a/t/db_dependent/Plugins.t +++ b/t/db_dependent/Plugins.t @@ -12,7 +12,6 @@ use Module::Load::Conditional qw(can_load); use Test::MockModule; use C4::Context; -use Koha::UploadedFile; use t::lib::Mocks; @@ -63,8 +62,8 @@ is( $plugin->get_plugin_http_path(), '/plugin/Koha/Plugin/Test', 'Test $plugin-> # test absolute path change in get_template with Koha::Plugin::Test # using the mock set before # we also add tmpdir as an approved template dir -t::lib::Mocks::mock_config( 'pluginsdir', [ C4::Context::temporary_directory ] ); -my ( $fh, $fn ) = tempfile( SUFFIX => '.tt', UNLINK => 1 ); +t::lib::Mocks::mock_config( 'pluginsdir', [ C4::Context->temporary_directory ] ); +my ( $fh, $fn ) = tempfile( SUFFIX => '.tt', UNLINK => 1, DIR => C4::Context->temporary_directory ); print $fh 'I am [% filename %]'; close $fh; my $classname = ref($plugin); diff --git a/t/db_dependent/Upload.t b/t/db_dependent/Upload.t index ccb879a7d6..729bb86248 100644 --- a/t/db_dependent/Upload.t +++ b/t/db_dependent/Upload.t @@ -48,11 +48,11 @@ our $uploads = [ ], ]; -# Redirect upload dir structure and mock File::Spec and CGI +# Redirect upload dir structure and mock C4::Context and CGI my $tempdir = tempdir( CLEANUP => 1 ); t::lib::Mocks::mock_config('upload_path', $tempdir); -my $specmod = Test::MockModule->new( 'File::Spec' ); -$specmod->mock( 'tmpdir' => sub { return $tempdir; } ); +my $specmod = Test::MockModule->new( 'C4::Context' ); +$specmod->mock( 'temporary_directory' => sub { return $tempdir; } ); my $cgimod = Test::MockModule->new( 'CGI' ); $cgimod->mock( 'new' => \&newCGI ); -- 2.39.5