Skip to content

Commit fc23b74

Browse files
committed
MC-36279: Some of Magento integration tests were failed on execution without Inventory Module
1 parent ef17285 commit fc23b74

File tree

2 files changed

+78
-2
lines changed

2 files changed

+78
-2
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\GraphQl\Catalog;
9+
10+
use Magento\Catalog\Api\ProductRepositoryInterface;
11+
use Magento\TestFramework\ObjectManager;
12+
use Magento\TestFramework\TestCase\GraphQlAbstract;
13+
14+
/**
15+
* Test that product is not present in GQL after it was deleted
16+
*/
17+
class ProductDeleteTest extends GraphQlAbstract
18+
{
19+
/**
20+
* @var \Magento\TestFramework\ObjectManager
21+
*/
22+
private $objectManager;
23+
24+
protected function setUp(): void
25+
{
26+
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
27+
}
28+
29+
/**
30+
* @magentoApiDataFixture Magento/Customer/_files/customer.php
31+
* @magentoApiDataFixture Magento/Catalog/_files/product_simple_with_all_fields.php
32+
*/
33+
public function testQuerySimpleProductAfterDelete()
34+
{
35+
$productSku = 'simple';
36+
37+
$query = <<<QUERY
38+
{
39+
products(filter: {sku: {eq: "{$productSku}"}})
40+
{
41+
items {
42+
attribute_set_id
43+
}
44+
}
45+
}
46+
QUERY;
47+
// get customer ID token
48+
/** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */
49+
$customerTokenService = $this->objectManager->create(
50+
\Magento\Integration\Api\CustomerTokenServiceInterface::class
51+
);
52+
$customerToken = $customerTokenService->createCustomerAccessToken('[email protected]', 'password');
53+
54+
$headerMap = ['Authorization' => 'Bearer ' . $customerToken];
55+
$response = $this->graphQlQuery($query, [], '', $headerMap);
56+
$this->assertArrayHasKey('products', $response);
57+
$this->assertArrayHasKey('items', $response['products']);
58+
$this->assertCount(1, $response['products']['items']);
59+
60+
// Delete the product and verify it is actually not accessible via the storefront anymore
61+
/** @var ProductRepositoryInterface $productRepository */
62+
$productRepository = ObjectManager::getInstance()->get(ProductRepositoryInterface::class);
63+
64+
$registry = ObjectManager::getInstance()->get(\Magento\Framework\Registry::class);
65+
$registry->unregister('isSecureArea');
66+
$registry->register('isSecureArea', true);
67+
$productRepository->deleteById($productSku);
68+
$registry->unregister('isSecureArea');
69+
$registry->register('isSecureArea', false);
70+
71+
$response = $this->graphQlQuery($query, [], '', $headerMap);
72+
$this->assertArrayHasKey('products', $response);
73+
$this->assertArrayHasKey('items', $response['products']);
74+
$this->assertCount(0, $response['products']['items']);
75+
}
76+
}

dev/tests/integration/testsuite/Magento/Wishlist/Controller/Index/AddTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@
1414
use Magento\Framework\Message\MessageInterface;
1515
use Magento\TestFramework\TestCase\AbstractController;
1616
use Magento\TestFramework\Wishlist\Model\GetWishlistByCustomerId;
17-
use Zend\Stdlib\Parameters;
17+
use Laminas\Stdlib\Parameters;
1818

1919
/**
2020
* Test for add product to wish list.
2121
*
22-
* @magentoDbIsolation enabled
22+
* @magentoDbIsolation disabled
2323
* @magentoAppArea frontend
2424
* @magentoDataFixture Magento/Customer/_files/customer.php
2525
*/

0 commit comments

Comments
 (0)