feat(wpmc S2): Taxonomy::register() attaches init hook

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Vladimir Bryzgalov
2026-05-12 17:36:26 +05:00
parent 945ae898ac
commit 53a784bbe8
2 changed files with 62 additions and 0 deletions
+43
View File
@@ -0,0 +1,43 @@
<?php
declare(strict_types=1);
namespace WPMultiCity\Tests;
use Brain\Monkey\Actions;
use WPMultiCity\Taxonomy;
final class TaxonomyTest extends TestCase
{
public function test_register_attaches_init_action(): void
{
Taxonomy::register();
self::assertNotFalse(
has_action('init', [Taxonomy::class, 'do_register']),
'Taxonomy::register() must attach init action with do_register handler'
);
}
public function test_do_register_calls_register_taxonomy_town_with_required_args(): void
{
$captured = null;
\Brain\Monkey\Functions\expect('register_taxonomy')
->once()
->with('town', ['shortcode-town'], \Mockery::on(function ($args) use (&$captured) {
$captured = $args;
return true;
}));
Taxonomy::do_register();
self::assertFalse($captured['hierarchical'], 'town must be flat');
self::assertFalse($captured['public'], 'town must not be public');
self::assertTrue($captured['show_ui'], 'town must show in admin UI');
self::assertTrue($captured['show_in_rest'], 'town must be REST-exposed');
self::assertFalse($captured['publicly_queryable']);
self::assertFalse($captured['query_var']);
self::assertFalse($captured['rewrite']);
self::assertFalse($captured['meta_box_cb']);
self::assertSame('Города', $captured['labels']['name']);
}
}