test: stub current_time() in bootstrap so Logger calls work unmocked
class-logger.php::log() calls current_time() which Brain Monkey does not stub by default. Rather than adding per-test mocks across 9 failing tests, define a global current_time() in bootstrap that returns a sensible value. Agent-Session: cowork-ci-parity-20260414
This commit is contained in:
@@ -61,6 +61,22 @@ if ( ! defined( 'OBJECT' ) ) {
|
|||||||
define( 'OBJECT', 'OBJECT' );
|
define( 'OBJECT', 'OBJECT' );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* current_time() stub — WordPress returns formatted timestamps.
|
||||||
|
* Used by class-logger.php (which Publisher/ChiefEditor/etc call).
|
||||||
|
* Using a real function (not Brain Monkey mock) so tests that don't explicitly
|
||||||
|
* set up expectations for current_time still get a sensible value.
|
||||||
|
*/
|
||||||
|
if ( ! function_exists( 'current_time' ) ) {
|
||||||
|
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
|
||||||
|
function current_time( $type = 'mysql', $gmt = 0 ) {
|
||||||
|
if ( $type === 'timestamp' || $type === 'U' ) {
|
||||||
|
return time();
|
||||||
|
}
|
||||||
|
return gmdate( 'Y-m-d H:i:s' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minimal WP_Query stub for unit tests.
|
* Minimal WP_Query stub for unit tests.
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user