['driver' => 'array']]); $table = AccountMappingResyncDispatcher::JOBS_TABLE; Schema::dropIfExists($table); Schema::create($table, function (Blueprint $table): void { $table->increments('id'); $table->string('platform'); $table->string('month'); $table->string('status'); $table->unsignedInteger('attempts')->default(0); $table->text('message')->nullable(); $table->timestamps(); }); foreach (['2026-09', '2026-10'] as $month) { DB::table($table)->insert(['platform' => 'jingxi', 'month' => $month, 'status' => 'pending', 'created_at' => now(), 'updated_at' => now()]); } $command = new class extends RunAccountMappingResync { public bool $edited = false; protected function runSync(object $job): array { if ($this->edited) { DB::table(AccountMappingResyncDispatcher::JOBS_TABLE)->where('id', $job->id)->update(['status' => 'pending']); } return [true, 'OK']; } }; $this->app->make(Kernel::class)->registerCommand($command); $this->artisan('store-receipt:auto-resync')->assertSuccessful(); $this->assertSame(['done', 'pending'], DB::table($table)->orderBy('id')->pluck('status')->all()); $command->edited = true; $this->artisan('store-receipt:auto-resync')->assertSuccessful(); $this->assertSame(['done', 'pending'], DB::table($table)->orderBy('id')->pluck('status')->all()); $this->assertSame([1, 1], DB::table($table)->orderBy('id')->pluck('attempts')->all()); } }