Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
remyperona committed Oct 22, 2024
1 parent c93898e commit 83cff8f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
13 changes: 10 additions & 3 deletions tests/Fixtures/inc/Engine/Support/Meta/addMetaGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,17 @@
'html' => '<html><head></head><body></body></html>',
'expected' => '<html><head></head><body></body></html>',
],
'testShouldReturnDefaultWhenLoggedIn' => [
'config' => [
'is_user_logged_in' => true,
],
'html' => '<html><head></head><body></body></html>',
'expected' => '<html><head></head><body></body></html>',
],
'testShouldReturnDefaultWhenNoFeatures' => [
'config' => [
'disable_meta' => false,
'cache' => false,
'cdn' => 0,
'do_caching_mobile_files' => 0,
'preload_links' => 0,
],
Expand All @@ -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' => '<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_cached wpr_cached_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_mobile wpr_preload_links" /></head><body></body></html>',
],
];
11 changes: 7 additions & 4 deletions tests/Unit/inc/Engine/Support/Meta/addMetaGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,20 @@ 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' )
->with( 'do_caching_mobile_files', 0 )
->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'] ) ) {
Expand Down

0 comments on commit 83cff8f

Please sign in to comment.