Skip to content

Commit d8b30bb

Browse files
pradeep1819devarul
authored andcommitted
ACP2E-1377: HTML tags removed in Page Builder editor after Product Import
1 parent 2b889f4 commit d8b30bb

File tree

1 file changed

+30
-25
lines changed
  • dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export

1 file changed

+30
-25
lines changed

dev/tests/integration/testsuite/Magento/CatalogImportExport/Model/Export/ProductTest.php

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
namespace Magento\CatalogImportExport\Model\Export;
1010

11-
use Magento\Catalog\Api\ProductRepositoryInterface;
1211
use Magento\Catalog\Api\CategoryRepositoryInterface;
12+
use Magento\Catalog\Api\ProductRepositoryInterface;
1313
use Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection as ProductAttributeCollection;
1414
use Magento\Catalog\Observer\SwitchPriceAttributeScopeOnConfigChange;
1515
use Magento\Catalog\Test\Fixture\Category as CategoryFixture;
@@ -19,6 +19,8 @@
1919
use Magento\CatalogInventory\Api\StockItemRepositoryInterface;
2020
use Magento\CatalogInventory\Model\Stock\Item;
2121
use Magento\Framework\App\Config\ReinitableConfigInterface;
22+
use Magento\Framework\Exception\NoSuchEntityException;
23+
use Magento\Store\Model\Store;
2224
use Magento\Store\Model\StoreManagerInterface;
2325
use Magento\Store\Test\Fixture\Store as StoreFixture;
2426
use Magento\TestFramework\Fixture\AppArea;
@@ -139,29 +141,6 @@ public function testExport(): void
139141
$this->assertEquals(1, $occurrencesCount);
140142
}
141143

142-
/**
143-
* Verify successful export of product with HTML tag
144-
*
145-
* @magentoDataFixture Magento/CatalogImportExport/_files/product_export_data_special_chars.php
146-
* @magentoDbIsolation enabled
147-
*
148-
* @return void
149-
*/
150-
public function testExportBehaviour(): void
151-
{
152-
$product = $this->productRepository->get('simple "1"');
153-
$product->setDescription('Description with <h2>this is test page</h2>');
154-
$product->save();
155-
$this->model->setWriter(
156-
$this->objectManager->create(
157-
\Magento\ImportExport\Model\Export\Adapter\Csv::class
158-
)
159-
);
160-
$exportData = $this->model->export();
161-
$this->assertStringContainsString('New Product', $exportData);
162-
$this->assertStringContainsString('Description with <h2>this is test page</h2>', $exportData);
163-
}
164-
165144
/**
166145
* Verify successful export of product with stock data with 'use config max sale quantity is enabled
167146
*
@@ -259,20 +238,46 @@ public function exportWithJsonAndMarkupTextAttributeDataProvider(): array
259238

260239
/**
261240
* @magentoDataFixture Magento/CatalogImportExport/_files/product_export_data_special_chars.php
262-
* @magentoDbIsolation enabled
241+
* @magentoDbIsolation disabled
263242
*
264243
* @return void
244+
* @throws NoSuchEntityException
265245
*/
266246
public function testExportSpecialChars(): void
267247
{
248+
$product = $this->productRepository->get('simple "1"');
249+
$product->setStoreId(Store::DEFAULT_STORE_ID);
250+
$product->setDescription('Description with <h2>this is test page</h2>');
251+
$product->save();
252+
268253
$this->model->setWriter(
269254
$this->objectManager->create(
270255
\Magento\ImportExport\Model\Export\Adapter\Csv::class
271256
)
272257
);
273258
$exportData = $this->model->export();
259+
274260
$this->assertStringContainsString('simple "1"', $exportData);
275261
$this->assertStringContainsString('Category with slash\/ symbol', $exportData);
262+
$this->assertStringContainsString('New Product', $exportData);
263+
$this->assertStringContainsString('Description with <h2>this is test page</h2>', $exportData);
264+
$this->assertFalse($this->hasDuplicateRowsForProducts($exportData));
265+
}
266+
267+
/**
268+
* Verify exported data does not contain duplicate rows for product
269+
*
270+
* @param $exportData
271+
* @return bool
272+
*/
273+
private function hasDuplicateRowsForProducts($exportData): bool
274+
{
275+
$skus = [];
276+
foreach (explode("\n", $exportData, -1) as $line) {
277+
$skus[] = current(explode(',', $line));
278+
}
279+
array_shift($skus);
280+
return count($skus) !== count(array_flip($skus));
276281
}
277282

278283
/**

0 commit comments

Comments
 (0)