2

When writing integration tests, there are two quite similar annotations:

  1. @magentoAdminConfigFixture (GitHub)
  2. @magentoConfigFixture (GitHub)

The latter one is used much more often:

$ grep -R '@magentoAdminConfigFixture ' vendor/magento/ | wc -l
110
$ grep -R '@magentoConfigFixture ' vendor/magento/ | wc -l
1828

However, I cannot find any documentation about the difference (see related DevDocs issue). Some config values are even used in both ways in the core:

$ grep -R '@magentoAdminConfigFixture admin/security/use_form_key' vendor/magento/ | wc -l
8
$ grep -R '@magentoConfigFixture admin/security/use_form_key' vendor/magento/ | wc -l
5

What is the difference between the two? When should I use which one?

1 Answer 1

0

@magentoConfigFixture

You can use this annotation when you need to set some config value before the test starts. The format for this annotation is:

/**
 * @magentoConfigFixture store_code section/group/field value
 */

It will set the value for the configuration field with the path section/group/field for the store that has the code store_code.

@magentoAdminConfigFixture

Similar to magentoConfigFixture except that it sets values for default scope so you cannot pick stores.

Reference: https://dusanlukic.com/annotations-in-magento-2-integration-tests

1
  • To be honest, "similar" does not convince me :D I would like to know the exact difference.
    – Simon
    Commented Jul 25, 2023 at 11:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.