create(['total' => 0, 'credit' => 0, 'total_pending' => 100_000]); $transaction = Transaction::create([ 'uuid' => (string) \Illuminate\Support\Str::uuid(), 'public_code' => 'DEP-TEST-0001', 'trans' => 'DEP-TEST-0001', 'amount' => 100_000, 'customer_id' => $customer->id, 'type' => 'manual', 'status' => TransactionStatus::PENDING->value, ]); $controller = app(AdminTransactionController::class); $first = $controller->approve($transaction->uuid); $second = $controller->approve($transaction->uuid); $this->assertSame(200, $first->getStatusCode()); // Second call finds the transaction no longer PENDING → treated as not-approvable. $this->assertSame(404, $second->getStatusCode()); $this->assertSame(100_000, (int) $customer->fresh()->total); } }