From d8af7d455e75d1c382575cb9cf45efa1abd9177b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Tue, 7 Feb 2023 16:22:26 +0100 Subject: [PATCH] Fixed: [doc generation] fix summary budget --- .../Service/Summary/SummaryBudget.php | 4 ++-- .../Tests/Service/Summary/SummaryBudgetTest.php | 11 +++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php b/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php index b7a88bb9d..2f401f1ec 100644 --- a/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php +++ b/src/Bundle/ChillBudgetBundle/Service/Summary/SummaryBudget.php @@ -150,7 +150,7 @@ final class SummaryBudget implements SummaryBudgetInterface switch ($kind) { case 'charge': foreach ($rows as $row) { - $chargeKind = $this->chargeKindRepository->findOneByKind($row['kind_id']); + $chargeKind = $this->chargeKindRepository->find($row['kind_id']); if (null === $chargeKind) { throw new RuntimeException('charge kind not found: ' . $row['kind_id']); @@ -166,7 +166,7 @@ final class SummaryBudget implements SummaryBudgetInterface case 'resource': foreach ($rows as $row) { - $resourceKind = $this->resourceKindRepository->findOneByKind($row['kind_id']); + $resourceKind = $this->resourceKindRepository->find($row['kind_id']); if (null === $resourceKind) { throw new RuntimeException('charge kind not found: ' . $row['kind_id']); diff --git a/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php b/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php index 9f90c60bd..cf8c00efe 100644 --- a/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php +++ b/src/Bundle/ChillBudgetBundle/Tests/Service/Summary/SummaryBudgetTest.php @@ -43,7 +43,7 @@ final class SummaryBudgetTest extends TestCase [ 'sum' => 250.0, 'comment' => '', - 'kind_id' => 'rental', + 'kind_id' => 1, // kind: rental ], ]); $queryCharges->setParameters(Argument::type('array')) @@ -57,7 +57,7 @@ final class SummaryBudgetTest extends TestCase [ 'sum' => 1500.0, 'comment' => '', - 'kind_id' => 'salary', + 'kind_id' => 2, // kind: 'salary', ], ]); $queryResources->setParameters(Argument::type('array')) @@ -84,6 +84,7 @@ final class SummaryBudgetTest extends TestCase $rental = (new ChargeKind())->setKind('rental')->setName(['fr' => 'Rental']), $other = (new ChargeKind())->setKind('other')->setName(['fr' => 'Other']), ]); + $chargeRepository->find(1)->willReturn($rental); $chargeRepository->findOneByKind('rental')->willReturn($rental); $chargeRepository->findOneByKind('other')->willReturn($other); @@ -92,6 +93,7 @@ final class SummaryBudgetTest extends TestCase $salary = (new ResourceKind())->setKind('salary')->setName(['fr' => 'Salary']), $misc = (new ResourceKind())->setKind('misc')->setName(['fr' => 'Misc']), ]); + $resourceRepository->find(2)->willReturn($salary); $resourceRepository->findOneByKind('salary')->willReturn($salary); $resourceRepository->findOneByKind('misc')->willReturn($misc); @@ -108,8 +110,9 @@ final class SummaryBudgetTest extends TestCase $household = new Household(); $householdReflection = new \ReflectionClass($household); - $householdReflection->getProperty('id')->setAccessible(true); - $householdReflection->getProperty('id')->setValue($household, 1); + $householdId = $householdReflection->getProperty('id'); + $householdId->setAccessible(true); + $householdId->setValue($household, 1); $householdMember = (new HouseholdMember())->setPerson($person) ->setStartDate(new \DateTimeImmutable('1 month ago')) ;