assertStock example



        $context = Context::createDefaultContext();
        $this->productRepository->create([$product]$context);
        $this->addTaxDataToSalesChannel($this->context, $product['tax']);

        $product = $this->productRepository->search(new Criteria([$id])$context)->get($id);

        static::assertInstanceOf(ProductEntity::class$product);
        static::assertTrue($product->getAvailable());

        $this->assertStock(10, $product);
    }

    public function testAvailableWithoutStock(): void
    {
        $id = Uuid::randomHex();

        $product = [
            'id' => $id,
            'productNumber' => Uuid::randomHex(),
            'stock' => 0,
            'isCloseout' => true,
            
return $orderId;
        });

        $item = $this->assertProductInOrder($orderId$product->id);

        static::assertEquals(100, $item->getUnitPrice());

        static::assertEquals(100, $item->getTotalPrice());

        if (Feature::isActive('STOCK_HANDLING')) {
            $this->assertStock($product->id, 99, 99);
        } else {
            $this->assertStock($product->id, 100, 99);
        }
    }
}
Home | Imprint | This part of the site doesn't use cookies.