Skip to content

Commit ca31a93

Browse files
author
oleksandrkravchuk
committed
Merge branch 'community-features-252' of github.com:swnsma/magento2-1 into community-features-252
2 parents 125a5d4 + d29e8a7 commit ca31a93

File tree

48 files changed

+1026
-473
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1026
-473
lines changed

app/code/Magento/CatalogImportExport/Model/Import/Product/StatusProcessor.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,8 @@ public function loadOldStatus(array $linkIdBySku): void
101101
$select = $connection->select()
102102
->from($this->getAttribute()->getBackend()->getTable())
103103
->columns([$linkId, 'store_id', 'value'])
104-
->where(sprintf('%s IN (?)', $linkId), array_values($linkIdBySku));
104+
->where(sprintf('%s IN (?)', $linkId), array_values($linkIdBySku))
105+
->where('attribute_id = ?', $this->getAttribute()->getId());
105106
$skuByLinkId = array_flip($linkIdBySku);
106107

107108
foreach ($connection->fetchAll($select) as $item) {

app/code/Magento/Wishlist/Test/Mftf/Test/AdminDeleteCustomerWishListItemTest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
<argument name="productVar" value="$createProduct$"/>
4545
</actionGroup>
4646
<actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="logout"/>
47+
<actionGroup ref="AdminLogoutActionGroup" stepKey="adminLogoutBeforeCheck"/>
4748
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
4849
<actionGroup ref="OpenEditCustomerFromAdminActionGroup" stepKey="navigateToCustomerEditPage">
4950
<argument name="customer" value="$createCustomer$"/>
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/api-functional/testsuite/Magento/Webapi/JoinDirectivesTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ protected function setUp(): void
5050
*
5151
* @magentoApiDataFixture Magento/SalesRule/_files/rules_rollback.php
5252
* @magentoApiDataFixture Magento/Sales/_files/quote.php
53+
* @magentoAppIsolation enabled
5354
*/
5455
public function testGetList()
5556
{
@@ -87,6 +88,7 @@ public function testGetList()
8788

8889
/**
8990
* @magentoApiDataFixture Magento/Sales/_files/invoice.php
91+
* @magentoAppIsolation enabled
9092
*/
9193
public function testAutoGeneratedGetList()
9294
{
@@ -131,6 +133,7 @@ public function testAutoGeneratedGetList()
131133
* Test get list of orders with extension attributes.
132134
*
133135
* @magentoApiDataFixture Magento/Sales/_files/order.php
136+
* @magentoAppIsolation enabled
134137
*/
135138
public function testGetOrdertList()
136139
{

dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractBackendController.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,14 @@ protected function setUp(): void
5858
parent::setUp();
5959

6060
$this->_objectManager->get(\Magento\Backend\Model\UrlInterface::class)->turnOffSecretKey();
61-
61+
/**
62+
* Authorization can be created on test bootstrap...
63+
* If it will be created on test bootstrap we will have invalid RoleLocator object.
64+
* As tests by default are run not from adminhtml area...
65+
*/
66+
\Magento\TestFramework\ObjectManager::getInstance()->removeSharedInstance(
67+
\Magento\Framework\Authorization::class
68+
);
6269
$this->_auth = $this->_objectManager->get(\Magento\Backend\Model\Auth::class);
6370
$this->_session = $this->_auth->getAuthStorage();
6471
$credentials = $this->_getAdminCredentials();

dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/AbstractEavTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,13 @@ protected function getOptionValueByLabel(string $attributeCode, string $label):
220220
/**
221221
* Returns product for testing.
222222
*
223+
* @param bool $forceReload
223224
* @return ProductInterface
225+
* @throws \Magento\Framework\Exception\NoSuchEntityException
224226
*/
225-
protected function getProduct(): ProductInterface
227+
protected function getProduct($forceReload = false): ProductInterface
226228
{
227-
return $this->productRepository->get('simple', false, Store::DEFAULT_STORE_ID);
229+
return $this->productRepository->get('simple', false, Store::DEFAULT_STORE_ID, $forceReload);
228230
}
229231

230232
/**

dev/tests/integration/testsuite/Magento/Catalog/Ui/DataProvider/Product/Form/Modifier/Eav/DefaultAttributesTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public function testModifyMeta(): void
3333
public function testModifyData(): void
3434
{
3535
$expectedData = include __DIR__ . '/../_files/eav_expected_data_output.php';
36-
$this->callModifyDataAndAssert($this->getProduct(), $expectedData);
36+
// force load: ProductRepositoryInterface::getList does not add stock item, prices, categories to product
37+
$this->callModifyDataAndAssert($this->getProduct(true), $expectedData);
3738
}
3839

3940
/**

dev/tests/integration/testsuite/Magento/Catalog/_files/category_product_rollback.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@
2222
if ($category->getId()) {
2323
$category->delete();
2424
}
25+
$registry->unregister('isSecureArea');
26+
$registry->register('isSecureArea', false);

dev/tests/integration/testsuite/Magento/Catalog/_files/configurable_products_with_custom_attribute_layered_navigation.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55
*/
66
declare(strict_types=1);
77

8-
use Magento\Eav\Api\AttributeRepositoryInterface;
9-
use Magento\TestFramework\Helper\Bootstrap;
10-
use Magento\TestFramework\Helper\CacheCleaner;
118
use Magento\TestFramework\Workaround\Override\Fixture\Resolver;
129

1310
Resolver::getInstance()->requireDataFixture('Magento/ConfigurableProduct/_files/configurable_products.php');
1411

12+
use Magento\TestFramework\Helper\Bootstrap;
13+
use Magento\Eav\Api\AttributeRepositoryInterface;
14+
use Magento\TestFramework\Helper\CacheCleaner;
15+
1516
$eavConfig = Bootstrap::getObjectManager()->get(\Magento\Eav\Model\Config::class);
1617

1718
/** @var $attribute \Magento\Catalog\Model\ResourceModel\Eav\Attribute */
@@ -28,11 +29,5 @@
2829
/** @var AttributeRepositoryInterface $attributeRepository */
2930
$attributeRepository = Bootstrap::getObjectManager()->create(AttributeRepositoryInterface::class);
3031
$attributeRepository->save($attribute);
32+
3133
CacheCleaner::cleanAll();
32-
/** @var \Magento\Indexer\Model\Indexer\Collection $indexerCollection */
33-
$indexerCollection = Bootstrap::getObjectManager()->get(\Magento\Indexer\Model\Indexer\Collection::class);
34-
$indexerCollection->load();
35-
/** @var \Magento\Indexer\Model\Indexer $indexer */
36-
foreach ($indexerCollection->getItems() as $indexer) {
37-
$indexer->reindexAll();
38-
}

dev/tests/integration/testsuite/Magento/Catalog/_files/multiple_products.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
->setName('Simple Product1')
1414
->setSku('simple1')
1515
->setTaxClassId('none')
16-
->setDescription('description')
16+
->setDescription('description uniqueword')
1717
->setShortDescription('short description')
1818
->setOptionsContainer('container1')
1919
->setMsrpDisplayActualPriceType(\Magento\Msrp\Model\Product\Attribute\Source\Type::TYPE_IN_CART)

0 commit comments

Comments
 (0)