From f95d09cc891de0b6e1ae1e066fa974fc2189537e Mon Sep 17 00:00:00 2001 From: Vladimir Bryzgalov Date: Tue, 12 May 2026 17:42:36 +0500 Subject: [PATCH] feat(wpmc S2): register CPT shortcode-town with required args Co-Authored-By: Claude Sonnet 4.6 --- includes/class-post-type.php | 29 ++++++++++++++++++++++++++++- tests/PostTypeTest.php | 24 ++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) diff --git a/includes/class-post-type.php b/includes/class-post-type.php index 541c0eb..4203de5 100644 --- a/includes/class-post-type.php +++ b/includes/class-post-type.php @@ -14,6 +14,33 @@ final class PostType public static function do_register(): void { - // Implementation filled in Task 9. + register_post_type(self::SLUG, [ + 'labels' => [ + 'name' => __('Шорткоды', 'wp-multi-city'), + 'singular_name' => __('Шорткод', 'wp-multi-city'), + 'menu_name' => __('Шорткоды', 'wp-multi-city'), + 'add_new' => __('Добавить', 'wp-multi-city'), + 'add_new_item' => __('Добавить шорткод', 'wp-multi-city'), + 'edit_item' => __('Редактировать', 'wp-multi-city'), + 'new_item' => __('Новый', 'wp-multi-city'), + 'view_item' => __('Смотреть', 'wp-multi-city'), + 'search_items' => __('Поиск', 'wp-multi-city'), + 'not_found' => __('Не найдено', 'wp-multi-city'), + ], + 'public' => false, + 'exclude_from_search' => true, + 'publicly_queryable' => false, + 'show_ui' => true, + 'show_in_menu' => true, + 'show_in_nav_menus' => false, + 'show_in_rest' => false, + 'query_var' => false, + 'has_archive' => false, + 'rewrite' => false, + 'hierarchical' => false, + 'capability_type' => 'post', + 'supports' => ['title'], + 'menu_position' => 8, + ]); } } diff --git a/tests/PostTypeTest.php b/tests/PostTypeTest.php index 1540d22..c4b41ef 100644 --- a/tests/PostTypeTest.php +++ b/tests/PostTypeTest.php @@ -16,4 +16,28 @@ final class PostTypeTest extends TestCase 'PostType::register() must attach init action with do_register handler' ); } + + public function test_do_register_calls_register_post_type_shortcode_town_with_required_args(): void + { + $captured = null; + \Brain\Monkey\Functions\expect('register_post_type') + ->once() + ->with('shortcode-town', \Mockery::on(function ($args) use (&$captured) { + $captured = $args; + return true; + })); + + PostType::do_register(); + + self::assertFalse($captured['public'], 'CPT must be non-public'); + self::assertTrue($captured['show_ui'], 'CPT must show in admin'); + self::assertSame(['title'], $captured['supports']); + self::assertTrue($captured['exclude_from_search']); + self::assertFalse($captured['publicly_queryable']); + self::assertFalse($captured['has_archive']); + self::assertFalse($captured['rewrite']); + self::assertFalse($captured['hierarchical']); + self::assertSame(8, $captured['menu_position']); + self::assertSame('Шорткоды', $captured['labels']['name']); + } }