Skip to content

Commit 6dfb0d7

Browse files
committed
Update Tests
1 parent 3eca5b4 commit 6dfb0d7

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

tests/Traits/WithOrderTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2192,8 +2192,9 @@ public function attemptCreateOrderWithInstalment()
21922192
*/
21932193
$orderService = app()->make( OrdersService::class );
21942194
$faker = Factory::create();
2195-
$products = Product::whereRelation( 'unit_quantities', 'quantity', '>', 100 )
2196-
->with( 'unit_quantities', fn( $query ) => $query->where( 'quantity', '>', 100 ) )
2195+
$products = Product::whereRelation( 'unit_quantities', 'quantity', '>', 2000 )
2196+
->where( 'type', '!=', Product::TYPE_GROUPED )
2197+
->with([ 'unit_quantities' => fn( $query ) => $query->where( 'quantity', '>', 2000 ) ])
21972198
->get()
21982199
->shuffle()->take(1);
21992200
$shippingFees = $faker->randomElement([100, 150, 200, 250, 300, 350, 400]);
@@ -2777,8 +2778,8 @@ protected function attemptCouponUsage()
27772778

27782779
private function retreiveProducts()
27792780
{
2780-
$products = Product::whereRelation( 'unit_quantities', 'quantity', '>', 100 )
2781-
->with( 'unit_quantities', fn( $query ) => $query->where( 'quantity', '>', 100 ) )
2781+
$products = Product::with([ 'unit_quantities' => fn( $query ) => $query->where( 'quantity', '>', 1000 ) ])
2782+
->whereRelation( 'unit_quantities', 'quantity', '>', 1000 )
27822783
->get()
27832784
->shuffle()
27842785
->take(3);

tests/Traits/WithProductTest.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,16 +258,20 @@ protected function attemptCreateGroupedProduct()
258258

259259
protected function attemptAdjustmentByDeletion()
260260
{
261-
$product = Product::find(1);
262-
$unitQuantity = $product->unit_quantities[0];
261+
$productUnitQuantity = ProductUnitQuantity::where( 'quantity', '>', 10 )
262+
->with( 'product' )
263+
->whereRelation( 'product', function( $query ){
264+
return $query->where( 'stock_management', Product::STOCK_MANAGEMENT_ENABLED );
265+
})
266+
->first();
263267

264268
$response = $this->json( 'POST', '/api/nexopos/v4/products/adjustments', [
265269
'products' => [
266270
[
267-
'id' => $product->id,
271+
'id' => $productUnitQuantity->product->id,
268272
'adjust_action' => 'deleted',
269-
'name' => $product->name,
270-
'adjust_unit' => $unitQuantity,
273+
'name' => $productUnitQuantity->product->name,
274+
'adjust_unit' => $productUnitQuantity,
271275
'adjust_reason' => __( 'Performing a test adjustment' ),
272276
'adjust_quantity' => 1,
273277
],

0 commit comments

Comments
 (0)