Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: dep tree tests #372

Merged
merged 1 commit into from
Nov 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ All notable changes to this project will be documented in this file.
## unreleased

* Misc
* Integration tests compare against human-readable snapshots, for regression (via [#371])
* Integration tests compare against human-readable snapshots, for regression (via [#371], [#372])

[#371]: https://github.com/CycloneDX/cyclonedx-php-library/pull/371
[#372]: https://github.com/CycloneDX/cyclonedx-php-library/pull/372

## 3.0.1 - 2023-09-16

Expand Down
35 changes: 11 additions & 24 deletions tests/_data/BomModelProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ public static function bomWithProperties(): Generator
}

/**
* make a BOM and return it with its root-component and 3 child components.
* make a BOM and return it with its root-component and 2 child components.
*
* @psalm-return array{0:Bom, 1:Component, 2:Component, 3:Component, 4:Component}
*/
Expand All @@ -1102,12 +1102,11 @@ private static function makeBomWithComponentsDeps(): array
$cR = (new Component(ComponentType::Application, 'my-app'))->setBomRefValue('my-app');
$cA = (new Component(ComponentType::Library, 'component-A'))->setBomRefValue('component-A');
$cB = (new Component(ComponentType::Library, 'component-B'))->setBomRefValue('component-B');
$cC = (new Component(ComponentType::Library, 'component-C'))->setBomRefValue('component-C');
$bom = new Bom();
$bom->getMetadata()->setComponent($cR);
$bom->getComponents()->addItems($cA, $cB, $cC);
$bom->getComponents()->addItems($cA, $cB);

return [$bom, $cR, $cA, $cB, $cC];
return [$bom, $cR, $cA, $cB];
}

/**
Expand All @@ -1119,31 +1118,19 @@ private static function makeBomWithComponentsDeps(): array
*/
public static function bomWithDepTree(): Generator
{
[$bom, $cR, $cA, $cB, $cC] = self::makeBomWithComponentsDeps();
[$bom, $cR, $cA, $cB] = self::makeBomWithComponentsDeps();
yield 'dep tree: all hang' => [$bom];

[$bom, $cR, $cA, $cB, $cC] = self::makeBomWithComponentsDeps();
$cR->getDependencies()->addItems($cA->getBomRef(), $cB->getBomRef());
yield 'dep tree: R->A, R->B, C hang' => [$bom];
[$bom, $cR, $cA, $cB] = self::makeBomWithComponentsDeps();
$bom->getMetadata()->setComponent(null);
yield 'dep tree: all hang, no root' => [$bom];

[$bom, $cR, $cA, $cB, $cC] = self::makeBomWithComponentsDeps();
$cA->getDependencies()->addItems($cB->getBomRef());
yield 'dep tree: A hang, A->B, C hang' => [$bom];

[$bom, $cR, $cA, $cB, $cC] = self::makeBomWithComponentsDeps();
[$bom, $cR, $cA, $cB] = self::makeBomWithComponentsDeps();
$cR->getDependencies()->addItems($cA->getBomRef());
$cA->getDependencies()->addItems($cR->getBomRef());
yield 'dep tree: R->A, A->R, B hang, C hang' => [$bom];
yield 'dep tree: R->A, B hang' => [$bom];

[$bom, $cR, $cA, $cB, $cC] = self::makeBomWithComponentsDeps();
$cA->getDependencies()->addItems($cB->getBomRef());
$cB->getDependencies()->addItems($cC->getBomRef());
yield 'dep tree: A hang, A->B, B->C' => [$bom];

[$bom, $cR, $cA, $cB, $cC] = self::makeBomWithComponentsDeps();
$cR->getDependencies()->addItems($cA->getBomRef());
[$bom, $cR, $cA, $cB] = self::makeBomWithComponentsDeps();
$cA->getDependencies()->addItems($cB->getBomRef());
$cB->getDependencies()->addItems($cC->getBomRef());
yield 'dep tree: R->A, A->B, B->C' => [$bom];
yield 'dep tree: A hang, A->B, no root' => [$bom];
}
}

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.