45 lines
1.5 KiB
PHP
45 lines
1.5 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace WPMultiCity\Tests;
|
|
|
|
use WPMultiCity\PostType;
|
|
|
|
final class PostTypeTest extends TestCase
|
|
{
|
|
public function test_register_attaches_init_action(): void
|
|
{
|
|
PostType::register();
|
|
|
|
self::assertNotFalse(
|
|
has_action('init', [PostType::class, 'do_register']),
|
|
'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['query_var']);
|
|
self::assertFalse($captured['hierarchical']);
|
|
self::assertSame(8, $captured['menu_position']);
|
|
self::assertSame('Шорткоды', $captured['labels']['name']);
|
|
}
|
|
}
|