mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-08-03 15:11:40 +00:00
Add test
This commit is contained in:
parent
1a0b67f361
commit
1632424fa5
1 changed files with 26 additions and 0 deletions
|
|
@ -208,6 +208,32 @@ final class ProjectBuildHelperTest extends WebTestCase
|
|||
$this->assertTrue(BigDecimal::of('6.00')->isEqualTo($result));
|
||||
}
|
||||
|
||||
public function testCalculateTotalBuildPriceWithBuildPartFromSubproject(): void
|
||||
{
|
||||
$project = new Project();
|
||||
$entry = new ProjectBOMEntry();
|
||||
$entry->setPart($this->makePartWithPrice(1.50));
|
||||
$entry->setQuantity(4);
|
||||
$project->addBomEntry($entry);
|
||||
|
||||
$subproject = new Project();
|
||||
$subproject->setParent($project);
|
||||
$subentry = new ProjectBOMEntry();
|
||||
$subentry->setPart($this->makePartWithPrice(3.5));
|
||||
$subentry->setQuantity(2);
|
||||
|
||||
$entry2 = new ProjectBOMEntry();
|
||||
$entry2->setPart(new Part());
|
||||
$entry2->setQuantity(2);
|
||||
$subproject->setBuildPart($entry2);
|
||||
$project->addBomEntry($entry2);
|
||||
|
||||
// 4 × 1.50 + 2 x (2 x 3.5) = 20.00 for 1 build
|
||||
$result = $this->service->calculateTotalBuildPrice($project, 1);
|
||||
$this->assertNotNull($result);
|
||||
$this->assertTrue(BigDecimal::of('20.00')->isEqualTo($result));
|
||||
}
|
||||
|
||||
public function testCalculateUnitBuildPriceEqualsTotal(): void
|
||||
{
|
||||
$project = new Project();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue