LoadProductStockSubscriber example

/** * @internal * * @covers \Shopware\Core\Content\Product\Stock\LoadProductStockSubscriber */
class LoadProductStockSubscriberTest extends TestCase
{
    public function testStockDataIsAppliedFromStorage(): void
    {
        $stockStorage = $this->createMock(AbstractStockStorage::class);
        $subscriber = new LoadProductStockSubscriber($stockStorage);

        $ids = new IdsCollection();

        $p1 = (new SalesChannelProductEntity())->assign(['id' => $ids->get('product-1')]);
        $p2 = (new SalesChannelProductEntity())->assign(['id' => $ids->get('product-2')]);

        $stock1 = new StockData($ids->get('product-1'), 10, false, 5, null, null);
        $stock1->addArrayExtension('extra', ['arbitrary-data1' => 'foo']);
        $stock2 = new StockData($ids->get('product-2'), 12, true);

        $stockStorage->expects(static::once())
            
Home | Imprint | This part of the site doesn't use cookies.