CodeExplorer addProductByNumber example
public function testAddAndDeleteProductByNumber(string
$productId, string
$productNumber, bool
$available = true
): void
{ $contextToken = Uuid::
randomHex();
$cartService =
$this->
getContainer()->
get(CartService::
class);
if ($productId &&
$available) { $this->
createProduct($productId,
$productNumber);
} $request =
$this->
createRequest(['number' =>
$productNumber]);
$salesChannelContext =
$this->
createSalesChannelContext($contextToken);
$response =
$this->
getContainer()->
get(CartLineItemController::
class)->
addProductByNumber($request,
$salesChannelContext);
$cart =
$cartService->
getCart($contextToken,
$salesChannelContext);
$cartLineItem =
$cart->
getLineItems()->
get($productId);
$flashBagEntries =
$this->
getFlashBag()->
all();
if ($productId &&
$available) { static::
assertArrayHasKey('success',
$flashBagEntries);
static::
assertNotNull($cartLineItem);
} else {