Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
69 lines
2.2 KiB
PHP
69 lines
2.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace LIT\MCP\Tests\Unit\Integrations\Divi;
|
|
|
|
use Brain\Monkey\Functions;
|
|
use LIT\MCP\Integrations\Core\EnvironmentComponent;
|
|
use LIT\MCP\Integrations\Divi\DiviCompatibility;
|
|
use LIT\MCP\Integrations\Divi\DiviEnvironmentComponent;
|
|
use LIT\MCP\Tests\Unit\TestCase;
|
|
use Mockery;
|
|
|
|
final class DiviEnvironmentComponentTest extends TestCase
|
|
{
|
|
private function theme(string $template, string $version = '5.2.1'): void
|
|
{
|
|
$theme = Mockery::mock();
|
|
$theme->allows('get_template')->andReturn($template);
|
|
$theme->allows('parent')->andReturn(false);
|
|
$theme->allows('get')->with('Version')->andReturn($version);
|
|
Functions\when('wp_get_theme')->justReturn($theme);
|
|
}
|
|
|
|
public function testIsAnEnvironmentComponent(): void
|
|
{
|
|
self::assertInstanceOf(EnvironmentComponent::class, new DiviEnvironmentComponent());
|
|
}
|
|
|
|
public function testCarriesTheCompatibilityFindings(): void
|
|
{
|
|
$this->theme('Divi');
|
|
$component = new DiviEnvironmentComponent(
|
|
new DiviCompatibility(['GlobalLayout' => static fn (): bool => false])
|
|
);
|
|
|
|
$described = $component->describe();
|
|
|
|
self::assertSame('divi', $described['id']);
|
|
self::assertTrue($described['active']);
|
|
self::assertSame('5.2.1', $described['version']);
|
|
self::assertSame(['GlobalLayout'], $described['problems']);
|
|
}
|
|
|
|
public function testCarriesTheReleaseStatus(): void
|
|
{
|
|
$this->theme('Divi');
|
|
|
|
$described = (new DiviEnvironmentComponent(new DiviCompatibility([])))->describe();
|
|
|
|
self::assertSame([], $described['problems']);
|
|
self::assertSame('released', $described['release']['state'] ?? null);
|
|
}
|
|
|
|
public function testIsInactiveWithoutDiviAndHasNoProblemsOrRelease(): void
|
|
{
|
|
$this->theme('twentytwentysix', '1.0');
|
|
|
|
$described = (new DiviEnvironmentComponent(
|
|
new DiviCompatibility(['GlobalLayout' => static fn (): bool => false])
|
|
))->describe();
|
|
|
|
self::assertSame(
|
|
['id' => 'divi', 'active' => false, 'version' => null, 'problems' => [], 'release' => null],
|
|
$described
|
|
);
|
|
}
|
|
}
|