3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-08-18 03:06:23 +00:00

And more tests

This commit is contained in:
snipe
2026-08-05 22:22:13 +01:00
parent 080520def1
commit 80925cd430
4 changed files with 9 additions and 9 deletions

View File

@ -8,7 +8,6 @@ use App\Models\Actionlog;
use App\Models\Location;
use App\Models\Order;
use App\Models\OrderItem;
use App\Models\Setting;
use App\Models\Supplier;
use App\Models\User;
use Tests\TestCase;

View File

@ -5,10 +5,8 @@ namespace Tests\Feature\Components;
use App\Enums\ActionType;
use App\Models\Actionlog;
use App\Models\Component;
use App\Models\Location;
use App\Models\Order;
use App\Models\OrderItem;
use App\Models\Setting;
use App\Models\Supplier;
use App\Models\User;
use Tests\TestCase;
@ -63,5 +61,4 @@ class ComponentObserverOrderTest extends TestCase
$this->assertSame($line->id, (int) $log->order_item_id);
}
}

View File

@ -8,7 +8,6 @@ use App\Models\Consumable;
use App\Models\Location;
use App\Models\Order;
use App\Models\OrderItem;
use App\Models\Setting;
use App\Models\Supplier;
use App\Models\User;
use Tests\TestCase;

View File

@ -530,22 +530,27 @@ class ImportAccessoriesTest extends ImportDataTestCase implements TestsPermissio
])->assertOk();
$newAccessory = Accessory::query()
->with(['location', 'category', 'manufacturer', 'supplier'])
->with(['location', 'category', 'manufacturer'])
->where('name', $row['modelNumber'])
->sole();
// purchase_date, purchase_cost, and supplier moved off the
// parent to the Orders / OrderItems polymorphic pair —
// recordOrderForImportedRow persists them there. Assertions
// walk through orderItems.order for those three fields.
$this->assertEquals($row['modelNumber'], $newAccessory->name);
$this->assertEquals($row['itemName'], $newAccessory->model_number);
$this->assertEquals($row['quantity'], $newAccessory->qty);
$this->assertEquals($row['notes'], $newAccessory->purchase_date->toDateString());
$this->assertEquals($row['location'], $newAccessory->purchase_cost);
$orderItem = $newAccessory->orderItems()->firstOrFail();
$this->assertEquals($row['notes'], $orderItem->order->purchase_date->toDateString());
$this->assertEquals($row['location'], (float) $orderItem->price);
// See the import_accessory test above for why order_number now
// lives on Orders / OrderItems rather than the parent column.
// Note this custom-mapping test intentionally maps companyName
// to the orderNumber CSV column, verifying that whatever value
// that column carries lands on the OrderItem's Order regardless
// of what the source column was called.
$orderItem = $newAccessory->orderItems()->firstOrFail();
$this->assertEquals($row['companyName'], $orderItem->order->order_number);
$this->assertEquals($row['purchaseDate'], $newAccessory->notes);
$this->assertEquals($row['manufacturerName'], $newAccessory->category->name);