Skip to content

Commit 3320c6d

Browse files
author
Serhii Balko
committed
Merge remote-tracking branch 'origin/MC-41576' into 2.4-develop-pr58
2 parents d7b0245 + bdfebe9 commit 3320c6d

File tree

2 files changed

+48
-22
lines changed
  • app/code/Magento/AdvancedPricingImportExport/Controller/Adminhtml/Export
  • dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml

2 files changed

+48
-22
lines changed

app/code/Magento/AdvancedPricingImportExport/Controller/Adminhtml/Export/GetFilter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public function execute()
3434
/** @var $export \Magento\ImportExport\Model\Export */
3535
$export = $this->_objectManager->create(\Magento\ImportExport\Model\Export::class);
3636
$export->setData($data);
37-
$attrFilterBlock->prepareCollection(
38-
$export->filterAttributeCollection($export->getEntityAttributeCollection())
37+
$export->filterAttributeCollection(
38+
$attrFilterBlock->prepareCollection($export->getEntityAttributeCollection())
3939
);
4040
return $resultLayout;
4141
} catch (\Exception $e) {

dev/tests/integration/testsuite/Magento/ImportExport/Controller/Adminhtml/ExportTest.php

Lines changed: 46 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
*/
66
namespace Magento\ImportExport\Controller\Adminhtml;
77

8+
use Magento\TestFramework\Helper\Xpath;
9+
use Magento\TestFramework\TestCase\AbstractBackendController;
10+
811
/**
912
* @magentoAppArea adminhtml
1013
*/
11-
class ExportTest extends \Magento\TestFramework\TestCase\AbstractBackendController
14+
class ExportTest extends AbstractBackendController
1215
{
1316
/**
1417
* Set value of $_SERVER['HTTP_X_REQUESTED_WITH'] parameter here
@@ -18,20 +21,8 @@ class ExportTest extends \Magento\TestFramework\TestCase\AbstractBackendControll
1821
protected $_httpXRequestedWith;
1922

2023
/**
21-
* Get possible entity types
22-
*
23-
* @return array
24+
* @inheritdoc
2425
*/
25-
public function getEntityTypesDataProvider()
26-
{
27-
return [
28-
'products' => ['$entityType' => 'catalog_product'],
29-
'customers' => ['$entityType' => 'customer'],
30-
// customer entities
31-
'customers_customer_entities' => ['$entityType' => 'customer', '$customerEntityType' => 'customer']
32-
];
33-
}
34-
3526
protected function setUp(): void
3627
{
3728
parent::setUp();
@@ -41,6 +32,9 @@ protected function setUp(): void
4132
}
4233
}
4334

35+
/**
36+
* @inheritdoc
37+
*/
4438
protected function tearDown(): void
4539
{
4640
if ($this->_httpXRequestedWith !== null) {
@@ -56,10 +50,14 @@ protected function tearDown(): void
5650
* @dataProvider getEntityTypesDataProvider
5751
*
5852
* @param string $entityType
59-
* @param string $customerEntityType
53+
* @param string|null $customerEntityType
54+
* @param array $expectedAttributes
6055
*/
61-
public function testGetFilterAction($entityType, $customerEntityType = null)
62-
{
56+
public function testGetFilterAction(
57+
string $entityType,
58+
string $customerEntityType = null,
59+
array $expectedAttributes = []
60+
) {
6361
$this->getRequest()->setParam('isAjax', true);
6462

6563
// Provide X_REQUESTED_WITH header in response to mark next action as ajax
@@ -72,7 +70,35 @@ public function testGetFilterAction($entityType, $customerEntityType = null)
7270
}
7371
$this->dispatch($url);
7472

75-
$this->assertStringContainsString('<div id="export_filter_grid"', $this->getResponse()->getBody());
73+
$body = $this->getResponse()->getBody();
74+
$this->assertStringContainsString('<div id="export_filter_grid"', $body);
75+
foreach ($expectedAttributes as $attribute) {
76+
$this->assertStringContainsString("name=\"export_filter[{$attribute}]\"", $body);
77+
}
78+
}
79+
80+
/**
81+
* Get possible entity types
82+
*
83+
* @return array
84+
*/
85+
public function getEntityTypesDataProvider()
86+
{
87+
return [
88+
'products' => [
89+
'entityType' => 'catalog_product',
90+
'customerEntityType' => null,
91+
'expectedAttributes' => ['category_ids']
92+
],
93+
'customers' => [
94+
'entityType' => 'customer'
95+
],
96+
// customer entities
97+
'customers_customer_entities' => [
98+
'entityType' => 'customer',
99+
'customerEntityType' => 'customer'
100+
]
101+
];
76102
}
77103

78104
/**
@@ -86,14 +112,14 @@ public function testIndexAction()
86112

87113
$this->assertEquals(
88114
1,
89-
\Magento\TestFramework\Helper\Xpath::getElementsCountForXpath(
115+
Xpath::getElementsCountForXpath(
90116
'//fieldset[@id="base_fieldset"]',
91117
$body
92118
)
93119
);
94120
$this->assertEquals(
95121
3,
96-
\Magento\TestFramework\Helper\Xpath::getElementsCountForXpath(
122+
Xpath::getElementsCountForXpath(
97123
'//fieldset[@id="base_fieldset"]/div[contains(@class,"field")]',
98124
$body
99125
)

0 commit comments

Comments
 (0)