diff --git a/HISTORY.md b/HISTORY.md index e58e30aa..e402c5df 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -12,16 +12,19 @@ All notable changes to this project will be documented in this file. * Changed * Method `\CycloneDX\Core\Serialize\{DOM,JSON}\Normalizers\ExternalReferenceNormalizer::normalize` throw `DomainException` when `ExternalReference`'s type was not supported by the spec. (via [#65]) This is considered a non-breaking change, because the behaviour was already documented in the API, even though there was no need for an implementation before. + * Class `\CycloneDX\Core\Models\Component`'s property `version` is optional now, to reflect CycloneDX v1.4. (via [#118]) + This affects constructor arguments, and affects methods `{get,set}Version()`. * Added * New class constant `\CycloneDX\Core\Spec\Version::V_1_4` for CycloneDX v1.4. (via [#65]) * New class `\CycloneDX\Core\Spec\Spec14` to reflect CycloneDX v1.4. (via [#65]) - * Support for CycloneDX v1.4 in `CycloneDX\Core\Validation\Validators\{Json,Xml}StrictValidator`. (via [#65]) + * Support for CycloneDX v1.4 in `\CycloneDX\Core\Validation\Validators\{Json,Xml}StrictValidator`. (via [#65]) * New methods in class `\CycloneDX\Core\Spec\Spec1{1,2,3}` (via [#65]) * `::getSupportsExternalReferenceTypes()` * `::isSupportsExternalReferenceType()` * New class constant `CycloneDX\Core\Enums\ExternalReferenceType::RELEASE_NOTES` to reflect CycloneDX v1.4. (via [#65]) [#65]: https://github.com/CycloneDX/cyclonedx-php-library/pull/65 +[#118]: https://github.com/CycloneDX/cyclonedx-php-library/pull/118 ## 1.6.2 - 2022-09-12 diff --git a/src/Core/Models/Component.php b/src/Core/Models/Component.php index d65ad78e..29ac5e70 100644 --- a/src/Core/Models/Component.php +++ b/src/Core/Models/Component.php @@ -138,9 +138,7 @@ class Component * The component version. The version should ideally comply with semantic versioning * but is not enforced. * - * @var string - * - * @psalm-suppress PropertyNotSetInConstructor + * @var string|null */ private $version; @@ -303,7 +301,7 @@ public function setHashRepository(?HashRepository $hashRepository): self return $this; } - public function getVersion(): string + public function getVersion(): ?string { return $this->version; } @@ -311,7 +309,7 @@ public function getVersion(): string /** * @return $this */ - public function setVersion(string $version): self + public function setVersion(?string $version): self { $this->version = $version; @@ -368,7 +366,7 @@ public function setExternalReferenceRepository(?ExternalReferenceRepository $ext * * @throws DomainException if type is unknown */ - public function __construct(string $type, string $name, string $version) + public function __construct(string $type, string $name, ?string $version = null) { $this->setType($type); $this->setName($name); diff --git a/src/Core/Serialize/DOM/Normalizers/ComponentNormalizer.php b/src/Core/Serialize/DOM/Normalizers/ComponentNormalizer.php index 7a548512..a46e5405 100644 --- a/src/Core/Serialize/DOM/Normalizers/ComponentNormalizer.php +++ b/src/Core/Serialize/DOM/Normalizers/ComponentNormalizer.php @@ -58,7 +58,10 @@ public function normalize(Component $component): DOMElement $type = $component->getType(); if (false === $spec->isSupportedComponentType($type)) { - $reportFQN = "$group/$name@$version"; + $reportFQN = "$group/$name"; + if (null !== $version) { + $reportFQN .= "@$version"; + } throw new DomainException("Component '$reportFQN' has unsupported type: $type"); } @@ -80,7 +83,11 @@ public function normalize(Component $component): DOMElement // publisher $this->simpleDomSafeTextElement($document, 'group', $group), $this->simpleDomSafeTextElement($document, 'name', $name), - $this->simpleDomSafeTextElement($document, 'version', $version), + $this->simpleDomSafeTextElement($document, 'version', + null === $version && $spec->requiresComponentVersion() + ? '' + : $version + ), $this->simpleDomSafeTextElement($document, 'description', $component->getDescription()), // scope $this->normalizeHashes($component->getHashRepository()), diff --git a/src/Core/Serialize/JSON/Normalizers/ComponentNormalizer.php b/src/Core/Serialize/JSON/Normalizers/ComponentNormalizer.php index 27b8cb81..1f158811 100644 --- a/src/Core/Serialize/JSON/Normalizers/ComponentNormalizer.php +++ b/src/Core/Serialize/JSON/Normalizers/ComponentNormalizer.php @@ -54,7 +54,10 @@ public function normalize(Component $component): array $type = $component->getType(); if (false === $spec->isSupportedComponentType($type)) { - $reportFQN = "$group/$name@$version"; + $reportFQN = "$group/$name"; + if (null !== $version) { + $reportFQN .= "@$version"; + } throw new DomainException("Component '$reportFQN' has unsupported type: $type"); } @@ -67,7 +70,9 @@ public function normalize(Component $component): array 'bom-ref' => $bomRef, 'type' => $type, 'name' => $name, - 'version' => $version, + 'version' => null === $version && $spec->requiresComponentVersion() + ? '' + : $version, 'group' => $group, 'description' => $component->getDescription(), 'licenses' => $this->normalizeLicense($component->getLicense()), diff --git a/src/Core/Spec/Spec11.php b/src/Core/Spec/Spec11.php index 880dc98e..33874af5 100644 --- a/src/Core/Spec/Spec11.php +++ b/src/Core/Spec/Spec11.php @@ -103,4 +103,9 @@ public function supportsExternalReferenceHashes(): bool { return false; } + + public function requiresComponentVersion(): bool + { + return true; + } } diff --git a/src/Core/Spec/Spec12.php b/src/Core/Spec/Spec12.php index 8aeded1b..c52a7207 100644 --- a/src/Core/Spec/Spec12.php +++ b/src/Core/Spec/Spec12.php @@ -111,4 +111,9 @@ public function supportsExternalReferenceHashes(): bool { return false; } + + public function requiresComponentVersion(): bool + { + return true; + } } diff --git a/src/Core/Spec/Spec13.php b/src/Core/Spec/Spec13.php index 4c281b13..3cb4d143 100644 --- a/src/Core/Spec/Spec13.php +++ b/src/Core/Spec/Spec13.php @@ -111,4 +111,9 @@ public function supportsExternalReferenceHashes(): bool { return true; } + + public function requiresComponentVersion(): bool + { + return true; + } } diff --git a/src/Core/Spec/Spec14.php b/src/Core/Spec/Spec14.php index 6268823b..7f9094ed 100644 --- a/src/Core/Spec/Spec14.php +++ b/src/Core/Spec/Spec14.php @@ -115,4 +115,9 @@ public function supportsExternalReferenceHashes(): bool { return true; } + + public function requiresComponentVersion(): bool + { + return false; + } } diff --git a/src/Core/Spec/SpecInterface.php b/src/Core/Spec/SpecInterface.php index fe617aa0..810218cf 100644 --- a/src/Core/Spec/SpecInterface.php +++ b/src/Core/Spec/SpecInterface.php @@ -102,4 +102,9 @@ public function isSupportsExternalReferenceType(string $referenceType): bool; * version < 1.3 does not support hashes in ExternalReference. */ public function supportsExternalReferenceHashes(): bool; + + /** + * version < 1.4 requires components to have a version, later it became optional. + */ + public function requiresComponentVersion(): bool; } diff --git a/tests/Core/Serialize/DOM/Normalizers/ComponentNormalizerTest.php b/tests/Core/Serialize/DOM/Normalizers/ComponentNormalizerTest.php index f2d10434..c0e01cd9 100644 --- a/tests/Core/Serialize/DOM/Normalizers/ComponentNormalizerTest.php +++ b/tests/Core/Serialize/DOM/Normalizers/ComponentNormalizerTest.php @@ -54,7 +54,6 @@ public function testNormalizeThrowsOnUnsupportedType(): void Component::class, [ 'getName' => 'foo', - 'getVersion' => 'some-version', 'getType' => 'FakeType', ] ); @@ -62,7 +61,8 @@ public function testNormalizeThrowsOnUnsupportedType(): void $factory = $this->createConfiguredMock(NormalizerFactory::class, ['getSpec' => $spec]); $normalizer = new Normalizers\ComponentNormalizer($factory); - $spec->expects(self::once())->method('isSupportedComponentType') + $spec->expects(self::once()) + ->method('isSupportedComponentType') ->with('FakeType') ->willReturn(false); @@ -72,13 +72,16 @@ public function testNormalizeThrowsOnUnsupportedType(): void $normalizer->normalize($component); } - public function testNormalizeMinimal(): void + /** + * @dataProvider dbNormalizeMinimal + */ + public function testNormalizeMinimal(string $expected, bool $requiresComponentVersion): void { $component = $this->createConfiguredMock( Component::class, [ 'getName' => 'myName', - 'getVersion' => 'some-version', + 'getVersion' => null, 'getType' => 'FakeType', 'getGroup' => null, 'getDescription' => null, @@ -94,16 +97,28 @@ public function testNormalizeMinimal(): void ); $normalizer = new Normalizers\ComponentNormalizer($factory); - $spec->expects(self::once())->method('isSupportedComponentType') + $spec->expects(self::once()) + ->method('isSupportedComponentType') ->with('FakeType') ->willReturn(true); + $spec->method('requiresComponentVersion') + ->willReturn($requiresComponentVersion); - $got = $normalizer->normalize($component); + $actual = $normalizer->normalize($component); - self::assertStringEqualsDomNode( - 'myNamesome-version', - $got - ); + self::assertStringEqualsDomNode($expected, $actual); + } + + public function dbNormalizeMinimal(): \Generator + { + yield 'mandatory ComponentVersion' => [ + 'myName', + true, + ]; + yield 'optional ComponentVersion' => [ + 'myName', + false, + ]; } /** @@ -148,13 +163,16 @@ public function testNormalizeFull(): void ); $normalizer = new Normalizers\ComponentNormalizer($factory); - $spec->expects(self::once())->method('isSupportedComponentType') + $spec->expects(self::once()) + ->method('isSupportedComponentType') ->with('FakeType') ->willReturn(true); - $licenseExpressionNormalizer->expects(self::once())->method('normalize') + $licenseExpressionNormalizer->expects(self::once()) + ->method('normalize') ->with($component->getLicense()) ->willReturn($factory->getDocument()->createElement('FakeLicense', 'dummy')); - $hashRepositoryNormalizer->expects(self::once())->method('normalize') + $hashRepositoryNormalizer->expects(self::once()) + ->method('normalize') ->with($component->getHashRepository()) ->willReturn([$factory->getDocument()->createElement('FakeHash', 'dummy')]); @@ -185,7 +203,6 @@ public function testNormalizeUnsupportedLicenseExpression(): void Component::class, [ 'getName' => 'myName', - 'getVersion' => 'some-version', 'getType' => 'FakeType', 'getLicense' => $this->createConfiguredMock(LicenseExpression::class, ['getExpression' => 'myLicense']), ] @@ -217,10 +234,12 @@ public function testNormalizeUnsupportedLicenseExpression(): void return true; }; - $spec->expects(self::once())->method('isSupportedComponentType') + $spec->expects(self::once()) + ->method('isSupportedComponentType') ->with('FakeType') ->willReturn(true); - $licenseNormalizer->expects(self::once())->method('normalize') + $licenseNormalizer->expects(self::once()) + ->method('normalize') ->with($this->callback($transformedLicenseTest)) ->willReturn([$factory->getDocument()->createElement('FakeLicense', 'dummy')]); @@ -229,7 +248,6 @@ public function testNormalizeUnsupportedLicenseExpression(): void self::assertStringEqualsDomNode( ''. 'myName'. - 'some-version'. 'dummy'. '', $got @@ -242,7 +260,6 @@ public function testNormalizeDisjunctiveLicenses(): void Component::class, [ 'getName' => 'myName', - 'getVersion' => 'some-version', 'getType' => 'FakeType', 'getLicense' => $this->createConfiguredMock(DisjunctiveLicenseRepository::class, ['count' => 1]), ] @@ -259,10 +276,12 @@ public function testNormalizeDisjunctiveLicenses(): void ); $normalizer = new Normalizers\ComponentNormalizer($factory); - $spec->expects(self::once())->method('isSupportedComponentType') + $spec->expects(self::once()) + ->method('isSupportedComponentType') ->with('FakeType') ->willReturn(true); - $licenseNormalizer->expects(self::once())->method('normalize') + $licenseNormalizer->expects(self::once()) + ->method('normalize') ->with($component->getLicense()) ->willReturn([$factory->getDocument()->createElement('FakeLicense', 'dummy')]); @@ -271,7 +290,6 @@ public function testNormalizeDisjunctiveLicenses(): void self::assertStringEqualsDomNode( ''. 'myName'. - 'some-version'. 'dummy'. '', $got @@ -284,7 +302,6 @@ public function testNormalizeDisjunctiveLicensesEmpty(): void Component::class, [ 'getName' => 'myName', - 'getVersion' => 'some-version', 'getType' => 'FakeType', 'getLicense' => $this->createConfiguredMock(DisjunctiveLicenseRepository::class, ['count' => 0]), ] @@ -301,17 +318,18 @@ public function testNormalizeDisjunctiveLicensesEmpty(): void ); $normalizer = new Normalizers\ComponentNormalizer($factory); - $spec->expects(self::once())->method('isSupportedComponentType') + $spec->expects(self::once()) + ->method('isSupportedComponentType') ->with('FakeType') ->willReturn(true); - $licenseNormalizer->expects(self::never())->method('normalize'); + $licenseNormalizer->expects(self::never()) + ->method('normalize'); $got = $normalizer->normalize($component); self::assertStringEqualsDomNode( ''. 'myName'. - 'some-version'. '', $got ); @@ -325,7 +343,6 @@ public function testNormalizeExternalReferences(): void Component::class, [ 'getName' => 'myName', - 'getVersion' => 'some-version', 'getType' => 'FakeType', 'getExternalReferenceRepository' => $this->createConfiguredMock(ExternalReferenceRepository::class, ['count' => 1]), ] @@ -342,7 +359,8 @@ public function testNormalizeExternalReferences(): void ); $normalizer = new Normalizers\ComponentNormalizer($factory); - $spec->expects(self::once())->method('isSupportedComponentType') + $spec->expects(self::once()) + ->method('isSupportedComponentType') ->with('FakeType') ->willReturn(true); $externalReferenceRepositoryNormalizer->expects(self::once()) @@ -355,7 +373,6 @@ public function testNormalizeExternalReferences(): void self::assertStringEqualsDomNode( ''. 'myName'. - 'some-version'. 'dummy'. '', $actual @@ -368,7 +385,6 @@ public function testNormalizeExternalReferencesOmitIfEmpty(): void Component::class, [ 'getName' => 'myName', - 'getVersion' => 'some-version', 'getType' => 'FakeType', 'getExternalReferenceRepository' => $this->createConfiguredMock(ExternalReferenceRepository::class, ['count' => 0]), ] @@ -385,17 +401,18 @@ public function testNormalizeExternalReferencesOmitIfEmpty(): void ); $normalizer = new Normalizers\ComponentNormalizer($factory); - $spec->expects(self::once())->method('isSupportedComponentType') + $spec->expects(self::once()) + ->method('isSupportedComponentType') ->with('FakeType') ->willReturn(true); - $externalReferenceRepositoryNormalizer->expects(self::never())->method('normalize'); + $externalReferenceRepositoryNormalizer->expects(self::never()) + ->method('normalize'); $actual = $normalizer->normalize($component); self::assertStringEqualsDomNode( ''. 'myName'. - 'some-version'. '', $actual ); diff --git a/tests/Core/Serialize/JSON/Normalizers/ComponentNormalizerTest.php b/tests/Core/Serialize/JSON/Normalizers/ComponentNormalizerTest.php index 4eccbbae..e8d38975 100644 --- a/tests/Core/Serialize/JSON/Normalizers/ComponentNormalizerTest.php +++ b/tests/Core/Serialize/JSON/Normalizers/ComponentNormalizerTest.php @@ -49,7 +49,6 @@ public function testNormalizeThrowsOnUnsupportedType(): void Component::class, [ 'getName' => 'foo', - 'getVersion' => 'some-version', 'getType' => 'FakeType', ] ); @@ -67,13 +66,16 @@ public function testNormalizeThrowsOnUnsupportedType(): void $normalizer->normalize($component); } - public function testNormalizeMinimal(): void + /** + * @dataProvider dptNormalizeMinimal + */ + public function testNormalizeMinimal(array $expected, bool $requiresComponentVersion): void { $component = $this->createConfiguredMock( Component::class, [ 'getName' => 'foo', - 'getVersion' => 'some-version', + 'getVersion' => null, 'getType' => 'FakeType', 'getGroup' => null, 'getDescription' => null, @@ -86,17 +88,35 @@ public function testNormalizeMinimal(): void $factory = $this->createConfiguredMock(NormalizerFactory::class, ['getSpec' => $spec]); $normalizer = new Normalizers\ComponentNormalizer($factory); - $spec->expects(self::once())->method('isSupportedComponentType') + $spec->expects(self::once()) + ->method('isSupportedComponentType') ->with('FakeType') ->willReturn(true); + $spec->method('requiresComponentVersion') + ->willReturn($requiresComponentVersion); - $got = $normalizer->normalize($component); + $actual = $normalizer->normalize($component); - self::assertSame([ - 'type' => 'FakeType', - 'name' => 'foo', - 'version' => 'some-version', - ], $got); + self::assertSame($expected, $actual); + } + + public function dptNormalizeMinimal(): \Generator + { + yield 'mandatory Component Version' => [ + [ + 'type' => 'FakeType', + 'name' => 'foo', + 'version' => '', + ], + true, + ]; + yield 'optional Component Version' => [ + [ + 'type' => 'FakeType', + 'name' => 'foo', + ], + false, + ]; } /** @@ -134,13 +154,16 @@ public function testNormalizeFull(): void ]); $normalizer = new Normalizers\ComponentNormalizer($factory); - $spec->expects(self::once())->method('isSupportedComponentType') + $spec->expects(self::once()) + ->method('isSupportedComponentType') ->with('FakeType') ->willReturn(true); - $licenseExpressionNormalizer->expects(self::once())->method('normalize') + $licenseExpressionNormalizer->expects(self::once()) + ->method('normalize') ->with($component->getLicense()) ->willReturn(['FakeLicense']); - $hashRepositoryNormalizer->expects(self::once())->method('normalize') + $hashRepositoryNormalizer->expects(self::once()) + ->method('normalize') ->with($component->getHashRepository()) ->willReturn(['FakeHashes']); @@ -173,7 +196,6 @@ public function testNormalizeUnsupportedLicenseExpression(): void Component::class, [ 'getName' => 'myName', - 'getVersion' => 'some-version', 'getType' => 'FakeType', 'getLicense' => $this->createConfiguredMock(LicenseExpression::class, ['getExpression' => 'myLicense']), ] @@ -201,10 +223,12 @@ public function testNormalizeUnsupportedLicenseExpression(): void return true; }; - $spec->expects(self::once())->method('isSupportedComponentType') + $spec->expects(self::once()) + ->method('isSupportedComponentType') ->with('FakeType') ->willReturn(true); - $licenseNormalizer->expects(self::once())->method('normalize') + $licenseNormalizer->expects(self::once()) + ->method('normalize') ->with($this->callback($transformedLicenseTest)) ->willReturn(['FakeLicense']); @@ -213,7 +237,6 @@ public function testNormalizeUnsupportedLicenseExpression(): void self::assertEquals([ 'type' => 'FakeType', 'name' => 'myName', - 'version' => 'some-version', 'licenses' => ['FakeLicense'], ], $got); } @@ -224,7 +247,6 @@ public function testNormalizeDisjunctiveLicenses(): void Component::class, [ 'getName' => 'myName', - 'getVersion' => 'some-version', 'getType' => 'FakeType', 'getLicense' => $this->createConfiguredMock(DisjunctiveLicenseRepository::class, ['count' => 1]), ] @@ -237,10 +259,12 @@ public function testNormalizeDisjunctiveLicenses(): void ]); $normalizer = new Normalizers\ComponentNormalizer($factory); - $spec->expects(self::once())->method('isSupportedComponentType') + $spec->expects(self::once()) + ->method('isSupportedComponentType') ->with('FakeType') ->willReturn(true); - $licenseNormalizer->expects(self::once())->method('normalize') + $licenseNormalizer->expects(self::once()) + ->method('normalize') ->with($component->getLicense()) ->willReturn(['FakeLicenses']); @@ -249,7 +273,6 @@ public function testNormalizeDisjunctiveLicenses(): void self::assertEquals([ 'type' => 'FakeType', 'name' => 'myName', - 'version' => 'some-version', 'licenses' => ['FakeLicenses'], ], $got); } @@ -260,7 +283,6 @@ public function testNormalizeDisjunctiveLicensesEmpty(): void Component::class, [ 'getName' => 'myName', - 'getVersion' => 'some-version', 'getType' => 'FakeType', 'getLicense' => $this->createConfiguredMock(DisjunctiveLicenseRepository::class, ['count' => 0]), ] @@ -273,17 +295,18 @@ public function testNormalizeDisjunctiveLicensesEmpty(): void ]); $normalizer = new Normalizers\ComponentNormalizer($factory); - $spec->expects(self::once())->method('isSupportedComponentType') + $spec->expects(self::once()) + ->method('isSupportedComponentType') ->with('FakeType') ->willReturn(true); - $licenseNormalizer->expects(self::never())->method('normalize'); + $licenseNormalizer->expects(self::never()) + ->method('normalize'); $got = $normalizer->normalize($component); self::assertEquals([ 'type' => 'FakeType', 'name' => 'myName', - 'version' => 'some-version', ], $got); } @@ -295,7 +318,6 @@ public function testNormalizeExternalReferences(): void Component::class, [ 'getName' => 'myName', - 'getVersion' => 'some-version', 'getType' => 'FakeType', 'getExternalReferenceRepository' => $this->createConfiguredMock(ExternalReferenceRepository::class, ['count' => 1]), ] @@ -311,7 +333,8 @@ public function testNormalizeExternalReferences(): void ); $normalizer = new Normalizers\ComponentNormalizer($factory); - $spec->expects(self::once())->method('isSupportedComponentType') + $spec->expects(self::once()) + ->method('isSupportedComponentType') ->with('FakeType') ->willReturn(true); $externalReferenceRepositoryNormalizer->expects(self::once()) @@ -324,7 +347,6 @@ public function testNormalizeExternalReferences(): void self::assertSame([ 'type' => 'FakeType', 'name' => 'myName', - 'version' => 'some-version', 'externalReferences' => ['FakeExternalReference'], ], $actual @@ -337,7 +359,6 @@ public function testNormalizeExternalReferencesOmitIfEmpty(): void Component::class, [ 'getName' => 'myName', - 'getVersion' => 'some-version', 'getType' => 'FakeType', 'getExternalReferenceRepository' => $this->createConfiguredMock(ExternalReferenceRepository::class, ['count' => 0]), ] @@ -353,17 +374,18 @@ public function testNormalizeExternalReferencesOmitIfEmpty(): void ); $normalizer = new Normalizers\ComponentNormalizer($factory); - $spec->expects(self::once())->method('isSupportedComponentType') + $spec->expects(self::once()) + ->method('isSupportedComponentType') ->with('FakeType') ->willReturn(true); - $externalReferenceRepositoryNormalizer->expects(self::never())->method('normalize'); + $externalReferenceRepositoryNormalizer->expects(self::never()) + ->method('normalize'); $actual = $normalizer->normalize($component); self::assertEquals([ 'type' => 'FakeType', 'name' => 'myName', - 'version' => 'some-version', ], $actual); } diff --git a/tests/Core/Spec/AbstractSpecTestCase.php b/tests/Core/Spec/AbstractSpecTestCase.php index 4d882eed..c1898eb8 100644 --- a/tests/Core/Spec/AbstractSpecTestCase.php +++ b/tests/Core/Spec/AbstractSpecTestCase.php @@ -197,4 +197,12 @@ final public function testSupportsExternalReferenceHashes(): void } abstract public function shouldSupportExternalReferenceHashes(): bool; + + final public function testRequiresComponentVersion(): void + { + $isSupported = $this->getSpec()->requiresComponentVersion(); + self::assertSame($this->shouldRequireComponentVersion(), $isSupported); + } + + abstract public function shouldRequireComponentVersion(): bool; } diff --git a/tests/Core/Spec/Spec11Test.php b/tests/Core/Spec/Spec11Test.php index 315ceadb..4519718a 100644 --- a/tests/Core/Spec/Spec11Test.php +++ b/tests/Core/Spec/Spec11Test.php @@ -71,4 +71,9 @@ public function shouldSupportExternalReferenceHashes(): bool { return false; } + + public function shouldRequireComponentVersion(): bool + { + return true; + } } diff --git a/tests/Core/Spec/Spec12Test.php b/tests/Core/Spec/Spec12Test.php index c45b4612..8c1894d2 100644 --- a/tests/Core/Spec/Spec12Test.php +++ b/tests/Core/Spec/Spec12Test.php @@ -71,4 +71,9 @@ public function shouldSupportExternalReferenceHashes(): bool { return false; } + + public function shouldRequireComponentVersion(): bool + { + return true; + } } diff --git a/tests/Core/Spec/Spec13Test.php b/tests/Core/Spec/Spec13Test.php index 02e5f2a7..c2ada243 100644 --- a/tests/Core/Spec/Spec13Test.php +++ b/tests/Core/Spec/Spec13Test.php @@ -71,4 +71,9 @@ public function shouldSupportExternalReferenceHashes(): bool { return true; } + + public function shouldRequireComponentVersion(): bool + { + return true; + } } diff --git a/tests/Core/Spec/Spec14Test.php b/tests/Core/Spec/Spec14Test.php index 520e774b..644b98c8 100644 --- a/tests/Core/Spec/Spec14Test.php +++ b/tests/Core/Spec/Spec14Test.php @@ -71,4 +71,9 @@ public function shouldSupportExternalReferenceHashes(): bool { return true; } + + public function shouldRequireComponentVersion(): bool + { + return false; + } } diff --git a/tests/_data/BomModelProvider.php b/tests/_data/BomModelProvider.php index 016888e0..e68cd263 100644 --- a/tests/_data/BomModelProvider.php +++ b/tests/_data/BomModelProvider.php @@ -175,7 +175,7 @@ public static function bomWithComponentPlain(): Generator yield 'component: plain' => [ (new Bom())->setComponentRepository( new ComponentRepository( - new Component(Classification::LIBRARY, 'name', 'version') + new Component(Classification::LIBRARY, 'name') ) ), ];