Files
portal-api/tests/Feature/Mail/MailSettingsQueueTest.php
T
baodev0andClaude Opus 5.5 46aa138eec feat(admin): IP pool allocation, billing exports, service attachments
- IP pool: sheet import (xlsx/csv) matched by address, bulk allocate/revoke
  with notification email (ip_allocated/ip_revoked), ip_pool_logs history.
- Orders/invoices: Excel export on branded template (BrandedReportWriter),
  shared billing filters, order item service info in list responses.
- Web design quote Excel export; activity log export.
- Service attachments with copy-to-invoice; deployment invoice attachments.
- Customer email attachments stored on disk and attached by path.
- Admin password change endpoint; user.fullname backfill migration;
  orders.user_id backfill from logs.
- Disable deploy workflow until CI/CD is set up.
- Ignore stored customer email and service attachment uploads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 19:58:36 +07:00

49 lines
1.6 KiB
PHP

<?php
declare(strict_types=1);
namespace Tests\Feature\Mail;
use App\Http\Facade\SignRSA;
use App\Models\Setting;
use App\Support\MailSettings;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Cache;
use Tests\TestCase;
class MailSettingsQueueTest extends TestCase
{
use RefreshDatabase;
private function saveSmtp(string $host): void
{
Setting::updateOrCreate(['key' => 'setting'], ['value' => json_encode(['company' => 'Thế Giới Số'])]);
Setting::updateOrCreate(['key' => 'smtp'], ['value' => json_encode([
'host' => $host, 'port' => 465, 'user' => 'noreply@tgs.com.vn',
'password' => SignRSA::EncryptFunc('secret'), 'encryption' => 'ssl',
'from_address' => 'noreply@tgs.com.vn', 'from_name' => 'TGS',
])]);
Cache::forget(MailSettings::cacheKey());
}
private function hostSeenByQueuedJob(): ?string
{
dispatch(fn () => Cache::put('test:queued-mail-host', config('mail.mailers.smtp.host')));
return Cache::pull('test:queued-mail-host');
}
public function test_queued_jobs_use_smtp_from_settings_and_pick_up_changes(): void
{
config(['queue.default' => 'sync']);
$this->saveSmtp('smtp.settings-one.test');
$this->assertSame('smtp.settings-one.test', $this->hostSeenByQueuedJob());
$this->assertSame('noreply@tgs.com.vn', config('mail.from.address'));
$this->assertSame('secret', config('mail.mailers.smtp.password'));
$this->saveSmtp('smtp.settings-two.test');
$this->assertSame('smtp.settings-two.test', $this->hostSeenByQueuedJob());
}
}