feat(wpmc S3): procedural wpmc_* API + smoke test

Also fixes PluginBootTest to be order-independent (reset booted flag)
and to expect ShortcodeDmr hook that boot() now wires.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Vladimir Bryzgalov
2026-05-12 20:11:47 +05:00
parent 3dbca34234
commit d8b0d01f1c
4 changed files with 60 additions and 1 deletions
+13
View File
@@ -197,4 +197,17 @@ final class HelpersTest extends TestCase
self::assertSame('mailto:x@y.com', Helpers::remove_domain_link('mailto:x@y.com'));
self::assertSame('not a url', Helpers::remove_domain_link('not a url'));
}
public function test_wpmc_procedural_functions_proxy_to_helpers(): void
{
require_once dirname(__DIR__) . '/includes/wpmc-functions.php';
self::assertTrue(function_exists('wpmc_current_town'));
self::assertTrue(function_exists('wpmc_get_term_by_slug'));
self::assertTrue(function_exists('wpmc_alt_get_field'));
self::assertTrue(function_exists('wpmc_remove_domain_link'));
// remove_domain_link is pure (no WP function dependencies) — exercise the proxy.
self::assertSame('/foo/', wpmc_remove_domain_link('https://site.com/foo/'));
}
}
+14 -1
View File
@@ -14,7 +14,13 @@ final class PluginBootTest extends TestCase
eval('class ACF {}');
}
Plugin::instance()->boot();
// Reset booted flag so this test is order-independent.
$plugin = Plugin::instance();
$reflection = new \ReflectionClass($plugin);
$prop = $reflection->getProperty('booted');
$prop->setValue($plugin, false);
$plugin->boot();
self::assertNotFalse(
has_action('init', ['WPMultiCity\\Taxonomy', 'do_register']),
@@ -28,6 +34,10 @@ final class PluginBootTest extends TestCase
has_action('acf/init', ['WPMultiCity\\FieldGroup', 'do_register']),
'boot() must register FieldGroup on acf/init'
);
self::assertNotFalse(
has_action('init', ['WPMultiCity\\ShortcodeDmr', 'do_register']),
'boot() must register ShortcodeDmr on init'
);
}
public function test_boot_is_idempotent_when_called_multiple_times(): void
@@ -55,6 +65,9 @@ final class PluginBootTest extends TestCase
\Brain\Monkey\Actions\expectAdded('acf/init')
->with([\WPMultiCity\FieldGroup::class, 'do_register'])
->once();
\Brain\Monkey\Actions\expectAdded('init')
->with([\WPMultiCity\ShortcodeDmr::class, 'do_register'])
->once();
$plugin->boot();
$plugin->boot();