补齐座驾购买金币流水
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Enums\CurrencySource;
|
||||
use App\Models\Ride;
|
||||
use App\Models\Room;
|
||||
use App\Models\User;
|
||||
@@ -80,6 +81,10 @@ class RideControllerTest extends TestCase
|
||||
'user_id' => $user->id,
|
||||
'ride_id' => $ride->id,
|
||||
]);
|
||||
$this->assertDatabaseMissing('user_currency_logs', [
|
||||
'user_id' => $user->id,
|
||||
'source' => CurrencySource::RIDE_BUY->value,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,6 +113,15 @@ class RideControllerTest extends TestCase
|
||||
'status' => 'active',
|
||||
'price_paid' => 18888,
|
||||
]);
|
||||
$this->assertDatabaseHas('user_currency_logs', [
|
||||
'user_id' => $user->id,
|
||||
'currency' => 'gold',
|
||||
'amount' => -18888,
|
||||
'balance_after' => 11112,
|
||||
'source' => CurrencySource::RIDE_BUY->value,
|
||||
'remark' => '购买聊天室座驾:测试座驾',
|
||||
'room_id' => $room->id,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+11
-4
@@ -16,10 +16,17 @@ abstract class TestCase extends BaseTestCase
|
||||
*/
|
||||
protected function flushChatRoomRedisState(): void
|
||||
{
|
||||
$keys = Redis::keys('room:*');
|
||||
$prefix = config('database.redis.options.prefix', '');
|
||||
$cursor = '0';
|
||||
|
||||
if ($keys !== []) {
|
||||
Redis::del(...$keys);
|
||||
}
|
||||
do {
|
||||
[$cursor, $keys] = Redis::scan($cursor, ['match' => $prefix.'room:*', 'count' => 200]);
|
||||
|
||||
foreach ($keys ?? [] as $fullKey) {
|
||||
// Laravel Redis Facade 写入时会自动追加前缀,删除时要还原成业务短 key。
|
||||
$shortKey = $prefix ? substr((string) $fullKey, strlen($prefix)) : (string) $fullKey;
|
||||
Redis::del($shortKey);
|
||||
}
|
||||
} while ($cursor !== '0');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user