Skip to content

Commit 9a84bd1

Browse files
committed
ACP2E-894: wip adding parametrized data fixtures
1 parent e1eb1b2 commit 9a84bd1

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

app/code/Magento/Quote/Test/Fixture/CustomerCart.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,17 @@ public function apply(array $data = []): ?DataObject
9393
{
9494
$data = $this->prepareData($data);
9595
$customerId = $data['customer_id'] ?? null;
96-
$cartService = $this->serviceFactory->create(CartManagementInterface::class, 'createEmptyCartForCustomer');
96+
$storeId = $data['store_id'] ?? null;
97+
if ($storeId) {
98+
$cartService = $this->serviceFactory->create(CartManagementInterface::class, 'createEmptyCart');
99+
} else {
100+
$cartService = $this->serviceFactory->create(CartManagementInterface::class, 'createEmptyCartForCustomer');
101+
}
97102
$cartId = $cartService->execute(['customerId' => $customerId]);
103+
if ($storeId) {
104+
$cartService = $this->serviceFactory->create(CartManagementInterface::class, 'assignCustomer');
105+
$cartService->execute(['cartId' => $cartId, 'customerId' => $customerId, 'storeId' => $storeId]);
106+
}
98107
$cartRepositoryService = $this->serviceFactory->create(CartRepositoryInterface::class, 'get');
99108
return $cartRepositoryService->execute(['cartId' => $cartId]);
100109
}

dev/tests/api-functional/testsuite/Magento/GraphQl/Sales/CustomerOrders/GetCustomerOrdersTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ protected function setUp(): void
101101
],
102102
as: 'customer'
103103
),
104-
DataFixture(CustomerCart::class, ['customer_id' => '$customer.id$'], as: 'quote'),
104+
DataFixture(CustomerCart::class, ['customer_id' => '$customer.id$', 'store_id' => '$store2.id$'], as: 'quote'),
105105
DataFixture(AddProductToCart::class, ['cart_id' => '$quote.id$', 'product_id' => '$product.id$', 'qty' => 1])
106106
]
107107
public function testGetCustomerOrders()

0 commit comments

Comments
 (0)