Skip to content

Commit 6638f7e

Browse files
committed
Api-functional tests added
1 parent 0cdfdcb commit 6638f7e

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
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\Data\ProductInterface;
11+
use Magento\Catalog\Api\ProductRepositoryInterface;
12+
use Magento\TestFramework\ObjectManager;
13+
use Magento\TestFramework\TestCase\GraphQlAbstract;
14+
15+
/**
16+
* Test for checking that product fields with directives allowed are rendered correctly
17+
*/
18+
class ProductWithDescriptionDirectivesTest extends GraphQlAbstract
19+
{
20+
/**
21+
* @var \Magento\TestFramework\ObjectManager
22+
*/
23+
private $objectManager;
24+
25+
protected function setUp()
26+
{
27+
$this->objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
28+
}
29+
30+
/**
31+
* @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
32+
* @magentoApiDataFixture Magento/Cms/_files/block.php
33+
*/
34+
public function testHtmlDirectivesRendered()
35+
{
36+
$productSku = 'simple';
37+
$cmsBlockId = 'fixture_block';
38+
$assertionCmsBlockText = 'Fixture Block Title';
39+
40+
/** @var ProductRepositoryInterface $productRepository */
41+
$productRepository = ObjectManager::getInstance()->get(ProductRepositoryInterface::class);
42+
/** @var ProductInterface $product */
43+
$product = $productRepository->get($productSku, false, null, true);
44+
$product->setDescription('Test: {{block id="' . $cmsBlockId . '"}}');
45+
$product->setShortDescription('Test: {{block id="' . $cmsBlockId . '"}}');
46+
$productRepository->save($product);
47+
48+
$query = <<<QUERY
49+
{
50+
products(filter: {sku: {eq: "{$productSku}"}}) {
51+
items {
52+
description
53+
short_description
54+
}
55+
}
56+
}
57+
QUERY;
58+
$response = $this->graphQlQuery($query);
59+
60+
self::assertContains($assertionCmsBlockText, $response['products']['items'][0]['description']);
61+
self::assertContains($assertionCmsBlockText, $response['products']['items'][0]['short_description']);
62+
}
63+
}

0 commit comments

Comments
 (0)