A free open source IT asset/license management system
And more tests
snipe80925cd430a2
diff --git a/tests/Feature/Accessories/AccessoryObserverOrderTest.php b/tests/Feature/Accessories/AccessoryObserverOrderTest.phpindex 2c6bd12a00..c7b2202a3a 100644--- a/tests/Feature/Accessories/AccessoryObserverOrderTest.php+++ b/tests/Feature/Accessories/AccessoryObserverOrderTest.php@@ -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;diff --git a/tests/Feature/Components/ComponentObserverOrderTest.php b/tests/Feature/Components/ComponentObserverOrderTest.phpindex 6b108a1bae..9320e2b426 100644--- a/tests/Feature/Components/ComponentObserverOrderTest.php+++ b/tests/Feature/Components/ComponentObserverOrderTest.php@@ -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);}-}diff --git a/tests/Feature/Consumables/ConsumableObserverOrderTest.php b/tests/Feature/Consumables/ConsumableObserverOrderTest.phpindex 47af607958..27b6804f4e 100644--- a/tests/Feature/Consumables/ConsumableObserverOrderTest.php+++ b/tests/Feature/Consumables/ConsumableObserverOrderTest.php@@ -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;diff --git a/tests/Feature/Importing/Api/ImportAccessoriesTest.php b/tests/Feature/Importing/Api/ImportAccessoriesTest.phpindex 5a956f914a..1da4c5d0ac 100644--- a/tests/Feature/Importing/Api/ImportAccessoriesTest.php+++ b/tests/Feature/Importing/Api/ImportAccessoriesTest.php@@ -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);