From b42cc6b105df2b74db1a9cd2d29523831e0fcc7b Mon Sep 17 00:00:00 2001 From: WordPressFan Date: Mon, 1 Jul 2024 15:08:19 +0300 Subject: [PATCH] set default value for mobile cache to be 1 --- .../Media/AboveTheFold/WarmUp/Controller.php | 7 +----- .../WarmUp/Controller/sendToSass.php | 22 +++++++------------ 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/inc/Engine/Media/AboveTheFold/WarmUp/Controller.php b/inc/Engine/Media/AboveTheFold/WarmUp/Controller.php index 86750d4239..004ebe1cb1 100644 --- a/inc/Engine/Media/AboveTheFold/WarmUp/Controller.php +++ b/inc/Engine/Media/AboveTheFold/WarmUp/Controller.php @@ -240,11 +240,6 @@ public function add_wpr_imagedimensions_query_arg( string $url ): string { * @return bool */ private function is_mobile(): bool { - $plugin_version = (string) get_rocket_option( 'version', '' ); - if ( ! $plugin_version ) { // We are warming up a fresh installation. Options are not set yet. - return true; - } - - return $this->options->get( 'cache_mobile', 0 ) && $this->options->get( 'do_caching_mobile_files', 0 ); + return $this->options->get( 'cache_mobile', 1 ) && $this->options->get( 'do_caching_mobile_files', 1 ); } } diff --git a/tests/Unit/inc/Engine/Media/AboveTheFold/WarmUp/Controller/sendToSass.php b/tests/Unit/inc/Engine/Media/AboveTheFold/WarmUp/Controller/sendToSass.php index 3d84363cbf..b3c79f5c78 100644 --- a/tests/Unit/inc/Engine/Media/AboveTheFold/WarmUp/Controller/sendToSass.php +++ b/tests/Unit/inc/Engine/Media/AboveTheFold/WarmUp/Controller/sendToSass.php @@ -37,15 +37,12 @@ protected function setUp(): void { */ public function testShouldReturnExpected( $config, $expected ) { $this->options->shouldReceive('get') - ->with('cache_mobile', 0) - ->andReturn(0); + ->with( 'cache_mobile', 1 ) + ->andReturn( 1 ); - if('desktop' === $config['device']) { - Functions\expect( 'get_rocket_option' ) - ->once() - ->with( 'version', '' ) - ->andReturn( true ); - } + $this->options->shouldReceive('get') + ->with( 'do_caching_mobile_files', 1 ) + ->andReturn( 1 ); $this->api_client->shouldReceive('add_to_atf_queue') ->with('http://example.com') @@ -53,15 +50,12 @@ public function testShouldReturnExpected( $config, $expected ) { ->andReturn([$config['url'], []]); if('mobile' === $config['device']) { - Functions\expect( 'get_rocket_option' ) - ->once() - ->with( 'version', '' ) - ->andReturn( '' ); + $this->api_client->shouldReceive('add_to_atf_queue') - ->with('http://example.com', $config['device']) + ->with( 'http://example.com', $config['device'] ) ->once() - ->andReturn([$config['url'], []]); + ->andReturn( [$config['url'], []] ); } $this->controller->send_to_saas($config['url']);