From 83cff8fb3ed8d1c039b2362c2d4df5df746e74d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Perona?= Date: Tue, 22 Oct 2024 10:51:33 -0400 Subject: [PATCH] update tests --- .../inc/Engine/Support/Meta/addMetaGenerator.php | 13 ++++++++++--- .../inc/Engine/Support/Meta/addMetaGenerator.php | 11 +++++++---- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/tests/Fixtures/inc/Engine/Support/Meta/addMetaGenerator.php b/tests/Fixtures/inc/Engine/Support/Meta/addMetaGenerator.php index db926e9b39..409be3e718 100644 --- a/tests/Fixtures/inc/Engine/Support/Meta/addMetaGenerator.php +++ b/tests/Fixtures/inc/Engine/Support/Meta/addMetaGenerator.php @@ -29,10 +29,17 @@ 'html' => '', 'expected' => '', ], + 'testShouldReturnDefaultWhenLoggedIn' => [ + 'config' => [ + 'is_user_logged_in' => true, + ], + 'html' => '', + 'expected' => '', + ], 'testShouldReturnDefaultWhenNoFeatures' => [ 'config' => [ 'disable_meta' => false, - 'cache' => false, + 'cdn' => 0, 'do_caching_mobile_files' => 0, 'preload_links' => 0, ], @@ -42,12 +49,12 @@ 'testShouldReturnAddMeta' => [ 'config' => [ 'disable_meta' => false, - 'cache' => true, + 'cdn' => 0, 'do_caching_mobile_files' => 1, 'preload_links' => 1, 'is_mobile' => true, ], 'html' => '', - 'expected' => '', + 'expected' => '', ], ]; diff --git a/tests/Unit/inc/Engine/Support/Meta/addMetaGenerator.php b/tests/Unit/inc/Engine/Support/Meta/addMetaGenerator.php index a360c39088..e3d29a473a 100644 --- a/tests/Unit/inc/Engine/Support/Meta/addMetaGenerator.php +++ b/tests/Unit/inc/Engine/Support/Meta/addMetaGenerator.php @@ -46,10 +46,7 @@ public function testShouldReturnExpected( $config, $html, $expected ) { ->andReturn( $config['disable_meta'] ); } - if ( isset( $config['cache'] ) ) { - Filters\expectApplied( 'do_rocket_generate_caching_files' ) - ->andReturn( $config['cache'] ); - } + Functions\when( 'is_user_logged_in' )->justReturn( $config['is_user_logged_in'] ?? false ); if ( isset( $config['do_caching_mobile_files'] ) ) { $this->options->shouldReceive( 'get' ) @@ -57,6 +54,12 @@ public function testShouldReturnExpected( $config, $html, $expected ) { ->andReturn( $config['do_caching_mobile_files'] ); } + if ( isset( $config['cdn'] ) ) { + $this->options->shouldReceive( 'get' ) + ->with( 'cdn', 0 ) + ->andReturn( $config['cdn'] ); + } + Functions\when( 'rocket_get_dns_prefetch_domains' )->justReturn( [] ); if ( isset( $config['preload_links'] ) ) {