feat: plugin scaffold with dependency check
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
if (! class_exists('WP_Error')) {
|
||||
class WP_Error
|
||||
{
|
||||
public function __construct(
|
||||
private string $code = '',
|
||||
private string $message = '',
|
||||
private mixed $data = null
|
||||
) {
|
||||
}
|
||||
|
||||
public function get_error_code(): string
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
public function get_error_message(): string
|
||||
{
|
||||
return $this->message;
|
||||
}
|
||||
|
||||
public function get_error_data(): mixed
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
if (! class_exists('WP_User')) {
|
||||
class WP_User
|
||||
{
|
||||
public int $ID = 0;
|
||||
public array $roles = [];
|
||||
|
||||
public function __construct(int $id = 0, array $roles = [])
|
||||
{
|
||||
$this->ID = $id;
|
||||
$this->roles = $roles;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Tests\Unit;
|
||||
|
||||
use LIT\MCP\Dependencies;
|
||||
|
||||
final class DependenciesTest extends TestCase
|
||||
{
|
||||
public function testReportsNothingMissingWhenAllClassesExist(): void
|
||||
{
|
||||
$deps = new Dependencies(static fn (string $class): bool => true);
|
||||
|
||||
self::assertSame([], $deps->missing());
|
||||
}
|
||||
|
||||
public function testNamesEveryMissingComponent(): void
|
||||
{
|
||||
$deps = new Dependencies(static fn (string $class): bool => false);
|
||||
|
||||
self::assertSame(
|
||||
['wordpress/mcp-adapter', 'wp-media/mcp-oauth', 'WordPress Abilities API'],
|
||||
$deps->missing()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Tests\Unit;
|
||||
|
||||
use Brain\Monkey;
|
||||
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
|
||||
use PHPUnit\Framework\TestCase as BaseTestCase;
|
||||
|
||||
abstract class TestCase extends BaseTestCase
|
||||
{
|
||||
use MockeryPHPUnitIntegration;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Monkey\setUp();
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
Monkey\tearDown();
|
||||
parent::tearDown();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
if (! defined('ABSPATH')) {
|
||||
define('ABSPATH', __DIR__ . '/');
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
require_once __DIR__ . '/Stubs/WpError.php';
|
||||
require_once __DIR__ . '/Stubs/WpUser.php';
|
||||
Reference in New Issue
Block a user