From 7472d6faf0d3ac7c41a3d37d7634b440953215cb Mon Sep 17 00:00:00 2001 From: Shish Date: Tue, 28 Jan 2020 22:23:03 +0000 Subject: [PATCH] Add a secret 'static' media engine for fast unit testing --- ext/media/main.php | 3 +++ ext/media/media_engine.php | 22 ++++++++++++++++------ tests/bootstrap.php | 2 +- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/ext/media/main.php b/ext/media/main.php index 60d0bb4a..a9c0e5ff 100644 --- a/ext/media/main.php +++ b/ext/media/main.php @@ -236,6 +236,9 @@ class Media extends Extension ); //} break; + case MediaEngine::STATIC: + copy($event->input_path, $event->output_path); + break; default: throw new MediaException("Engine not supported for resize: " . $event->engine); } diff --git a/ext/media/media_engine.php b/ext/media/media_engine.php index 933dacbe..62e56e05 100644 --- a/ext/media/media_engine.php +++ b/ext/media/media_engine.php @@ -5,11 +5,13 @@ abstract class MediaEngine public const GD = "gd"; public const IMAGICK = "convert"; public const FFMPEG = "ffmpeg"; + public const STATIC = "static"; public const ALL = [ MediaEngine::GD, MediaEngine::FFMPEG, - MediaEngine::IMAGICK + MediaEngine::IMAGICK, + MediaEngine::STATIC, ]; public const OUTPUT_SUPPORT = [ MediaEngine::GD => [ @@ -30,8 +32,11 @@ abstract class MediaEngine MediaEngine::FFMPEG => [ "jpg", "webp", - "png" - ] + "png", + ], + MediaEngine::STATIC => [ + "jpg", + ], ]; public const INPUT_SUPPORT = [ MediaEngine::GD => [ @@ -41,7 +46,7 @@ abstract class MediaEngine "png", "webp", Media::WEBP_LOSSY, - Media::WEBP_LOSSLESS + Media::WEBP_LOSSLESS, ], MediaEngine::IMAGICK => [ "bmp", @@ -61,7 +66,12 @@ abstract class MediaEngine "webm", "mp4", "mov", - "flv" - ] + "flv", + ], + MediaEngine::STATIC => [ + "jpg", + "gif", + "png", + ], ]; } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index bfd1568b..881ce725 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -23,7 +23,7 @@ require_all(zglob("ext/{".Extension::get_enabled_extensions_as_string()."}/main. _load_theme_files(); $page = new Page(); _load_event_listeners(); -$config->set_string("thumb_engine", "gd"); # GD has less overhead per-call +$config->set_string("thumb_engine", "static"); # GD has less overhead per-call send_event(new DatabaseUpgradeEvent()); send_event(new InitExtEvent());