Skip to content

Commit 945f2bd

Browse files
committed
MC-37922: Html tag <br> visible in message
1 parent db7cab6 commit 945f2bd

File tree

2 files changed

+90
-0
lines changed

2 files changed

+90
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
sku,_store,_attribute_set,product_type,categories,_product_websites,color,cost,country_of_manufacture,created_at,custom_design,custom_design_from,custom_design_to,custom_layout_update,description,gallery,gift_message_available,gift_wrapping_available,gift_wrapping_price,has_options,image,image_label,is_returnable,manufacturer,meta_description,meta_keyword,meta_title,minimal_price,msrp,msrp_display_actual_price_type,name,news_from_date,news_to_date,options_container,page_layout,price,quantity_and_stock_status,related_tgtr_position_behavior,related_tgtr_position_limit,required_options,short_description,small_image,small_image_label,special_from_date,special_price,special_to_date,status,tax_class_id,thumbnail,thumbnail_label,updated_at,upsell_tgtr_position_behavior,upsell_tgtr_position_limit,url_key,url_path,visibility,weight,qty,min_qty,use_config_min_qty,is_qty_decimal,backorders,use_config_backorders,min_sale_qty,use_config_min_sale_qty,max_sale_qty,use_config_max_sale_qty,is_in_stock,notify_stock_qty,use_config_notify_stock_qty,manage_stock,use_config_manage_stock,use_config_qty_increments,qty_increments,use_config_enable_qty_inc,enable_qty_increments,is_decimal_divided,website_id,_related_sku,_related_position,_crosssell_sku,_crosssell_position,_upsell_sku,_upsell_position,_tier_price_website,_tier_price_customer_group,_tier_price_qty,_tier_price_price,_media_attribute_id,_media_image,_media_label,_media_position,_media_is_disabled,_associated_sku,_associated_default_qty,_associated_position
2+
"",,Default,simple,,base,,,,"2014-12-25 19:52:47",,,,,,,,,,0,,,"No",,"simple product 1 ","simple product 1","simple product 1",,,,"simple product 1",,,"Block after Info Column",,100.0000,"In Stock",,,0,,,,,,,1,2,,,"2014-12-25 19:52:47",,,simple-product-1,,"catalog, search",,123.0000,0.0000,1,0,0,1,1.0000,1,0.0000,1,1,,1,1,0,1,0.0000,1,0,0,1,,,,,,,,,,,,,,,,,,
3+
"",,Default,simple,,base,,,,"2014-12-25 19:53:14",,,,,,,,,,0,,,"No",,"simple product 2 ","simple product 2","simple product 2",,,,"simple product 2",,,"Block after Info Column",,200.0000,"In Stock",,,0,,,,,,,1,2,,,"2014-12-25 19:53:14",,,simple-product-2,,"catalog, search",,234.0000,0.0000,1,0,0,1,1.0000,1,0.0000,1,1,,1,1,0,1,0.0000,1,0,0,1,,,,,,,,,,,,,,,,,,
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\ImportExport\Controller\Adminhtml;
7+
8+
use Magento\Framework\Filesystem\DirectoryList;
9+
use Magento\Framework\HTTP\Adapter\FileTransferFactory;
10+
use Magento\ImportExport\Model\Import;
11+
use Magento\ImportExport\Model\Import\ErrorProcessing\ProcessingErrorAggregatorInterface;
12+
use Magento\ImportExport\Controller\Adminhtml\Import\HttpFactoryMock;
13+
14+
/**
15+
* @magentoAppArea adminhtml
16+
*/
17+
class ImportResultTest extends \Magento\TestFramework\TestCase\AbstractBackendController
18+
{
19+
/**
20+
* @dataProvider validationDataProvider
21+
* @param string $fileName
22+
* @param string $mimeType
23+
* @param string $delimiter
24+
* @throws \Magento\Framework\Exception\FileSystemException
25+
* @backupGlobals enabled
26+
* @magentoDbIsolation enabled
27+
* @SuppressWarnings(PHPMD.Superglobals)
28+
*/
29+
public function testAddErrorMessages(string $fileName, string $mimeType, string $delimiter): void
30+
{
31+
$validationStrategy = ProcessingErrorAggregatorInterface::VALIDATION_STRATEGY_STOP_ON_ERROR;
32+
33+
$this->getRequest()->setParam('isAjax', true);
34+
$this->getRequest()->setMethod('POST');
35+
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
36+
37+
/** @var $formKey \Magento\Framework\Data\Form\FormKey */
38+
$formKey = $this->_objectManager->get(\Magento\Framework\Data\Form\FormKey::class);
39+
$this->getRequest()->setPostValue('form_key', $formKey->getFormKey());
40+
$this->getRequest()->setPostValue('entity', 'catalog_product');
41+
$this->getRequest()->setPostValue('behavior', 'append');
42+
$this->getRequest()->setPostValue(Import::FIELD_NAME_VALIDATION_STRATEGY, $validationStrategy);
43+
$this->getRequest()->setPostValue(Import::FIELD_NAME_ALLOWED_ERROR_COUNT, 0);
44+
$this->getRequest()->setPostValue('_import_field_separator', $delimiter);
45+
46+
/** @var \Magento\TestFramework\App\Filesystem $filesystem */
47+
$filesystem = $this->_objectManager->get(\Magento\Framework\Filesystem::class);
48+
$tmpDir = $filesystem->getDirectoryWrite(DirectoryList::SYS_TMP);
49+
$subDir = str_replace('\\', '_', __CLASS__);
50+
$tmpDir->create($subDir);
51+
$target = $tmpDir->getAbsolutePath("{$subDir}/{$fileName}");
52+
copy(__DIR__ . "/Import/_files/{$fileName}", $target);
53+
54+
$_FILES = [
55+
'import_file' => [
56+
'name' => $fileName,
57+
'type' => $mimeType,
58+
'tmp_name' => $target,
59+
'error' => 0,
60+
'size' => filesize($target)
61+
]
62+
];
63+
64+
$this->_objectManager->configure(
65+
[
66+
'preferences' => [FileTransferFactory::class => HttpFactoryMock::class]
67+
]
68+
);
69+
70+
$this->dispatch('backend/admin/import/validate');
71+
$this->assertStringNotContainsString('&lt;br&gt;', $this->getResponse()->getBody());
72+
}
73+
74+
/**
75+
* @return array
76+
*/
77+
public function validationDataProvider(): array
78+
{
79+
return [
80+
[
81+
'file_name' => 'invalid_catalog_products.csv',
82+
'mime-type' => 'text/csv',
83+
'delimiter' => ',',
84+
],
85+
];
86+
}
87+
}

0 commit comments

Comments
 (0)