test(wpmc S4): restore ACF-missing guard assertions + tighten stub signature
Re-add ->never() to both noop tests so Brain Monkey/Mockery actively asserts
acf_add_local_field_group is never called when ACF is absent. Order matters:
expect() must precede when('function_exists')->alias() so FunctionStub sees the
real function_exists and skips the eval() path (function already declared in
acf-stubs.php). Also tighten stub signature to match real ACF ($field_group,
no type hint, no default).
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -19,15 +19,18 @@ final class TermMetaTest extends TestCase
|
||||
|
||||
public function test_do_register_is_noop_when_acf_missing(): void
|
||||
{
|
||||
// Set up the ->never() expectation BEFORE aliasing function_exists, so that
|
||||
// FunctionStub::__construct() sees the real function_exists and skips the
|
||||
// eval() path (the function is already declared in acf-stubs.php).
|
||||
\Brain\Monkey\Functions\expect('acf_add_local_field_group')->never();
|
||||
\Brain\Monkey\Functions\when('function_exists')->alias(function ($name) {
|
||||
return $name !== 'acf_add_local_field_group';
|
||||
});
|
||||
|
||||
// acf_add_local_field_group is NOT stubbed here: if do_register() called it,
|
||||
// the Brain\Monkey eval-stub would throw MissingFunctionExpectations.
|
||||
// We just verify the method returns without error.
|
||||
TermMeta::do_register();
|
||||
|
||||
// ->never() above is the actual guard assertion; assertTrue keeps
|
||||
// PHPUnit happy under failOnRisky.
|
||||
self::assertTrue(true);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user