seed(CurrencySeeder::class); $this->assertDatabaseCount('currencies', 5); foreach (['USD', 'AED', 'EUR', 'CNY', 'IRR'] as $code) { $this->assertDatabaseHas('currencies', [ 'code' => $code, 'is_active' => true, ]); } } #[Test] public function it_sets_irr_rate_to_one() { $this->seed(CurrencySeeder::class); $irr = Currency::where('code', 'IRR')->first(); $this->assertSame('1.0000', $irr->rate_to_rial); } #[Test] public function it_is_idempotent_and_does_not_overwrite_real_rates() { // اجرای اول با نرخ صفر $this->seed(CurrencySeeder::class); // شبیه‌سازی نرخ واقعی که مدیر یا cron وارد کرده Currency::where('code', 'USD')->update(['rate_to_rial' => 60000]); Currency::where('code', 'EUR')->update(['rate_to_rial' => 65000]); // اجرای دوباره seeder — نباید نرخ‌های واقعی را overwrite کند $this->seed(CurrencySeeder::class); $this->assertSame('60000.0000', Currency::where('code', 'USD')->value('rate_to_rial')); $this->assertSame('65000.0000', Currency::where('code', 'EUR')->value('rate_to_rial')); // ولی هنوز همه ۵ ارز موجود هستند $this->assertDatabaseCount('currencies', 5); } #[Test] public function it_sets_other_currencies_rate_to_zero_until_imported() { $this->seed(CurrencySeeder::class); // ارزهای غیر IRR باید نرخ صفر داشته باشند تا cron یا مدیر آنها را پر کند foreach (['USD', 'AED', 'EUR', 'CNY'] as $code) { $this->assertSame('0.0000', Currency::where('code', $code)->value('rate_to_rial')); } } }