- TestCase 공통화: setUpAuthenticatedUser(), api(), assertApiSuccess(), assertApiPaginated() - 기존 10개 테스트 파일의 중복 setUp 코드 → TestCase 상속으로 전환 - Factory 3개 추가: TenantFactory, ClientFactory, OrderFactory - OrderApiTest 12개 테스트 신규 작성 (목록/생성/조회/수정/삭제/상태변경/인증) - 발견: 빈 데이터로 수주 생성 가능 (FormRequest 검증 강화 필요)
64 lines
1.5 KiB
PHP
64 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace Database\Factories;
|
|
|
|
use App\Models\Orders\Order;
|
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
|
|
|
/**
|
|
* @extends Factory<Order>
|
|
*/
|
|
class OrderFactory extends Factory
|
|
{
|
|
protected $model = Order::class;
|
|
|
|
public function definition(): array
|
|
{
|
|
return [
|
|
'order_no' => 'ORD-'.fake()->unique()->numerify('######'),
|
|
'order_type_code' => Order::TYPE_ORDER,
|
|
'status_code' => Order::STATUS_DRAFT,
|
|
'site_name' => fake()->company().' 현장',
|
|
'quantity' => fake()->numberBetween(1, 100),
|
|
'supply_amount' => fake()->numberBetween(100000, 10000000),
|
|
'tax_amount' => 0,
|
|
'total_amount' => 0,
|
|
'received_at' => now(),
|
|
'delivery_date' => now()->addDays(14),
|
|
'memo' => fake()->optional()->sentence(),
|
|
];
|
|
}
|
|
|
|
/**
|
|
* 확정 상태
|
|
*/
|
|
public function confirmed(): static
|
|
{
|
|
return $this->state(['status_code' => Order::STATUS_CONFIRMED]);
|
|
}
|
|
|
|
/**
|
|
* 생산중 상태
|
|
*/
|
|
public function inProduction(): static
|
|
{
|
|
return $this->state(['status_code' => Order::STATUS_IN_PRODUCTION]);
|
|
}
|
|
|
|
/**
|
|
* 완료 상태
|
|
*/
|
|
public function completed(): static
|
|
{
|
|
return $this->state(['status_code' => Order::STATUS_COMPLETED]);
|
|
}
|
|
|
|
/**
|
|
* 취소 상태
|
|
*/
|
|
public function cancelled(): static
|
|
{
|
|
return $this->state(['status_code' => Order::STATUS_CANCELLED]);
|
|
}
|
|
}
|