|
@@ -96,6 +96,97 @@ class ProductSKUControllerTest extends TestCase
|
|
|
$response->assertViewIs('products_sku.index');
|
|
$response->assertViewIs('products_sku.index');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public function test_maf_filter_options_include_empty_marker_for_factory_number(): void
|
|
|
|
|
+ {
|
|
|
|
|
+ ProductSKU::factory()->create(['factory_number' => null]);
|
|
|
|
|
+ ProductSKU::factory()->create(['factory_number' => ' ']);
|
|
|
|
|
+ ProductSKU::factory()->create(['factory_number' => 'FN-123456']);
|
|
|
|
|
+
|
|
|
|
|
+ $response = $this->actingAs($this->adminUser)
|
|
|
|
|
+ ->getJson(route('getFilters', [
|
|
|
|
|
+ 'table' => 'product_sku',
|
|
|
|
|
+ 'column' => 'factory_number',
|
|
|
|
|
+ ]));
|
|
|
|
|
+
|
|
|
|
|
+ $response->assertOk();
|
|
|
|
|
+ $response->assertJsonFragment(['-пусто-']);
|
|
|
|
|
+ $response->assertJsonFragment(['FN-123456']);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function test_maf_empty_filter_matches_null_blank_and_null_date_values(): void
|
|
|
|
|
+ {
|
|
|
|
|
+ $orderWithNullFactory = Order::factory()->create(['object_address' => 'ул. Пустая фабрика']);
|
|
|
|
|
+ $orderWithBlankFactory = Order::factory()->create(['object_address' => 'ул. Пробелы фабрика']);
|
|
|
|
|
+ $orderWithNullDate = Order::factory()->create(['object_address' => 'ул. Пустая дата']);
|
|
|
|
|
+ $orderWithBlankStatement = Order::factory()->create(['object_address' => 'ул. Пустая ведомость']);
|
|
|
|
|
+ $orderWithFilledValue = Order::factory()->create(['object_address' => 'ул. Заполненная']);
|
|
|
|
|
+ $product = Product::factory()->create();
|
|
|
|
|
+
|
|
|
|
|
+ ProductSKU::factory()->create([
|
|
|
|
|
+ 'order_id' => $orderWithNullFactory->id,
|
|
|
|
|
+ 'product_id' => $product->id,
|
|
|
|
|
+ 'factory_number' => null,
|
|
|
|
|
+ 'manufacture_date' => '2026-04-01',
|
|
|
|
|
+ 'statement_number' => 'STAT-1',
|
|
|
|
|
+ ]);
|
|
|
|
|
+ ProductSKU::factory()->create([
|
|
|
|
|
+ 'order_id' => $orderWithBlankFactory->id,
|
|
|
|
|
+ 'product_id' => $product->id,
|
|
|
|
|
+ 'factory_number' => ' ',
|
|
|
|
|
+ 'manufacture_date' => '2026-04-02',
|
|
|
|
|
+ 'statement_number' => 'STAT-2',
|
|
|
|
|
+ ]);
|
|
|
|
|
+ ProductSKU::factory()->create([
|
|
|
|
|
+ 'order_id' => $orderWithNullDate->id,
|
|
|
|
|
+ 'product_id' => $product->id,
|
|
|
|
|
+ 'factory_number' => 'FN-000001',
|
|
|
|
|
+ 'manufacture_date' => null,
|
|
|
|
|
+ 'statement_number' => 'STAT-3',
|
|
|
|
|
+ ]);
|
|
|
|
|
+ ProductSKU::factory()->create([
|
|
|
|
|
+ 'order_id' => $orderWithBlankStatement->id,
|
|
|
|
|
+ 'product_id' => $product->id,
|
|
|
|
|
+ 'factory_number' => 'FN-000002',
|
|
|
|
|
+ 'manufacture_date' => '2026-04-03',
|
|
|
|
|
+ 'statement_number' => ' ',
|
|
|
|
|
+ ]);
|
|
|
|
|
+ ProductSKU::factory()->create([
|
|
|
|
|
+ 'order_id' => $orderWithFilledValue->id,
|
|
|
|
|
+ 'product_id' => $product->id,
|
|
|
|
|
+ 'factory_number' => 'FN-999999',
|
|
|
|
|
+ 'manufacture_date' => '2026-04-04',
|
|
|
|
|
+ 'statement_number' => 'STAT-9',
|
|
|
|
|
+ ]);
|
|
|
|
|
+
|
|
|
|
|
+ $factoryResponse = $this->actingAs($this->adminUser)
|
|
|
|
|
+ ->get(route('product_sku.index', [
|
|
|
|
|
+ 'filters' => ['factory_number' => '-пусто-'],
|
|
|
|
|
+ ]));
|
|
|
|
|
+ $factoryResponse->assertOk();
|
|
|
|
|
+ $factoryAddresses = $factoryResponse->viewData('products_sku')->pluck('object_address')->all();
|
|
|
|
|
+ $this->assertContains('ул. Пустая фабрика', $factoryAddresses);
|
|
|
|
|
+ $this->assertContains('ул. Пробелы фабрика', $factoryAddresses);
|
|
|
|
|
+ $this->assertNotContains('ул. Заполненная', $factoryAddresses);
|
|
|
|
|
+
|
|
|
|
|
+ $dateResponse = $this->actingAs($this->adminUser)
|
|
|
|
|
+ ->get(route('product_sku.index', [
|
|
|
|
|
+ 'filters' => ['manufacture_date' => '-пусто-'],
|
|
|
|
|
+ ]));
|
|
|
|
|
+ $dateResponse->assertOk();
|
|
|
|
|
+ $dateAddresses = $dateResponse->viewData('products_sku')->pluck('object_address')->all();
|
|
|
|
|
+ $this->assertContains('ул. Пустая дата', $dateAddresses);
|
|
|
|
|
+ $this->assertNotContains('ул. Заполненная', $dateAddresses);
|
|
|
|
|
+
|
|
|
|
|
+ $statementResponse = $this->actingAs($this->adminUser)
|
|
|
|
|
+ ->get(route('product_sku.index', [
|
|
|
|
|
+ 'filters' => ['statement_number' => '-пусто-'],
|
|
|
|
|
+ ]));
|
|
|
|
|
+ $statementResponse->assertOk();
|
|
|
|
|
+ $statementAddresses = $statementResponse->viewData('products_sku')->pluck('object_address')->all();
|
|
|
|
|
+ $this->assertContains('ул. Пустая ведомость', $statementAddresses);
|
|
|
|
|
+ $this->assertNotContains('ул. Заполненная', $statementAddresses);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// ==================== Show ====================
|
|
// ==================== Show ====================
|
|
|
|
|
|
|
|
public function test_admin_can_view_product_sku(): void
|
|
public function test_admin_can_view_product_sku(): void
|