From fef9b207e5b9530dc731131eab3979dd67b3b130 Mon Sep 17 00:00:00 2001 From: Khadreal Date: Thu, 23 Jan 2025 05:58:56 +0100 Subject: [PATCH] Add test -- #7029 --- .../Frontend/Subscriber/add_hashes.php | 15 +++++++++++++++ .../Frontend/Subscriber/add_hashes.php | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tests/Fixtures/inc/Engine/Optimization/LazyRenderContent/Frontend/Subscriber/add_hashes.php b/tests/Fixtures/inc/Engine/Optimization/LazyRenderContent/Frontend/Subscriber/add_hashes.php index 7ba4a5967f..fb771790ab 100644 --- a/tests/Fixtures/inc/Engine/Optimization/LazyRenderContent/Frontend/Subscriber/add_hashes.php +++ b/tests/Fixtures/inc/Engine/Optimization/LazyRenderContent/Frontend/Subscriber/add_hashes.php @@ -80,5 +80,20 @@ 'html' => file_get_contents( WP_ROCKET_TESTS_FIXTURES_DIR . '/inc/Engine/Optimization/LazyRenderContent/Frontend/Subscriber/html/expected_exclusions.php' ), ] ], + 'shouldNotAddHashesWhenDonotoptimize' => [ + 'config' => [ + 'donotrocketoptimize' => true, + 'row' => [ + 'url' => 'http://example.org/', + 'is_mobile' => 0, + 'below_the_fold' => json_encode([]), + 'status' => 'completed' + ], + 'html' => file_get_contents( WP_ROCKET_TESTS_FIXTURES_DIR . '/inc/Engine/Optimization/LazyRenderContent/Frontend/Subscriber/html/original.php' ), + ], + 'expected' => [ + 'html' => file_get_contents( WP_ROCKET_TESTS_FIXTURES_DIR . '/inc/Engine/Optimization/LazyRenderContent/Frontend/Subscriber/html/original.php' ), + ] + ], ] ]; diff --git a/tests/Integration/inc/Engine/Optimization/LazyRenderContent/Frontend/Subscriber/add_hashes.php b/tests/Integration/inc/Engine/Optimization/LazyRenderContent/Frontend/Subscriber/add_hashes.php index 699cf7caf5..c016bae208 100644 --- a/tests/Integration/inc/Engine/Optimization/LazyRenderContent/Frontend/Subscriber/add_hashes.php +++ b/tests/Integration/inc/Engine/Optimization/LazyRenderContent/Frontend/Subscriber/add_hashes.php @@ -9,7 +9,7 @@ * * @group PerformanceHints */ -class Test_AddHashes extends TestCase { +class Test_Add_Hashes extends TestCase { private $max_hashes; public static function set_up_before_class() { @@ -46,6 +46,7 @@ public function tear_down() { */ public function testShouldWorkAsExpected( $config, $expected ) { self::addLrc( $config['row'] ); + $this->donotrocketoptimize = $config['donotrocketoptimize'] ?? null; add_filter( 'rocket_lrc_optimization', '__return_true' ); add_filter( 'rocket_lrc_exclusions', function() use ($config) {