feat(billing): renewals, coupons, VAT numbering, billing cycles and invoice payment tracking
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
ea9a53f742
commit
25f23d541e
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature\Api\Admin;
|
||||
|
||||
use App\Models\Setting;
|
||||
use App\Models\User;
|
||||
use App\Support\EmailHealth;
|
||||
use Database\Seeders\TemplateSeeder;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Spatie\Permission\Models\Role;
|
||||
use Tests\TestCase;
|
||||
|
||||
class EmailHealthTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_health_flags_disabled_lifecycle_scenarios_and_clears_when_enabled(): void
|
||||
{
|
||||
$this->seed(TemplateSeeder::class);
|
||||
Role::firstOrCreate(['name' => 'Full Administrator', 'guard_name' => 'admin']);
|
||||
$admin = User::factory()->create();
|
||||
$admin->assignRole('Full Administrator');
|
||||
|
||||
Setting::updateOrCreate(['key' => 'email_settings'], ['value' => json_encode(['auto_disabled' => ['service_expiry', 'auto_renew_failed']])]);
|
||||
|
||||
$rows = collect($this->actingAs($admin, 'admin')->getJson('/api/v1/administrator/email-templates/health')
|
||||
->assertOk()
|
||||
->json('data.scenarios'))->keyBy('key');
|
||||
|
||||
$this->assertFalse($rows['service_expiry']['auto_enabled']);
|
||||
$this->assertFalse($rows['service_expiry']['ready']);
|
||||
$this->assertTrue($rows['invoice_notification']['has_template']);
|
||||
$this->assertSame(EmailHealth::LIFECYCLE_SCENARIOS, $rows->keys()->all());
|
||||
|
||||
Setting::updateOrCreate(['key' => 'email_settings'], ['value' => json_encode(['auto_disabled' => []])]);
|
||||
|
||||
$rows = collect(EmailHealth::report()['scenarios'])->keyBy('key');
|
||||
$this->assertTrue($rows['service_expiry']['ready']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user