$active, static fn (): string => '4.2.0' ); } private function component(Profile $profile): EnvironmentComponent { return new CompatibilityComponent($profile, static fn (): Compatibility => new Compatibility([$profile])); } public function testAnInactivePluginIsReportedAsNotInstalledWithoutProblems(): void { self::assertSame( ['id' => 'fake', 'active' => false, 'version' => null, 'problems' => [], 'release' => null], $this->component($this->profile(false))->describe() ); } public function testAnActiveWorkingPluginHasItsVersionAndNoProblems(): void { self::assertSame( ['id' => 'fake', 'active' => true, 'version' => '4.2.0', 'problems' => [], 'release' => null], $this->component($this->profile(true))->describe() ); } public function testAnActiveButBrokenPluginListsItsProblems(): void { $described = $this->component($this->profile(true, broken: true))->describe(); self::assertTrue($described['active']); self::assertSame('4.2.0', $described['version']); self::assertNotSame([], $described['problems']); self::assertContainsOnly('string', $described['problems']); self::assertNull($described['release']); } public function testTheCompatibilityIsAskedOnlyWhenDescribing(): void { $asked = 0; $profile = $this->profile(true); $component = new CompatibilityComponent($profile, static function () use (&$asked, $profile): Compatibility { $asked++; return new Compatibility([$profile]); }); self::assertSame(0, $asked); $component->describe(); self::assertSame(1, $asked); } public function testAReleasePerVersionProfileHasItsOwnComponent(): void { $profile = new Profile( 'rel', 'Rel', Tier::ReleasePerVersion, [FakeCapability::Other], matrix: static fn (): CompatibilityMatrix => CompatibilityMatrix::allReleased([FakeCapability::Other]) ); $this->expectException(LogicException::class); new CompatibilityComponent($profile, static fn (): Compatibility => new Compatibility([$profile])); } public function testForProfilesBuildsAComponentPerProfileWithoutReleasePerVersion(): void { $plain = $this->profile(true); $release = new Profile( 'rel', 'Rel', Tier::ReleasePerVersion, [FakeCapability::Other], matrix: static fn (): CompatibilityMatrix => CompatibilityMatrix::allReleased([FakeCapability::Other]) ); $components = CompatibilityComponent::forProfiles(new Compatibility([$release, $plain])); self::assertSame(['fake'], array_map(static fn (CompatibilityComponent $c): string => $c->describe()['id'], $components)); } }