From e49123109017fa2edc09831436a9ea6031fef1b1 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 4 Sep 2024 08:13:53 +1000 Subject: [PATCH] Fixes for tests --- app/Repositories/TaskStatusRepository.php | 3 +++ app/Services/Invoice/AutoBillInvoice.php | 2 -- tests/Feature/TaskStatusApiTest.php | 18 ++++++++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/Repositories/TaskStatusRepository.php b/app/Repositories/TaskStatusRepository.php index edfbac42c4..0062af5532 100644 --- a/app/Repositories/TaskStatusRepository.php +++ b/app/Repositories/TaskStatusRepository.php @@ -72,6 +72,9 @@ class TaskStatusRepository extends BaseRepository } elseif($ts->status_order >= $task_status->status_order) { $ts->status_order++; $ts->save(); + } else { + $ts->status_order = 99999; + $ts->save(); } }); diff --git a/app/Services/Invoice/AutoBillInvoice.php b/app/Services/Invoice/AutoBillInvoice.php index 3c7fc0bb9c..802bf4de65 100644 --- a/app/Services/Invoice/AutoBillInvoice.php +++ b/app/Services/Invoice/AutoBillInvoice.php @@ -148,7 +148,6 @@ class AutoBillInvoice extends AbstractService ]); nlog("Payment hash created => {$payment_hash->id}"); - $this->invoice->saveQuietly(); $payment = false; try { @@ -163,7 +162,6 @@ class AutoBillInvoice extends AbstractService } - $this->invoice = $this->invoice->fresh(); $this->invoice->auto_bill_tries += 1; if ($this->invoice->auto_bill_tries == 3) { diff --git a/tests/Feature/TaskStatusApiTest.php b/tests/Feature/TaskStatusApiTest.php index c454e4cca2..dda27d7696 100644 --- a/tests/Feature/TaskStatusApiTest.php +++ b/tests/Feature/TaskStatusApiTest.php @@ -46,11 +46,15 @@ class TaskStatusApiTest extends TestCase public function testSorting() { - TaskStatus::factory()->count(5)->create([ - 'company_id' => $this->company->id, - 'user_id' => $this->user->id - ]); + TaskStatus::query()->where('company_id', $this->company->id)->cursor()->each(function ($ts){ + $ts->forceDelete(); + }); + TaskStatus::factory()->count(10)->create([ + 'company_id' => $this->company->id, + 'user_id' => $this->user->id, + 'status_order' => 99999, + ]); $t = TaskStatus::where('company_id', '=', $this->company->id)->orderBy('id', 'desc'); @@ -59,7 +63,6 @@ class TaskStatusApiTest extends TestCase $id = $task_status->id; - $data = [ 'status_order' => 1, ]; @@ -69,7 +72,10 @@ class TaskStatusApiTest extends TestCase 'X-API-TOKEN' => $this->token, ])->put('/api/v1/task_statuses/'.$task_status->hashed_id, $data); - $t = TaskStatus::where('company_id', '=', $this->company->id)->orderBy('status_order', 'asc')->first(); + + $xx = TaskStatus::where('company_id', $this->company->id)->pluck('status_order'); + + $t = TaskStatus::where('company_id', $this->company->id)->orderBy('status_order', 'asc')->first(); $this->assertEquals($id, $t->id);