5
5
*/
6
6
declare (strict_types=1 );
7
7
8
- namespace Magento \Config \Controller \Adminhtml \System ;
8
+ namespace Magento \Config \Controller \Adminhtml \System \ Config ;
9
9
10
10
use Magento \Config \Model \Config \Loader ;
11
11
use Magento \Framework \App \Request \Http as HttpRequest ;
@@ -41,17 +41,17 @@ public function setUp(): void
41
41
42
42
/**
43
43
* @dataProvider saveConfigDataProvider
44
+ * @magentoDbIsolation enabled
44
45
* @param array $params
45
46
* @param array $post
46
- * @magentoDbIsolation enabled
47
47
* @return void
48
48
*/
49
49
public function testSaveConfig (array $ params , array $ post ): void
50
50
{
51
51
$ expectedPathValue = $ this ->prepareExpectedPathValue ($ params ['section ' ], $ post ['groups ' ]);
52
52
$ this ->dispatchWithParams ($ params , $ post );
53
53
$ this ->assertSessionMessages (
54
- $ this ->equalTo ([ (string )__ ('You saved the configuration. ' )] ),
54
+ $ this ->containsEqual ( (string )__ ('You saved the configuration. ' )),
55
55
MessageInterface::TYPE_SUCCESS
56
56
);
57
57
$ this ->assertPathValue ($ expectedPathValue );
@@ -120,7 +120,6 @@ public function saveConfigDataProvider(): array
120
120
*/
121
121
private function prepareExpectedPathValue (string $ section , array $ groups ): array
122
122
{
123
- $ expectedData = [];
124
123
foreach ($ groups as $ groupId => $ groupData ) {
125
124
$ groupPath = $ section . '/ ' . $ groupId ;
126
125
foreach ($ groupData ['fields ' ] as $ fieldId => $ fieldData ) {
@@ -129,7 +128,7 @@ private function prepareExpectedPathValue(string $section, array $groups): array
129
128
}
130
129
}
131
130
132
- return $ expectedData ;
131
+ return $ expectedData ?? [] ;
133
132
}
134
133
135
134
/**
@@ -148,13 +147,18 @@ private function assertPathValue(array $expectedPathValue): void
148
147
$ scope ->getId (),
149
148
false
150
149
);
151
- $ filteredActualPathValue = [];
152
150
foreach ($ groupData as $ fieldPath => $ fieldValue ) {
153
- if (isset ($ actualPathValue [$ fieldPath ])) {
154
- $ filteredActualPathValue [$ fieldPath ] = $ actualPathValue [$ fieldPath ];
155
- }
151
+ $ this ->assertArrayHasKey (
152
+ $ fieldPath ,
153
+ $ actualPathValue ,
154
+ sprintf ('The expected config setting was not saved in the database. Path: %s ' , $ fieldPath )
155
+ );
156
+ $ this ->assertEquals (
157
+ $ fieldValue ,
158
+ $ actualPathValue [$ fieldPath ],
159
+ sprintf ('The expected value of the config setting is not correct. Path: %s ' , $ fieldPath )
160
+ );
156
161
}
157
- $ this ->assertEquals ($ groupData , $ filteredActualPathValue );
158
162
}
159
163
}
160
164
0 commit comments