-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'media-modules' of github.com:magento-engcom/magento2ce …
…into media-modules
- Loading branch information
Showing
51 changed files
with
1,044 additions
and
483 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductDeleteTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<?php | ||
/** | ||
* Copyright © Magento, Inc. All rights reserved. | ||
* See COPYING.txt for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Magento\GraphQl\Catalog; | ||
|
||
use Magento\Catalog\Api\ProductRepositoryInterface; | ||
use Magento\TestFramework\ObjectManager; | ||
use Magento\TestFramework\TestCase\GraphQlAbstract; | ||
|
||
/** | ||
* Test that product is not present in GQL after it was deleted | ||
*/ | ||
class ProductDeleteTest extends GraphQlAbstract | ||
{ | ||
/** | ||
* @var \Magento\TestFramework\ObjectManager | ||
*/ | ||
private $objectManager; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); | ||
} | ||
|
||
/** | ||
* @magentoApiDataFixture Magento/Customer/_files/customer.php | ||
* @magentoApiDataFixture Magento/Catalog/_files/product_simple_with_all_fields.php | ||
*/ | ||
public function testQuerySimpleProductAfterDelete() | ||
{ | ||
$productSku = 'simple'; | ||
|
||
$query = <<<QUERY | ||
{ | ||
products(filter: {sku: {eq: "{$productSku}"}}) | ||
{ | ||
items { | ||
attribute_set_id | ||
} | ||
} | ||
} | ||
QUERY; | ||
// get customer ID token | ||
/** @var \Magento\Integration\Api\CustomerTokenServiceInterface $customerTokenService */ | ||
$customerTokenService = $this->objectManager->create( | ||
\Magento\Integration\Api\CustomerTokenServiceInterface::class | ||
); | ||
$customerToken = $customerTokenService->createCustomerAccessToken('customer@example.com', 'password'); | ||
|
||
$headerMap = ['Authorization' => 'Bearer ' . $customerToken]; | ||
$response = $this->graphQlQuery($query, [], '', $headerMap); | ||
$this->assertArrayHasKey('products', $response); | ||
$this->assertArrayHasKey('items', $response['products']); | ||
$this->assertCount(1, $response['products']['items']); | ||
|
||
// Delete the product and verify it is actually not accessible via the storefront anymore | ||
/** @var ProductRepositoryInterface $productRepository */ | ||
$productRepository = ObjectManager::getInstance()->get(ProductRepositoryInterface::class); | ||
|
||
$registry = ObjectManager::getInstance()->get(\Magento\Framework\Registry::class); | ||
$registry->unregister('isSecureArea'); | ||
$registry->register('isSecureArea', true); | ||
$productRepository->deleteById($productSku); | ||
$registry->unregister('isSecureArea'); | ||
$registry->register('isSecureArea', false); | ||
|
||
$response = $this->graphQlQuery($query, [], '', $headerMap); | ||
$this->assertArrayHasKey('products', $response); | ||
$this->assertArrayHasKey('items', $response['products']); | ||
$this->assertCount(0, $response['products']['items']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.