-
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 pull request #3433 from magento-engcom/graphql-develop-prs
[EngCom] Public Pull Requests - GraphQL
- Loading branch information
Showing
9 changed files
with
178 additions
and
94 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
142 changes: 142 additions & 0 deletions
142
dev/tests/api-functional/testsuite/Magento/GraphQl/Catalog/ProductTextAttributesTest.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,142 @@ | ||
<?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\Helper\Bootstrap; | ||
use Magento\TestFramework\TestCase\GraphQlAbstract; | ||
|
||
class ProductTextAttributesTest extends GraphQlAbstract | ||
{ | ||
/** | ||
* @var ProductRepositoryInterface | ||
*/ | ||
private $productRepository; | ||
|
||
protected function setUp() | ||
{ | ||
$this->productRepository = Bootstrap::getObjectManager()::getInstance()->get(ProductRepositoryInterface::class); | ||
} | ||
|
||
/** | ||
* @magentoApiDataFixture Magento/Catalog/_files/product_simple.php | ||
*/ | ||
public function testProductTextAttributes() | ||
{ | ||
$productSku = 'simple'; | ||
|
||
$query = <<<QUERY | ||
{ | ||
products(filter: {sku: {eq: "{$productSku}"}}) | ||
{ | ||
items { | ||
sku | ||
description { | ||
html | ||
} | ||
short_description { | ||
html | ||
} | ||
} | ||
} | ||
} | ||
QUERY; | ||
$response = $this->graphQlQuery($query); | ||
|
||
$this->assertEquals( | ||
$productSku, | ||
$response['products']['items'][0]['sku'] | ||
); | ||
$this->assertEquals( | ||
'Short description', | ||
$response['products']['items'][0]['short_description']['html'] | ||
); | ||
$this->assertEquals( | ||
'Description with <b>html tag</b>', | ||
$response['products']['items'][0]['description']['html'] | ||
); | ||
} | ||
|
||
/** | ||
* @magentoApiDataFixture Magento/Catalog/_files/product_virtual.php | ||
*/ | ||
public function testProductWithoutFilledTextAttributes() | ||
{ | ||
$productSku = 'virtual-product'; | ||
|
||
$query = <<<QUERY | ||
{ | ||
products(filter: {sku: {eq: "{$productSku}"}}) | ||
{ | ||
items { | ||
sku | ||
description { | ||
html | ||
} | ||
short_description { | ||
html | ||
} | ||
} | ||
} | ||
} | ||
QUERY; | ||
$response = $this->graphQlQuery($query); | ||
|
||
$this->assertEquals( | ||
$productSku, | ||
$response['products']['items'][0]['sku'] | ||
); | ||
$this->assertEquals( | ||
'', | ||
$response['products']['items'][0]['short_description']['html'] | ||
); | ||
$this->assertEquals( | ||
'', | ||
$response['products']['items'][0]['description']['html'] | ||
); | ||
} | ||
|
||
/** | ||
* Test for checking that product fields with directives allowed are rendered correctly | ||
* | ||
* @magentoApiDataFixture Magento/Catalog/_files/product_simple.php | ||
* @magentoApiDataFixture Magento/Cms/_files/block.php | ||
*/ | ||
public function testHtmlDirectivesRendering() | ||
{ | ||
$productSku = 'simple'; | ||
$cmsBlockId = 'fixture_block'; | ||
$assertionCmsBlockText = 'Fixture Block Title'; | ||
|
||
$product = $this->productRepository->get($productSku, false, null, true); | ||
$product->setDescription('Test: {{block id="' . $cmsBlockId . '"}}'); | ||
$product->setShortDescription('Test: {{block id="' . $cmsBlockId . '"}}'); | ||
$this->productRepository->save($product); | ||
|
||
$query = <<<QUERY | ||
{ | ||
products(filter: {sku: {eq: "{$productSku}"}}) { | ||
items { | ||
description { | ||
html | ||
} | ||
short_description { | ||
html | ||
} | ||
} | ||
} | ||
} | ||
QUERY; | ||
$response = $this->graphQlQuery($query); | ||
|
||
self::assertContains($assertionCmsBlockText, $response['products']['items'][0]['description']['html']); | ||
self::assertNotContains('{{block id', $response['products']['items'][0]['description']['html']); | ||
self::assertContains($assertionCmsBlockText, $response['products']['items'][0]['short_description']['html']); | ||
self::assertNotContains('{{block id', $response['products']['items'][0]['short_description']['html']); | ||
} | ||
} |
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
65 changes: 0 additions & 65 deletions
65
...api-functional/testsuite/Magento/GraphQl/Catalog/ProductWithDescriptionDirectivesTest.php
This file was deleted.
Oops, something went wrong.
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.