Skip to content

Commit cfba3b3

Browse files
committed
MC-40836: Create automated test for: "Configure: Flat Rate Shipping Method, Multi Shipping Options, Shipping Origin"
1 parent d63cc85 commit cfba3b3

File tree

1 file changed

+14
-10
lines changed
  • dev/tests/integration/testsuite/Magento/Config/Controller/Adminhtml/System/Config

1 file changed

+14
-10
lines changed

dev/tests/integration/testsuite/Magento/Config/Controller/Adminhtml/System/Config/SaveTest.php

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
declare(strict_types=1);
77

8-
namespace Magento\Config\Controller\Adminhtml\System;
8+
namespace Magento\Config\Controller\Adminhtml\System\Config;
99

1010
use Magento\Config\Model\Config\Loader;
1111
use Magento\Framework\App\Request\Http as HttpRequest;
@@ -41,17 +41,17 @@ public function setUp(): void
4141

4242
/**
4343
* @dataProvider saveConfigDataProvider
44+
* @magentoDbIsolation enabled
4445
* @param array $params
4546
* @param array $post
46-
* @magentoDbIsolation enabled
4747
* @return void
4848
*/
4949
public function testSaveConfig(array $params, array $post): void
5050
{
5151
$expectedPathValue = $this->prepareExpectedPathValue($params['section'], $post['groups']);
5252
$this->dispatchWithParams($params, $post);
5353
$this->assertSessionMessages(
54-
$this->equalTo([(string)__('You saved the configuration.')]),
54+
$this->containsEqual((string)__('You saved the configuration.')),
5555
MessageInterface::TYPE_SUCCESS
5656
);
5757
$this->assertPathValue($expectedPathValue);
@@ -120,7 +120,6 @@ public function saveConfigDataProvider(): array
120120
*/
121121
private function prepareExpectedPathValue(string $section, array $groups): array
122122
{
123-
$expectedData = [];
124123
foreach ($groups as $groupId => $groupData) {
125124
$groupPath = $section . '/' . $groupId;
126125
foreach ($groupData['fields'] as $fieldId => $fieldData) {
@@ -129,7 +128,7 @@ private function prepareExpectedPathValue(string $section, array $groups): array
129128
}
130129
}
131130

132-
return $expectedData;
131+
return $expectedData ?? [];
133132
}
134133

135134
/**
@@ -148,13 +147,18 @@ private function assertPathValue(array $expectedPathValue): void
148147
$scope->getId(),
149148
false
150149
);
151-
$filteredActualPathValue = [];
152150
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+
);
156161
}
157-
$this->assertEquals($groupData, $filteredActualPathValue);
158162
}
159163
}
160164

0 commit comments

Comments
 (0)