47 lines
1.5 KiB
PHP
47 lines
1.5 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
use App\Models\User;
|
||
|
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||
|
|
use Illuminate\Support\Facades\DB;
|
||
|
|
|
||
|
|
uses(DatabaseTransactions::class);
|
||
|
|
|
||
|
|
// EnsureSaasAdmin — стаб в testing (см. SupplierManualQueueTest::16); actingAs
|
||
|
|
// нужен только для прохода middleware-стека auth+admin.
|
||
|
|
|
||
|
|
it('GET export-mode returns current value', function (): void {
|
||
|
|
$this->actingAs(User::factory()->create());
|
||
|
|
DB::table('system_settings')->updateOrInsert(
|
||
|
|
['key' => 'supplier_export_mode'],
|
||
|
|
['value' => 'batch', 'type' => 'string', 'updated_at' => now()],
|
||
|
|
);
|
||
|
|
|
||
|
|
$this->getJson('/api/admin/supplier-integration/export-mode')
|
||
|
|
->assertOk()
|
||
|
|
->assertJson(['mode' => 'batch']);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('POST export-mode switches value', function (): void {
|
||
|
|
$this->actingAs(User::factory()->create());
|
||
|
|
DB::table('system_settings')->updateOrInsert(
|
||
|
|
['key' => 'supplier_export_mode'],
|
||
|
|
['value' => 'batch', 'type' => 'string', 'updated_at' => now()],
|
||
|
|
);
|
||
|
|
|
||
|
|
$this->postJson('/api/admin/supplier-integration/export-mode', ['mode' => 'online'])
|
||
|
|
->assertOk()
|
||
|
|
->assertJson(['mode' => 'online']);
|
||
|
|
|
||
|
|
expect(DB::table('system_settings')->where('key', 'supplier_export_mode')->value('value'))
|
||
|
|
->toBe('online');
|
||
|
|
});
|
||
|
|
|
||
|
|
it('POST export-mode rejects invalid value', function (): void {
|
||
|
|
$this->actingAs(User::factory()->create());
|
||
|
|
|
||
|
|
$this->postJson('/api/admin/supplier-integration/export-mode', ['mode' => 'turbo'])
|
||
|
|
->assertStatus(422);
|
||
|
|
});
|