feat(wpmc S4): Plugin::boot wires OptionsPage + TermMeta + Router + Redirect
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -51,6 +51,10 @@ final class Plugin
|
||||
PostType::register();
|
||||
FieldGroup::register();
|
||||
ShortcodeDmr::register();
|
||||
OptionsPage::register();
|
||||
TermMeta::register();
|
||||
Redirect::register();
|
||||
Router::register();
|
||||
}
|
||||
|
||||
private function dependencies_satisfied(): bool
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace WPMultiCity\Tests;
|
||||
|
||||
use WPMultiCity\Plugin;
|
||||
|
||||
final class PluginBootS4Test extends TestCase
|
||||
{
|
||||
public function test_boot_wires_s4_registrations(): void
|
||||
{
|
||||
if (!class_exists('ACF', false)) {
|
||||
eval('class ACF {}');
|
||||
}
|
||||
|
||||
$plugin = Plugin::instance();
|
||||
$reflection = new \ReflectionClass($plugin);
|
||||
$prop = $reflection->getProperty('booted');
|
||||
$prop->setValue($plugin, false);
|
||||
|
||||
$plugin->boot();
|
||||
|
||||
self::assertNotFalse(
|
||||
has_action('acf/init', ['WPMultiCity\\OptionsPage', 'do_register']),
|
||||
'boot() must register OptionsPage on acf/init'
|
||||
);
|
||||
self::assertNotFalse(
|
||||
has_action('acf/init', ['WPMultiCity\\TermMeta', 'do_register']),
|
||||
'boot() must register TermMeta on acf/init'
|
||||
);
|
||||
self::assertSame(
|
||||
9999,
|
||||
has_action('wp', ['WPMultiCity\\Router', 'route']),
|
||||
'boot() must register Router on wp@9999'
|
||||
);
|
||||
self::assertSame(
|
||||
9998,
|
||||
has_action('wp', ['WPMultiCity\\Redirect', 'handle']),
|
||||
'boot() must register Redirect on wp@9998'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -68,6 +68,18 @@ final class PluginBootTest extends TestCase
|
||||
\Brain\Monkey\Actions\expectAdded('init')
|
||||
->with([\WPMultiCity\ShortcodeDmr::class, 'do_register'])
|
||||
->once();
|
||||
\Brain\Monkey\Actions\expectAdded('acf/init')
|
||||
->with([\WPMultiCity\OptionsPage::class, 'do_register'])
|
||||
->once();
|
||||
\Brain\Monkey\Actions\expectAdded('acf/init')
|
||||
->with([\WPMultiCity\TermMeta::class, 'do_register'])
|
||||
->once();
|
||||
\Brain\Monkey\Actions\expectAdded('wp')
|
||||
->with([\WPMultiCity\Redirect::class, 'handle'], 9998)
|
||||
->once();
|
||||
\Brain\Monkey\Actions\expectAdded('wp')
|
||||
->with([\WPMultiCity\Router::class, 'route'], 9999)
|
||||
->once();
|
||||
|
||||
$plugin->boot();
|
||||
$plugin->boot();
|
||||
|
||||
Reference in New Issue
Block a user