Skip to content

Commit

Permalink
Make sure to send mobile visit to saas warmup for OCI with a fresh in…
Browse files Browse the repository at this point in the history
…stall (#6753)
  • Loading branch information
wordpressfan authored Jul 2, 2024
1 parent 6367742 commit 77ed4f2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 21 deletions.
7 changes: 1 addition & 6 deletions inc/Engine/Media/AboveTheFold/WarmUp/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,32 +36,26 @@ protected function setUp(): void {
* @dataProvider configTestData
*/
public function testShouldReturnExpected( $config, $expected ) {
$mobile_cache = 'mobile' === $config['device'] ? 1 : 0;

$this->options->shouldReceive('get')
->with('cache_mobile', 0)
->andReturn(0);
->with( 'cache_mobile', 1 )
->andReturn( $mobile_cache );

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( $mobile_cache );

$this->api_client->shouldReceive('add_to_atf_queue')
->with('http://example.com')
->once()
->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']);
Expand Down

0 comments on commit 77ed4f2

Please sign in to comment.