PHP built-in attributes help to declare context in your code. Attributes can be used alone or together with Annotations to help to declare context in your code.
PHP built-in attributes are currently available to Magento Open Source contributors only. They will be released for general use with Magento Open Source 2.4.5. PHPUnit annotations are still available for use with Magento Open Source.
The following attributes are available in integration tests:
|Application Isolation||AppIsolation||Enables or disables application isolation when you run tests. When enabled, an application state after a test run will be the same as before the test run. For example, you should enable it when you want to create sessions in a test, but you don’t want them to affect other tests.|
|Configuration Fixture||Config||Sets up configuration settings for a particular test. The list of settings is stored in the
|Database Isolation||DbIsolation||Enables or disables database isolation. Disabled by default, unless you are using the
|Data Fixture||DataFixture||Points to a class or a method that creates testing entities (fixtures) for test execution. These are applied during the transaction.|
|Data Fixture Before Transaction||DataFixtureBeforeTransaction||Points to a class or a method that creates testing entities (fixtures) for test execution before the transaction begins. You must implement a rollback method for changes made here.|
|Application Area||AppArea||Configures test environment in the context of specified application area.|
|Enable/Disable Cache||Cache||Enables or disables certain cache segment (or all of them) to prevent isolation problems.|
|Indexer Dimension Mode||IndexerDimensionMode||Sets the indexer dimension mode for the test run. More information can be found in the DevBlog.|
|Register Components||ComponentsDir||Registers fixture components from the specified directory (recursively). Unregisters the components after the test is finished.|
The application-specific annotations for integration tests are applied in the following order:
This order is necessary to meet the requirement of setting up the store-scoped configuration values for fixture stores (stores that are created by data fixtures).
PHP built-in attributes are only available with PHP8 and above.