From e6cb2cb75d519d64f9f62fdf0c6bc05f775f7388 Mon Sep 17 00:00:00 2001 From: Opeyemi Ibrahim Date: Tue, 27 Aug 2024 10:03:31 +0100 Subject: [PATCH] Add tests --- .../Frontend/Controller/expected-single-line.html | 14 ++++++++++++++ .../Frontend/Controller/optimize.php | 10 ++++++++++ .../Frontend/Controller/single-line-hashed.html | 13 +++++++++++++ .../Frontend/Controller/optimize.php | 2 +- 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 tests/Fixtures/inc/Engine/Optimization/LazyRenderContent/Frontend/Controller/expected-single-line.html create mode 100644 tests/Fixtures/inc/Engine/Optimization/LazyRenderContent/Frontend/Controller/single-line-hashed.html diff --git a/tests/Fixtures/inc/Engine/Optimization/LazyRenderContent/Frontend/Controller/expected-single-line.html b/tests/Fixtures/inc/Engine/Optimization/LazyRenderContent/Frontend/Controller/expected-single-line.html new file mode 100644 index 0000000000..5caa1f7046 --- /dev/null +++ b/tests/Fixtures/inc/Engine/Optimization/LazyRenderContent/Frontend/Controller/expected-single-line.html @@ -0,0 +1,14 @@ + + + Single line element + + + +
div in body
another div in body
header in div in div in body
another div in header in div in div in body
+ + + diff --git a/tests/Fixtures/inc/Engine/Optimization/LazyRenderContent/Frontend/Controller/optimize.php b/tests/Fixtures/inc/Engine/Optimization/LazyRenderContent/Frontend/Controller/optimize.php index 796c87a39c..c55eee95d8 100644 --- a/tests/Fixtures/inc/Engine/Optimization/LazyRenderContent/Frontend/Controller/optimize.php +++ b/tests/Fixtures/inc/Engine/Optimization/LazyRenderContent/Frontend/Controller/optimize.php @@ -2,6 +2,8 @@ $hashed = file_get_contents( WP_ROCKET_TESTS_FIXTURES_DIR . '/inc/Engine/Optimization/LazyRenderContent/Frontend/Controller/hashed.html' ); $expected = file_get_contents( WP_ROCKET_TESTS_FIXTURES_DIR . '/inc/Engine/Optimization/LazyRenderContent/Frontend/Controller/expected.html' ); +$single_line_hashed = file_get_contents( WP_ROCKET_TESTS_FIXTURES_DIR . '/inc/Engine/Optimization/LazyRenderContent/Frontend/Controller/single-line-hashed.html' ); +$single_line_expected = file_get_contents( WP_ROCKET_TESTS_FIXTURES_DIR . '/inc/Engine/Optimization/LazyRenderContent/Frontend/Controller/expected-single-line.html' ); return [ 'testShouldReturnEarlyWhenNoDbEntry' => [ @@ -36,4 +38,12 @@ 'html' => $hashed, 'expected' => $expected, ], + 'testShouldReturnUpdatedHtmlForSingleLine' => [ + 'config' => [ + 'has_lrc' => true, + 'below_the_fold' => json_encode( [ '7b16eca0652d4703f83ba63e304f2030', '30c5235261141d2450dc033e5c78bbcc', 'b42afa69f728fcc707157eb61efa53cc' ] ), + ], + 'html' => $single_line_hashed, + 'expected' => $single_line_expected, + ], ]; diff --git a/tests/Fixtures/inc/Engine/Optimization/LazyRenderContent/Frontend/Controller/single-line-hashed.html b/tests/Fixtures/inc/Engine/Optimization/LazyRenderContent/Frontend/Controller/single-line-hashed.html new file mode 100644 index 0000000000..3e3eae2c58 --- /dev/null +++ b/tests/Fixtures/inc/Engine/Optimization/LazyRenderContent/Frontend/Controller/single-line-hashed.html @@ -0,0 +1,13 @@ + + + Single line element + + +
div in body
another div in body
header in div in div in body
another div in header in div in div in body
+ + + diff --git a/tests/Unit/inc/Engine/Optimization/LazyRenderContent/Frontend/Controller/optimize.php b/tests/Unit/inc/Engine/Optimization/LazyRenderContent/Frontend/Controller/optimize.php index 30575b979d..17dfc5895d 100644 --- a/tests/Unit/inc/Engine/Optimization/LazyRenderContent/Frontend/Controller/optimize.php +++ b/tests/Unit/inc/Engine/Optimization/LazyRenderContent/Frontend/Controller/optimize.php @@ -13,7 +13,7 @@ /** * @group LRC */ -class TestOptimize extends TestCase { +class Test_Optimize extends TestCase { private $controller; public function set_up() {