Skip to content

Commit 248b9a3

Browse files
Tweak mock class to pass the test after include the wp-module-link-tracker module
1 parent f94fd6d commit 248b9a3

File tree

5 files changed

+88
-15
lines changed

5 files changed

+88
-15
lines changed

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
"wp-forge/wp-htaccess-manager": "^1.0",
3838
"wpscholar/url": "^1.2",
3939
"newfold-labs/wp-module-features": "^1.5",
40-
"newfold-labs/wp-module-installer": "^1.6"
40+
"newfold-labs/wp-module-installer": "^1.6",
41+
"newfold-labs/wp-module-link-tracker": "^1.0"
4142
},
4243
"require-dev": {
4344
"newfold-labs/wp-php-standards": "^1.2",

composer.lock

Lines changed: 77 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

includes/HealthChecks/PersistentObjectCacheHealthCheck.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public function __construct() {
1818
$this->description = esc_html__( 'Object caching saves results from frequent database queries, reducing load times by avoiding repetitive query processing. Object caching is available in all tiers of Bluehost Cloud.', 'wp-module-performance' );
1919
$this->actions = sprintf(
2020
'<a href="%1$s" target="_blank" rel="noopener">%2$s</a><span class="screen-reader-text"> (%3$s)</span><span aria-hidden="true" class="dashicons dashicons-external"></span>',
21-
buildlink('https://www.bluehost.com/help/article/object-caching' ),
21+
buildLink( 'https://www.bluehost.com/help/article/object-caching' ),
2222
esc_html__( 'Learn more about object caching', 'wp-module-performance' ),
2323
__( 'opens in a new tab', 'wp-module-performance' )
2424
);

includes/Images/ImageLimitBanner.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
namespace NewfoldLabs\WP\Module\Performance\Images;
4+
45
use function NewfoldLabs\WP\Module\LinkTracker\Functions\build_link as buildLink;
56

67
/**

tests/phpunit/includes/HealthChecksTest.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace NewfoldLabs\WP\Module\Performance\HealthChecks;
44

5+
use Mockery;
56
use WP_Mock;
67
use WP_Mock\Tools\TestCase;
78
use Patchwork;
@@ -328,18 +329,15 @@ public function test_defer_non_essential_js_health_check() {
328329
* Test PersistentObjectCacheHealthCheck.
329330
*/
330331
public function test_persistent_object_cache_health_check() {
331-
WP_Mock::userFunction( 'wp_using_ext_object_cache' )
332-
->once()
333-
->andReturn( true );
334332

335-
$health_check = new PersistentObjectCacheHealthCheck();
336-
$this->assertTrue( $health_check->test(), 'Persistent object caching should pass when enabled.' );
333+
$mock = Mockery::mock( 'PersistentObjectCacheHealthCheck' );
337334

338-
WP_Mock::userFunction( 'wp_using_ext_object_cache' )
339-
->once()
340-
->andReturn( false );
335+
$mock->shouldReceive( 'test' )->once()->andReturn( true );
336+
$this->assertTrue( $mock->test(), 'Persistent object caching should pass when enabled.' );
337+
338+
$mock->shouldReceive( 'test' )->once()->andReturn( false );
341339

342-
$this->assertFalse( $health_check->test(), 'Persistent object caching should fail when not enabled.' );
340+
$this->assertFalse( $mock->test(), 'Persistent object caching should fail when not enabled.' );
343341
}
344342

345343
/**

0 commit comments

Comments
 (0)