Files
WP-LIT-MCP/tests/Unit/Integrations/WordPress/Menus/MenuFixtures.php
T

37 lines
1009 B
PHP

<?php
declare(strict_types=1);
namespace LIT\MCP\Tests\Unit\Integrations\WordPress\Menus;
/**
* Shared wp_get_nav_menu_items()-shaped fixture, reused by every menu test
* (tree building, read/write abilities, and the Task 14 menu-set-items tests).
*/
trait MenuFixtures
{
public static function item(
int $id,
int $parent,
string $title,
string $type = 'post_type',
string $url = ''
): object {
return (object) [
'ID' => $id,
'menu_item_parent' => (string) $parent,
'title' => $title,
'post_title' => $type === 'custom' ? $title : '',
'type' => $type,
'object' => $type === 'custom' ? 'custom' : 'page',
'object_id' => (string) ($type === 'custom' ? $id : $id + 100),
'url' => $url,
'description' => '',
'attr_title' => '',
'target' => '',
'classes' => [''],
'xfn' => '',
];
}
}