To modify Magento Admin configuration in MFTF tests it’s better to create custom configuration file in your tests. To do that you need to create a config data file with predefined configurations. Let’s create Vendor/YourModule/Test/Mftf/Data/ConfigData.xml
with following data:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:DataGenerator/etc/dataProfileSchema.xsd"> <entity name="DisableYourFeature"> <!-- Magento default value --> <data key="path">checkout/options/enable_your_feature</data> <data key="label">No</data> <data key="value">0</data> </entity> <entity name="EnableYourFeature"> <data key="path">checkout/options/enable_your_feature</data> <data key="label">Yes</data> <data key="value">1</data> </entity> <entity name="DefaultFeatureLimit"> <!-- Magento default value --> <data key="path">checkout/options/your_feature_limit</data> <data key="label">10</data> <data key="value">10</data> </entity> <entity name="CustomFeatureLimit"> <data key="path">checkout/options/your_feature_limit</data> <data key="label">2</data> <data key="value">2</data> </entity> </entities> |
It’s necessary to add path, value, label to your entity.
Path
– is the configuration path in core_config_data
table.
Label
– is the label of your configuration in Magento Admin.
Value
– is the value that is passes from Magento Admin to backend while saving configuration.
Entity name
– is the name of the entity that is called in your test.
If configuration in Magento Admin is a simple input field then values of label and value should be the same. See example above in DefaultFeatureLimit entity.
You can modify your configuration in before and after conditions of your test calling to your entities. Check example below:
1 2 3 4 5 6 7 8 9 10 |
<test name="YourNewFeatureTest"> <before> <magentoCLI command="config:set {{EnableYourFeature.path}} {{EnableYourFeature.value}}" stepKey="enableYourFeature"/> <magentoCLI command="config:set {{CustomFeatureLimit.path}} {{CustomFeatureLimit.value}}" stepKey="setCustomFeatureLimit"/> </before> <after> <magentoCLI command="config:set {{DisableYourFeature.path}} {{DisableYourFeature.value}}" stepKey="disableYourFeature"/> <magentoCLI command="config:set {{DefaultFeatureLimit.path}} {{DefaultFeatureLimit.value}}" stepKey="setDefaultFeatureLimit"/> </after> </test> |