'sqlite']); Cache::flush(); if (! Schema::hasTable('jst_oms_shipping')) { Schema::create('jst_oms_shipping', function (Blueprint $table): void { $table->increments('id'); $table->string('express_name1')->nullable(); $table->string('express_name2')->nullable(); }); } DB::table('jst_oms_shipping')->insert(['id' => 1, 'express_name1' => '仅历史出现的快递', 'express_name2' => null]); foreach (array_chunk(range(2, 10001), 500) as $ids) { DB::table('jst_oms_shipping')->insert(array_map(fn ($id) => [ 'id' => $id, 'express_name1' => '发货名称甲', 'express_name2' => $id === 10001 ? '发货名称乙' : '0', ], $ids)); } $repository = new ShippingOrderRepository(); DB::enableQueryLog(); DB::flushQueryLog(); $this->assertSame(['发货名称乙', '发货名称甲'], $repository->recentCourierNames('发货名称')); $this->assertSame([], $repository->recentCourierNames('仅历史')); $this->assertCount(1, DB::getQueryLog()); DB::disableQueryLog(); $this->assertSame('仅历史出现的快递', DB::table('jst_oms_shipping')->where('id', 1)->value('express_name1')); $this->assertSame(10001, DB::table('jst_oms_shipping')->count()); } }