Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Miraeld committed Jan 31, 2025
1 parent e3b0f20 commit b334e84
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tests/Fixtures/inc/Engine/Support/Meta/addMetaGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
'cdn' => 0,
'do_caching_mobile_files' => 0,
'preload_links' => 0,
'host_fonts_locally' => 0,
],
'html' => '<html><head></head><body></body></html>',
'expected' => '<html><head></head><body></body></html>',
Expand All @@ -53,8 +54,9 @@
'do_caching_mobile_files' => 1,
'preload_links' => 1,
'is_mobile' => true,
'host_fonts_locally' => 1
],
'html' => '<html><head></head><body></body></html><!-- wpr_remove_unused_css -->',
'expected' => '<html><head><meta name="generator" content="WP Rocket 3.17" data-wpr-features="wpr_remove_unused_css wpr_mobile wpr_preload_links" /></head><body></body></html>',
'expected' => '<html><head><meta name="generator" content="WP Rocket 3.17" data-wpr-features="wpr_remove_unused_css wpr_preload_links wpr_host_fonts_locally wpr_mobile" /></head><body></body></html>',
],
];
6 changes: 6 additions & 0 deletions tests/Unit/inc/Engine/Support/Meta/addMetaGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ public function testShouldReturnExpected( $config, $html, $expected ) {
->andReturn( $config['preload_links'] );
}

if ( isset( $config['host_fonts_locally'] ) ) {
$this->options->shouldReceive( 'get' )
->with( 'host_fonts_locally', 0 )
->andReturn( $config['host_fonts_locally'] );
}

$this->mobile_detect->shouldReceive( 'isMobile' )
->andReturn( $config['is_mobile'] ?? false );

Expand Down

0 comments on commit b334e84

Please sign in to comment.