Skip to content

Commit a336e41

Browse files
committed
Tests: Allow *::test_render_control_template_scripts() to run by itself.
These tests call `->render_control_template_scripts()`, which depends on a normally lazy-loaded file: `wp-includes/media-template.php`. Previous tests in these classes load that file as a side-effect of calling `$widget->enqueue_admin_scripts()`. When testing these tests individually, that file is never loaded. Load it explicitly.
1 parent bb3b81b commit a336e41

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

‎tests/phpunit/tests/widgets/wpWidgetMediaAudio.php‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,9 @@ public function test_enqueue_admin_scripts() {
316316
* @covers WP_Widget_Media_Audio::render_control_template_scripts
317317
*/
318318
public function test_render_control_template_scripts() {
319+
// Provides wp_underscore_audio_template(), normally loaded by wp_enqueue_media().
320+
require_once ABSPATH . WPINC . '/media-template.php';
321+
319322
$widget = new WP_Widget_Media_Audio();
320323

321324
ob_start();

‎tests/phpunit/tests/widgets/wpWidgetMediaVideo.php‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,9 @@ public function test_enqueue_admin_scripts() {
344344
* @covers WP_Widget_Media_Video::render_control_template_scripts
345345
*/
346346
public function test_render_control_template_scripts() {
347+
// Provides wp_underscore_video_template(), normally loaded by wp_enqueue_media().
348+
require_once ABSPATH . WPINC . '/media-template.php';
349+
347350
$widget = new WP_Widget_Media_Video();
348351

349352
ob_start();

0 commit comments

Comments
 (0)