Work on ordertest, splitting address lines, and shipping entry stuff
parent
2c0fbfde5b
commit
487ea48c14
Binary file not shown.
@ -1,38 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Feature;
|
|
||||||
|
|
||||||
use App\Filament\Resources\OrderResource\Pages\ListOrders;
|
|
||||||
use App\Models\Customer;
|
|
||||||
use App\Models\Order;
|
|
||||||
use App\Models\OrderProduct;
|
|
||||||
use App\Models\ProductService;
|
|
||||||
use App\Models\ServiceFile;
|
|
||||||
|
|
||||||
use function Pest\Livewire\livewire;
|
|
||||||
|
|
||||||
it('can list posts', function () {
|
|
||||||
$customer = Customer::factory()->create();
|
|
||||||
$orders = Order::factory()->for($customer)->count(2)->create();
|
|
||||||
|
|
||||||
livewire(ListOrders::class)
|
|
||||||
->assertCanSeeTableRecords($orders);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can create a post', function () {
|
|
||||||
$customer = Customer::factory()->create();
|
|
||||||
$formData = Order::factory()->for($customer)->create();
|
|
||||||
|
|
||||||
$formData['order_products'] = OrderProduct::factory()->count(2)->create();
|
|
||||||
|
|
||||||
$formData['order_products'][0]['xs'] = 4;
|
|
||||||
$formData['order_products'][1]['s'] = 3;
|
|
||||||
|
|
||||||
$serviceFile1 = ServiceFile::factory()->create();
|
|
||||||
$serviceFile2 = ServiceFile::factory()->create();
|
|
||||||
|
|
||||||
$formData['services'][0] = ProductService::factory()->for($serviceFile1)->create();
|
|
||||||
$formData['services'][1] = ProductService::factory()->for($serviceFile2)->create();
|
|
||||||
|
|
||||||
dd($formData);
|
|
||||||
});
|
|
@ -0,0 +1,110 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Enums\OrderAttributes;
|
||||||
|
use App\Enums\OrderStatus;
|
||||||
|
use App\Enums\OrderType;
|
||||||
|
use App\Filament\Resources\OrderResource\Pages\CreateOrder;
|
||||||
|
use App\Models\Contact;
|
||||||
|
use App\Models\Customer;
|
||||||
|
use App\Models\Order;
|
||||||
|
use App\Models\ServiceType;
|
||||||
|
use App\Models\User;
|
||||||
|
|
||||||
|
use function Pest\Livewire\livewire;
|
||||||
|
|
||||||
|
it('can create an order and save it to the database', function () {
|
||||||
|
$type = fake()->randomElement(OrderType::cases());
|
||||||
|
$status = fake()->randomElement(OrderStatus::cases());
|
||||||
|
$customer = Customer::factory()->create();
|
||||||
|
$contact = Contact::factory()->for($customer)->create();
|
||||||
|
$attributes = array_map(fn ($case) => $case->value, OrderAttributes::cases());
|
||||||
|
|
||||||
|
$serviceTypes = ServiceType::factory()->count(2)->create();
|
||||||
|
|
||||||
|
$user = User::factory()->create();
|
||||||
|
$this->actingAs($user);
|
||||||
|
|
||||||
|
$formData = [
|
||||||
|
'order_type' => $type->value,
|
||||||
|
'customer_id' => $customer->id,
|
||||||
|
'contact_id' => $contact->id,
|
||||||
|
'customer_po' => 'Customer PO name here',
|
||||||
|
'order_date' => today(),
|
||||||
|
'due_date' => today()->addDays(10),
|
||||||
|
'notes' => 'Notes go here! Here\'s the notes!',
|
||||||
|
'pre_production' => '1',
|
||||||
|
'printed' => '1',
|
||||||
|
'status' => $status->value,
|
||||||
|
'order_attributes' => $attributes,
|
||||||
|
'order_products' => [
|
||||||
|
[
|
||||||
|
'sku' => 'sku 1',
|
||||||
|
'product_name' => 'test',
|
||||||
|
'color' => 'black',
|
||||||
|
'xs' => '1',
|
||||||
|
's' => '2',
|
||||||
|
'm' => '3',
|
||||||
|
'l' => '4',
|
||||||
|
'xl' => '5',
|
||||||
|
'2xl' => '6',
|
||||||
|
'3xl' => '7',
|
||||||
|
'osfa' => '8',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'sku' => 'sku 2',
|
||||||
|
'product_name' => 'alsotest',
|
||||||
|
'color' => 'white',
|
||||||
|
'xs' => '9',
|
||||||
|
's' => '10',
|
||||||
|
'm' => '11',
|
||||||
|
'l' => '12',
|
||||||
|
'xl' => '13',
|
||||||
|
'2xl' => '14',
|
||||||
|
'3xl' => '15',
|
||||||
|
'osfa' => '16',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
'services' => [
|
||||||
|
[
|
||||||
|
'serviceType' => $serviceTypes[0]->id,
|
||||||
|
'placement' => 'c/f',
|
||||||
|
'serviceFileName' => 'logo name 1',
|
||||||
|
'serviceFileSetupNumber' => '1',
|
||||||
|
'serviceFileWidth' => '1',
|
||||||
|
'serviceFileHeight' => '2',
|
||||||
|
'amount' => '3',
|
||||||
|
'amount_price' => '4',
|
||||||
|
'serviceFileCode' => 'A1234',
|
||||||
|
'notes' => 'Here\'s some notes, all handwritten by me.',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'serviceType' => $serviceTypes[1]->id,
|
||||||
|
'placement' => 'f/b',
|
||||||
|
'serviceFileName' => 'logo name 2',
|
||||||
|
'serviceFileSetupNumber' => '5',
|
||||||
|
'serviceFileWidth' => '6',
|
||||||
|
'serviceFileHeight' => '7',
|
||||||
|
'amount' => '8',
|
||||||
|
'amount_price' => '9',
|
||||||
|
'serviceFileCode' => 'B5678',
|
||||||
|
'notes' => 'Here\'s even more notes, still handwritten by me.',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
|
livewire(CreateOrder::class)
|
||||||
|
->set('data.order_products', [])
|
||||||
|
->set('data.services', [])
|
||||||
|
->fillForm($formData)
|
||||||
|
->call('create')
|
||||||
|
->assertHasNoErrors();
|
||||||
|
|
||||||
|
$order = Order::first();
|
||||||
|
|
||||||
|
$this->assertNotNull($order);
|
||||||
|
|
||||||
|
$this->assertSame($order->customer_id, $formData['customer_id']);
|
||||||
|
|
||||||
|
});
|
@ -1,38 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Feature;
|
|
||||||
|
|
||||||
use App\Filament\Resources\OrderResource\Pages\ListOrders;
|
|
||||||
use App\Models\Customer;
|
|
||||||
use App\Models\Order;
|
|
||||||
use App\Models\OrderProduct;
|
|
||||||
use App\Models\ProductService;
|
|
||||||
use App\Models\ServiceFile;
|
|
||||||
|
|
||||||
use function Pest\Livewire\livewire;
|
|
||||||
|
|
||||||
it('can list posts', function () {
|
|
||||||
$customer = Customer::factory()->create();
|
|
||||||
$orders = Order::factory()->for($customer)->count(2)->create();
|
|
||||||
|
|
||||||
livewire(ListOrders::class)
|
|
||||||
->assertCanSeeTableRecords($orders);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('can create a post', function () {
|
|
||||||
$customer = Customer::factory()->create();
|
|
||||||
$formData = Order::factory()->for($customer)->create();
|
|
||||||
|
|
||||||
$formData['order_products'] = OrderProduct::factory()->count(2)->create();
|
|
||||||
|
|
||||||
$formData['order_products'][0]['xs'] = 4;
|
|
||||||
$formData['order_products'][1]['s'] = 3;
|
|
||||||
|
|
||||||
$serviceFile1 = ServiceFile::factory()->create();
|
|
||||||
$serviceFile2 = ServiceFile::factory()->create();
|
|
||||||
|
|
||||||
$formData['services'][0] = ProductService::factory()->for($serviceFile1)->create();
|
|
||||||
$formData['services'][1] = ProductService::factory()->for($serviceFile2)->create();
|
|
||||||
|
|
||||||
dd($formData);
|
|
||||||
});
|
|
Loading…
Reference in New Issue