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 ); } }