assertSame(7, $result->total()); } public function test_it_reports_a_zero_total_when_empty(): void { $this->assertSame(0, (new BreakdownResult([]))->total()); } public function test_it_calculates_a_row_share_of_the_total(): void { $result = new BreakdownResult([ new Breakdown('A', 3), new Breakdown('B', 1), ]); $this->assertSame(75.0, $result->shareOf($result->rows[0])); $this->assertSame(25.0, $result->shareOf($result->rows[1])); } public function test_it_reports_a_zero_share_when_nothing_was_counted(): void { $result = new BreakdownResult([new Breakdown('A', 0)]); $this->assertSame(0.0, $result->shareOf($result->rows[0])); } public function test_it_has_no_data_without_rows(): void { $this->assertTrue((new BreakdownResult([]))->isEmpty()); } public function test_it_has_no_data_when_every_row_is_zero(): void { $this->assertTrue((new BreakdownResult([new Breakdown('A', 0)]))->isEmpty()); } public function test_it_has_data_when_any_row_is_counted(): void { $this->assertFalse((new BreakdownResult([new Breakdown('A', 1)]))->isEmpty()); } }