From 54f3d75e027cb9d36152afb13d523bbc7feff431 Mon Sep 17 00:00:00 2001 From: Vadym <114911409+VadymHrechukha@users.noreply.github.com> Date: Fri, 22 Nov 2024 16:04:00 +0000 Subject: [PATCH] HP-2212 Fix falling phpunit-legacy Unit tests after add Since and Till properties to Bill (#91) * HP-2212 Fix falling phpunit-legacy Unit tests * HP-2212 initialize default value for Bill::$usageInterval property --- src/bill/Bill.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/bill/Bill.php b/src/bill/Bill.php index 6e833f5..8178268 100755 --- a/src/bill/Bill.php +++ b/src/bill/Bill.php @@ -89,7 +89,6 @@ public function __construct( $this->plan = $plan; $this->charges = $charges; $this->state = $state; - $this->setUsageInterval(UsageInterval::wholeMonth($time)); } /** @@ -111,9 +110,18 @@ public function getUniqueString(): string public function getUsageInterval(): UsageInterval { + if ($this->usageInterval === null) { + $this->initializeWholeMonthUsageInterval(); + } + return $this->usageInterval; } + private function initializeWholeMonthUsageInterval(): void + { + $this->setUsageInterval(UsageInterval::wholeMonth($this->time)); + } + public function calculatePrice() { $quantity = $this->quantity->getQuantity();