Files
WP-LIT-MCP/tests/Integration/tec-probe.php
T
janniclas.loosenandClaude Opus 5.5 0e3332ad3e fix: close etappe-0 whole-branch review findings
- Autoloader: add automattic/jetpack-autoloader and load
  vendor/autoload_packages.php; require wordpress/mcp-adapter directly (^0.5).
- ServerRegistrar: make the adapter create_server() call and the
  OAuthServerRegistrar class_exists() check injectable so createServer()'s
  unhook-before-create ordering and the "mcp-oauth absent" branch are unit
  tested; add a smoke-test check that booting REST triggers no
  _doing_it_wrong().
- mcp-smoke.sh: assert mcp-adapter's default server route 404s, and that the
  subscriber role-gate denial actually carries our/the adapter's denial text
  (not just any isError/error).
- Guard tests/Integration/mint-token.php and tec-probe.php with
  `defined('WP_CLI') && WP_CLI || exit;`; add .gitattributes export-ignore
  for tests/docs-superpowers/.superpowers/phpunit/phpcs config.
- Security: add Server/RequestContext, tracking via
  rest_request_before_callbacks whether the current REST dispatch is our
  OAuth-protected /mcp/mcp-oauth-server route; AbilityRegistrar's
  permission_callback now denies (after the role gate) when abilities are
  invoked outside that route. Wired in Plugin::boot().
- Minors: single Plugin::VERSION constant used by ServerRegistrar;
  IntegrationRegistry caches its computed abilities list; tec-probe.php
  checks wp_insert_post's result and cleans up its probe post in a
  try/finally.

composer test: 47/47 green. composer lint: clean. Full mcp-smoke.sh run ends
ALL CHECKS PASSED (plus the expected /.well-known WARN).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
2026-09-25 19:23:09 +02:00

61 lines
1.7 KiB
PHP

<?php
/**
* Checks whether a The Events Calendar event created only through generic
* WordPress APIs (wp_insert_post + post meta) is found by TEC's own queries.
*
* Usage: wp eval-file tests/Integration/tec-probe.php
*
* No strict_types: PHP forbids declare(strict_types) inside eval(), which wp eval-file uses.
*/
defined('WP_CLI') && WP_CLI || exit;
if (! class_exists('Tribe__Events__Main')) {
fwrite(STDERR, "The Events Calendar is not active\n");
exit(1);
}
$start = gmdate('Y-m-d', strtotime('+30 days')) . ' 18:00:00';
$end = gmdate('Y-m-d', strtotime('+30 days')) . ' 20:00:00';
$id = wp_insert_post([
'post_type' => 'tribe_events',
'post_status' => 'publish',
'post_title' => 'LIT Probe Event (wegwerfen)',
], true);
if (is_wp_error($id)) {
fwrite(STDERR, 'wp_insert_post failed: ' . $id->get_error_message() . "\n");
exit(1);
}
if (! $id) {
fwrite(STDERR, "wp_insert_post returned no post id\n");
exit(1);
}
try {
update_post_meta($id, '_EventStartDate', $start);
update_post_meta($id, '_EventEndDate', $end);
$derived = [];
foreach (['_EventStartDateUTC', '_EventEndDateUTC', '_EventDuration', '_EventTimezone'] as $key) {
$derived[$key] = get_post_meta($id, $key, true);
}
$found = tribe_get_events([
'start_date' => gmdate('Y-m-d', strtotime('+29 days')),
'end_date' => gmdate('Y-m-d', strtotime('+31 days')),
'fields' => 'ids',
]);
echo wp_json_encode([
'event_id' => $id,
'found_by_tribe_get_events' => in_array($id, (array) $found, true),
'derived_meta' => $derived,
], JSON_PRETTY_PRINT) . "\n";
} finally {
wp_delete_post($id, true);
}