43 lines
1.4 KiB
PHP
43 lines
1.4 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace WPMultiCity\Tests;
|
|
|
|
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']);
|
|
}
|
|
}
|