Skip to content

Commit e6c311a

Browse files
ACQE-8858: Verify that The store that was requested should be visible on credit memo grid page in admin
- Fixed static failures
1 parent 6f630ce commit e6c311a

File tree

1 file changed

+13
-74
lines changed

1 file changed

+13
-74
lines changed

dev/tests/integration/testsuite/Magento/Sales/Model/StoreWithNumericNameCreditmemoWorkflowTest.php

Lines changed: 13 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,6 @@ class StoreWithNumericNameCreditmemoWorkflowTest extends TestCase
5555
*/
5656
private $storeManager;
5757

58-
/**
59-
* @var WebsiteResource
60-
*/
61-
private $websiteResource;
62-
63-
/**
64-
* @var GroupResource
65-
*/
66-
private $groupResource;
67-
68-
/**
69-
* @var StoreResource
70-
*/
71-
private $storeResource;
72-
7358
/**
7459
* @var OrderRepositoryInterface
7560
*/
@@ -80,11 +65,6 @@ class StoreWithNumericNameCreditmemoWorkflowTest extends TestCase
8065
*/
8166
private $creditmemoRepository;
8267

83-
/**
84-
* @var InvoiceManagementInterface
85-
*/
86-
private $invoiceService;
87-
8868
/**
8969
* @var CreditmemoFactory
9070
*/
@@ -100,36 +80,6 @@ class StoreWithNumericNameCreditmemoWorkflowTest extends TestCase
10080
*/
10181
private $productRepository;
10282

103-
/**
104-
* @var WebsiteInterfaceFactory
105-
*/
106-
private $websiteFactory;
107-
108-
/**
109-
* @var GroupInterfaceFactory
110-
*/
111-
private $groupFactory;
112-
113-
/**
114-
* @var StoreInterfaceFactory
115-
*/
116-
private $storeFactory;
117-
118-
/**
119-
* @var AddressFactory
120-
*/
121-
private $addressFactory;
122-
123-
/**
124-
* @var OrderPaymentInterfaceFactory
125-
*/
126-
private $paymentFactory;
127-
128-
/**
129-
* @var OrderItemInterfaceFactory
130-
*/
131-
private $orderItemFactory;
132-
13383
/**
13484
* Test data constants
13585
*/
@@ -149,25 +99,14 @@ class StoreWithNumericNameCreditmemoWorkflowTest extends TestCase
14999
*/
150100
protected function setUp(): void
151101
{
102+
parent::setUp();
152103
$this->objectManager = Bootstrap::getObjectManager();
153104
$this->storeManager = $this->objectManager->get(StoreManagerInterface::class);
154-
$this->websiteResource = $this->objectManager->get(WebsiteResource::class);
155-
$this->groupResource = $this->objectManager->get(GroupResource::class);
156-
$this->storeResource = $this->objectManager->get(StoreResource::class);
157105
$this->orderRepository = $this->objectManager->get(OrderRepositoryInterface::class);
158106
$this->creditmemoRepository = $this->objectManager->get(CreditmemoRepositoryInterface::class);
159-
$this->invoiceService = $this->objectManager->get(InvoiceManagementInterface::class);
160107
$this->creditmemoFactory = $this->objectManager->get(CreditmemoFactory::class);
161108
$this->searchCriteriaBuilder = $this->objectManager->get(SearchCriteriaBuilder::class);
162109
$this->productRepository = $this->objectManager->get(ProductRepositoryInterface::class);
163-
164-
// Cache factories for better performance
165-
$this->websiteFactory = $this->objectManager->get(WebsiteInterfaceFactory::class);
166-
$this->groupFactory = $this->objectManager->get(GroupInterfaceFactory::class);
167-
$this->storeFactory = $this->objectManager->get(StoreInterfaceFactory::class);
168-
$this->addressFactory = $this->objectManager->get(AddressFactory::class);
169-
$this->paymentFactory = $this->objectManager->get(OrderPaymentInterfaceFactory::class);
170-
$this->orderItemFactory = $this->objectManager->get(OrderItemInterfaceFactory::class);
171110
}
172111

173112
/**
@@ -202,41 +141,41 @@ public function testCompleteWorkflowWithNumericStoreNames(): void
202141
private function createStoreConfigurationWithNumericNames(): StoreInterface
203142
{
204143
// Create website with numeric name
205-
$website = $this->websiteFactory->create()
144+
$website = $this->objectManager->get(WebsiteInterfaceFactory::class)->create()
206145
->setCode(self::WEBSITE_CODE)
207146
->setName(self::WEBSITE_NAME);
208-
$this->websiteResource->save($website);
147+
$this->objectManager->get(WebsiteResource::class)->save($website);
209148
$this->assertEntityCreated($website, self::WEBSITE_CODE, self::WEBSITE_NAME);
210149

211150
// Create store group with numeric name
212-
$storeGroup = $this->groupFactory->create()
151+
$storeGroup = $this->objectManager->get(GroupInterfaceFactory::class)->create()
213152
->setCode(self::STORE_GROUP_CODE)
214153
->setName(self::STORE_GROUP_NAME)
215154
->setWebsiteId($website->getId())
216155
->setRootCategoryId(self::DEFAULT_ROOT_CATEGORY_ID);
217-
$this->groupResource->save($storeGroup);
156+
$this->objectManager->get(GroupResource::class)->save($storeGroup);
218157
$this->assertEntityCreated($storeGroup, self::STORE_GROUP_CODE, self::STORE_GROUP_NAME);
219158

220159
// Link website to store group
221160
$website->setDefaultGroupId($storeGroup->getId());
222-
$this->websiteResource->save($website);
161+
$this->objectManager->get(WebsiteResource::class)->save($website);
223162
$this->storeManager->reinitStores();
224163

225164
// Create store view with numeric name
226-
$store = $this->storeFactory->create()
165+
$store = $this->objectManager->get(StoreInterfaceFactory::class)->create()
227166
->setCode(self::STORE_CODE)
228167
->setWebsiteId($website->getId())
229168
->setGroupId($storeGroup->getId())
230169
->setName(self::STORE_NAME)
231170
->setSortOrder(self::STORE_SORT_ORDER)
232171
->setIsActive(1);
233-
$this->storeResource->save($store);
172+
$this->objectManager->get(StoreResource::class)->save($store);
234173
$this->assertEntityCreated($store, self::STORE_CODE, self::STORE_NAME);
235174
$this->assertEquals(1, $store->getIsActive());
236175

237176
// Link store group to store
238177
$storeGroup->setDefaultStoreId($store->getId());
239-
$this->groupResource->save($storeGroup);
178+
$this->objectManager->get(GroupResource::class)->save($storeGroup);
240179

241180
// Final verification
242181
$this->storeManager->reinitStores();
@@ -281,7 +220,7 @@ private function createOrderOnNumericStore(StoreInterface $store): OrderInterfac
281220
$addresses = $this->createOrderAddresses();
282221

283222
// Create payment using cached factory
284-
$payment = $this->paymentFactory->create()
223+
$payment = $this->objectManager->get(OrderPaymentInterfaceFactory::class)->create()
285224
->setMethod(Checkmo::PAYMENT_METHOD_CHECKMO_CODE)
286225
->setAdditionalInformation('last_trans_id', '11122')
287226
->setAdditionalInformation('metadata', ['type' => 'free', 'fraudulent' => false]);
@@ -334,7 +273,7 @@ private function createOrderOnNumericStore(StoreInterface $store): OrderInterfac
334273
*/
335274
private function createOrderAddresses(): array
336275
{
337-
$billingAddress = $this->addressFactory->create()->setData([
276+
$billingAddress = $this->objectManager->get(AddressFactory::class)->create()->setData([
338277
'region' => 'CA',
339278
'region_id' => '12',
340279
'postcode' => '11111',
@@ -367,7 +306,7 @@ private function createOrderAddresses(): array
367306
*/
368307
private function createOrderItem($product, float $productPrice, float $orderTotal)
369308
{
370-
return $this->orderItemFactory->create()
309+
return $this->objectManager->get(OrderItemInterfaceFactory::class)->create()
371310
->setProductId($product->getId())
372311
->setQtyOrdered(self::ORDER_QTY)
373312
->setBasePrice($productPrice)
@@ -388,7 +327,7 @@ private function createOrderItem($product, float $productPrice, float $orderTota
388327
*/
389328
private function createAndSaveInvoice(OrderInterface $order): void
390329
{
391-
$invoice = $this->invoiceService->prepareInvoice($order);
330+
$invoice = $this->objectManager->get(InvoiceManagementInterface::class)->prepareInvoice($order);
392331
$invoice->register();
393332
$invoice->setIncrementId($order->getIncrementId());
394333
$order = $invoice->getOrder();

0 commit comments

Comments
 (0)