createMock(Quote::class); $quote->method('getStoreId')->willReturn(16); $quote->method('getAllVisibleItems')->willReturn([]); $checkoutSession = $this->createMock(CheckoutSession::class); $checkoutSession->method('getQuote')->willReturn($quote); $config = $this->createMock(Config::class); $config->expects(self::once()) ->method('isGiftSku') ->with('free-gift', 16) ->willReturn(true); $plugin = new CartPlugin($checkoutSession, $config); $result = $plugin->afterGetSectionData( $this->createMock(Cart::class), [ 'items' => [[ 'item_id' => 42, 'product_sku' => 'free-gift', 'product_url' => 'https://example.test/free-gift', 'product_has_url' => true, 'configure_url' => 'https://example.test/configure', 'product_price' => '$0.00', 'product_price_value' => 0.0, ]], ] ); $item = $result['items'][0]; self::assertTrue($item['is_esun_free_gift']); self::assertSame('Free', (string)$item['line_total']); self::assertSame('Free', (string)$item['product_price']); self::assertSame('', $item['product_url']); self::assertFalse($item['product_has_url']); self::assertSame('', $item['configure_url']); } }