From ae0ae7c27b27e493270e6f2980eea764f8b3469e Mon Sep 17 00:00:00 2001 From: kylekatarnls Date: Thu, 15 Jun 2023 17:10:15 +0200 Subject: [PATCH] Add test message for mutability expectation --- tests/CarbonPeriod/MacroTest.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/CarbonPeriod/MacroTest.php b/tests/CarbonPeriod/MacroTest.php index 01ea1b653c..65924c6838 100644 --- a/tests/CarbonPeriod/MacroTest.php +++ b/tests/CarbonPeriod/MacroTest.php @@ -225,18 +225,18 @@ public function testMixinInstance() $this->assertSame('Every 1 day from 2023-06-10 to 2023-06-13', (string) $copy); $mutated = $period->oneMoreDay(); - $expectedEnd = $this->periodClass === CarbonPeriodImmutable::class - ? '2023-06-12' - : '2023-06-13'; + $immutable = ($this->periodClass === CarbonPeriodImmutable::class); + $expectedEnd = $immutable ? '2023-06-12' : '2023-06-13'; $this->assertSame('Every 1 day from 2023-06-10 to 2023-06-13', (string) $mutated); $this->assertSame("Every 1 day from 2023-06-10 to $expectedEnd", (string) $period); - if ($this->periodClass === CarbonPeriodImmutable::class) { - $this->assertNotSame($mutated, $period); - } else { - $this->assertSame($mutated, $period); - } + $expectedResult = $immutable ? 'a new instance' : 'the same instance'; + $this->assertSame( + $immutable, + ($mutated !== $period), + $this->periodClass . "::oneMoreDay() should return $expectedResult" + ); $this->assertNotSame($copy, $period);