Skip to content

Commit 74a3b06

Browse files
committed
fixed integration tests
1 parent c366ac4 commit 74a3b06

File tree

2 files changed

+100
-35
lines changed

2 files changed

+100
-35
lines changed

dev/tests/integration/testsuite/Magento/Backend/Model/Search/ConfigTest.php

Lines changed: 72 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@
66

77
namespace Magento\Backend\Model\Search;
88

9+
use Magento\Backend\App\Area\FrontNameResolver;
10+
use Magento\Framework\App\Area;
11+
use Magento\Framework\App\AreaList;
12+
use Magento\Framework\App\Cache\State;
13+
use Magento\Framework\App\Config\FileResolver;
14+
use Magento\Framework\Config\FileIteratorFactory;
15+
use Magento\Framework\Config\ScopeInterface;
916
use Magento\TestFramework\Helper\Bootstrap;
1017

1118
/**
@@ -15,13 +22,12 @@ class ConfigTest extends \PHPUnit\Framework\TestCase
1522
{
1623
/**
1724
* @dataProvider loadDataProvider
25+
* @magentoConfigFixture current_store general/store_information/name Foo
1826
*/
1927
public function testLoad($query, $expectedResult)
2028
{
21-
/** Preconditions */
22-
$objectManager = Bootstrap::getObjectManager();
2329
/** @var \Magento\Backend\Model\Search\Config $configSearch */
24-
$configSearch = $objectManager->create(\Magento\Backend\Model\Search\Config::class);
30+
$configSearch = $this->getConfigSearchInstance();
2531
$configSearch->setQuery($query);
2632
$configSearch->load();
2733

@@ -46,62 +52,93 @@ public function testLoad($query, $expectedResult)
4652
}
4753
}
4854

55+
/**
56+
* @return \Magento\Backend\Model\Search\Config
57+
*/
58+
private function getConfigSearchInstance()
59+
{
60+
Bootstrap::getInstance()->reinitialize([
61+
State::PARAM_BAN_CACHE => true,
62+
]);
63+
Bootstrap::getObjectManager()
64+
->get(ScopeInterface::class)
65+
->setCurrentScope(FrontNameResolver::AREA_CODE);
66+
Bootstrap::getObjectManager()->get(AreaList::class)
67+
->getArea(FrontNameResolver::AREA_CODE)
68+
->load(Area::PART_CONFIG);
69+
70+
$fileResolverMock = $this->getMockBuilder(FileResolver::class)->disableOriginalConstructor()->getMock();
71+
$fileIteratorFactory = Bootstrap::getObjectManager()->get(FileIteratorFactory::class);
72+
$fileIterator = $fileIteratorFactory->create(
73+
[__DIR__ . '/_files/test_config.xml']
74+
);
75+
$fileResolverMock->expects($this->any())->method('get')->will($this->returnValue($fileIterator));
76+
77+
$objectManager = Bootstrap::getObjectManager();
78+
/** @var \Magento\Config\Model\Config\Structure\Reader $structureReader */
79+
$structureReader = $objectManager->create(
80+
\Magento\Config\Model\Config\Structure\Reader::class,
81+
['fileResolver' => $fileResolverMock]
82+
);
83+
/** @var \Magento\Config\Model\Config\Structure\Data $structureData */
84+
$structureData = $objectManager->create(
85+
\Magento\Config\Model\Config\Structure\Data::class,
86+
['reader' => $structureReader]
87+
);
88+
/** @var \Magento\Config\Model\Config\Structure $structure */
89+
$structure = $objectManager->create(
90+
\Magento\Config\Model\Config\Structure::class,
91+
['structureData' => $structureData]
92+
);
93+
94+
return $objectManager->create(
95+
\Magento\Backend\Model\Search\Config::class,
96+
['configStructure' => $structure]
97+
);
98+
}
99+
100+
/**
101+
* @return array
102+
*/
49103
public static function loadDataProvider()
50104
{
51105
return [
52106
'Search by field name' => [
53-
'Store Name',
54-
[
55-
[
56-
'id' => 'general/store_information/name',
57-
'type' => null,
58-
'name' => 'Store Name',
59-
'description' => '/ General / General / Store Information',
60-
],
61-
],
62-
],
63-
'Search by field name, multiple items result' => [
64-
'Secure Base URL',
107+
'Test Field',
65108
[
66109
[
67-
'id' => 'web/secure/base_url',
68-
'type' => null,
69-
'name' => 'Secure Base URL',
70-
'description' => '/ General / Web / Base URLs (Secure)',
71-
],
72-
[
73-
'id' => 'web/secure/base_static_url',
110+
'id' => 'test_section/test_group/test_field_1',
74111
'type' => null,
75-
'name' => 'Secure Base URL for Static View Files',
76-
'description' => '/ General / Web / Base URLs (Secure)',
112+
'name' => 'Test Field',
113+
'description' => '/ Test Tab / Test Section / Test Group',
77114
],
78115
[
79-
'id' => 'web/secure/base_media_url',
116+
'id' => 'test_section/test_group/test_field_2',
80117
'type' => null,
81-
'name' => 'Secure Base URL for User Media Files',
82-
'description' => '/ General / Web / Base URLs (Secure)',
118+
'name' => 'Test Field',
119+
'description' => '/ Test Tab / Test Section / Test Group',
83120
],
84121
],
85122
],
86123
'Search by group name' => [
87-
'Country Options',
124+
'Test Group',
88125
[
89126
[
90-
'id' => 'general/country',
127+
'id' => 'test_section/test_group',
91128
'type' => null,
92-
'name' => 'Country Options',
93-
'description' => '/ General / General',
129+
'name' => 'Test Group',
130+
'description' => '/ Test Tab / Test Section',
94131
],
95132
],
96133
],
97134
'Search by section name' => [
98-
'Currency Setup',
135+
'Test Section',
99136
[
100137
[
101-
'id' => '/currency',
138+
'id' => '/test_section',
102139
'type' => null,
103-
'name' => 'Currency Setup',
104-
'description' => '/ General',
140+
'name' => 'Test Section',
141+
'description' => '/ Test Tab',
105142
],
106143
],
107144
],
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
9+
<system>
10+
<tab id="test">
11+
<label>Test Tab</label>
12+
</tab>
13+
<section id="test_section" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" type="text" sortOrder="0">
14+
<label>Test Section</label>
15+
<tab>test</tab>
16+
17+
<group id="test_group" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" type="text" sortOrder="10">
18+
<label>Test Group</label>
19+
<field id="test_field_1" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" type="text" sortOrder="20">
20+
<label>Test Field</label>
21+
</field>
22+
<field id="test_field_2" translate="label" showInDefault="1" showInWebsite="1" showInStore="1" type="text" sortOrder="20">
23+
<label>Test Field</label>
24+
</field>
25+
</group>
26+
</section>
27+
</system>
28+
</config>

0 commit comments

Comments
 (0)