Skip to content

Commit

Permalink
Fixed squash testing.
Browse files Browse the repository at this point in the history
  • Loading branch information
firebed committed Jun 12, 2024
1 parent 93205af commit a114df2
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions tests/SquashInvoiceRowsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -434,16 +434,22 @@ public function test_mixed_same_tax_category_rows_are_squashed()
public function test_rows_with_rec_type_are_not_squashed()
{
$invoice = new Invoice();
$invoice->setInvoiceDetails(InvoiceDetails::factory(4)->make([
$invoice->addInvoiceDetails(new InvoiceDetails([
'vatCategory' => VatCategory::VAT_1,
'netValue' => 10,
'recType' => null,
]));

$invoice->addInvoiceDetails(new InvoiceDetails([
'vatCategory' => VatCategory::VAT_1,
'netValue' => 40,
'recType' => null,
'withheldPercentCategory' => null,
'stampDutyPercentCategory' => null,
'otherTaxesPercentCategory' => null,
'feesPercentCategory' => null,
]));

for ($i = 0; $i < 5; $i++) {
$invoice->addInvoiceDetails(InvoiceDetails::factory()->make([
$invoice->addInvoiceDetails(new InvoiceDetails([
'vatCategory' => VatCategory::VAT_1,
'netAmount' => 10,
'recType' => RecType::TYPE_5,
]));
}
Expand All @@ -453,13 +459,10 @@ public function test_rows_with_rec_type_are_not_squashed()

$this->assertIsArray($rows);
$this->assertCount(6, $rows);
$this->assertEquals(1, $rows[0]->getLineNumber());

$this->assertCount(5, array_filter($invoice->getInvoiceDetails(), fn($row) => $row->getRecType() === RecType::TYPE_5));
$this->assertEquals(2, $rows[1]->getLineNumber());
$this->assertEquals(3, $rows[2]->getLineNumber());
$this->assertEquals(4, $rows[3]->getLineNumber());
$this->assertEquals(5, $rows[4]->getLineNumber());
$this->assertEquals(6, $rows[5]->getLineNumber());

for ($i=0; $i<count($rows); $i++) {
$this->assertEquals($i + 1, $rows[$i]->getLineNumber());
}
}
}

0 comments on commit a114df2

Please sign in to comment.