скрытие магазина
This commit is contained in:
@@ -17,6 +17,12 @@ class AdminShopFeatureTest extends TestCase
|
||||
config(['database.connections.store' => ['driver' => 'sqlite', 'database' => ':memory:', 'prefix' => '']]);
|
||||
DB::purge('store');
|
||||
|
||||
Schema::connection('store')->create('store_config', function (Blueprint $table): void {
|
||||
$table->unsignedInteger('id')->primary();
|
||||
$table->unsignedInteger('enabled')->default(1);
|
||||
});
|
||||
DB::connection('store')->table('store_config')->insert(['id' => 1, 'enabled' => 1]);
|
||||
|
||||
Schema::connection('store')->create('store_categories', function (Blueprint $table): void {
|
||||
$table->increments('id');
|
||||
$table->string('name')->nullable();
|
||||
@@ -75,10 +81,28 @@ class AdminShopFeatureTest extends TestCase
|
||||
->where('categories.0.name', 'Маунты')
|
||||
->where('products.0.name', 'Спектральный тигр')
|
||||
->where('products.0.category_ids.0', $categoryId)
|
||||
->where('shopEnabled', true)
|
||||
->etc()
|
||||
);
|
||||
}
|
||||
|
||||
public function test_admin_can_disable_and_enable_store(): void
|
||||
{
|
||||
$admin = $this->admin();
|
||||
|
||||
$this->actingAs($admin)
|
||||
->patch(route('admin.shop.availability.update'), ['enabled' => false])
|
||||
->assertSessionHas('status', 'Магазин и пополнение выключены.');
|
||||
|
||||
$this->assertSame(0, (int) DB::connection('store')->table('store_config')->where('id', 1)->value('enabled'));
|
||||
|
||||
$this->actingAs($admin)
|
||||
->patch(route('admin.shop.availability.update'), ['enabled' => true])
|
||||
->assertSessionHas('status', 'Магазин и пополнение включены.');
|
||||
|
||||
$this->assertSame(1, (int) DB::connection('store')->table('store_config')->where('id', 1)->value('enabled'));
|
||||
}
|
||||
|
||||
public function test_regular_player_cannot_manage_store(): void
|
||||
{
|
||||
$this->actingAs($this->admin(0))->get(route('admin.shop.index'))->assertForbidden();
|
||||
|
||||
Reference in New Issue
Block a user