From a114df2a690d3c99c36a84cbb896bbb503f38fa5 Mon Sep 17 00:00:00 2001 From: Okan Date: Wed, 12 Jun 2024 18:51:40 +0300 Subject: [PATCH] Fixed squash testing. --- tests/SquashInvoiceRowsTest.php | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/tests/SquashInvoiceRowsTest.php b/tests/SquashInvoiceRowsTest.php index 89b57e9..49d3c57 100644 --- a/tests/SquashInvoiceRowsTest.php +++ b/tests/SquashInvoiceRowsTest.php @@ -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, ])); } @@ -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; $iassertEquals($i + 1, $rows[$i]->getLineNumber()); + } } } \ No newline at end of file