Skip to content
This repository was archived by the owner on Nov 19, 2024. It is now read-only.

Commit b060608

Browse files
authored
Merge pull request #2491 from magento-commerce/8-27_integration
8 27 integration
2 parents b56541f + b464388 commit b060608

File tree

5 files changed

+154
-7
lines changed

5 files changed

+154
-7
lines changed

src/guides/v2.4/install-gde/prereq/mysql.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Magento _strongly_ recommends you observe the following standard when you set up
1414
* If you use MySQL database replication, be aware that Magento does _not_ support MySQL statement-based replication. Make sure you use _only_ [row-based replication](https://dev.mysql.com/doc/refman/8.0/en/replication-formats.htmll){:target="_blank"}.
1515

1616
{:.bs-callout-warning}
17-
Magento 2 currently utilizes `CREATE TEMPORARY TABLE` statements inside transactions, which are [incompatible](https://dev.mysql.com/doc/refman/5.7/en/replication-gtids-restrictions.html) with database implementations utilizing GTID-based replication, such as [Google Cloud SQL second-generation instances](https://cloud.google.com/sql/docs/features#differences).
17+
Magento 2 currently utilizes `CREATE TEMPORARY TABLE` statements inside transactions, which are [incompatible](https://dev.mysql.com/doc/refman/5.7/en/replication-gtids-restrictions.html) with database implementations utilizing GTID-based replication, such as [Google Cloud SQL second-generation instances](https://cloud.google.com/sql/docs/features#differences). Consider MySQL for Cloud SQL 8.0 as an alternative.
1818

1919
{:.bs-callout-info}
2020
If your web server and database server are on different hosts, perform the tasks discussed in this topic on the database server host then see [Set up a remote MySQL database connection]({{page.baseurl }}/install-gde/prereq/mysql_remote.html).

src/guides/v2.4/release-notes/open-source-2-4-3.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -708,10 +708,6 @@ We have fixed hundreds of issues in the Magento 2.4.3 core code.
708708

709709
* The image resizing process no longer halts for images in unsupported format. Previously, when `catalog:images:resize` encountered an unsupported image format, the process stopped and Magento displayed this error: `bin/magento catalog:images:resize Unsupported image format`.
710710

711-
<!--- ENGCOM-9148-->
712-
713-
* The image resizing process now processes images marked as hidden in the Admin. Also added the `--skip_hidden_images` option to skip hidden images in the `catalog:images:resize` command. [GitHub-28239](https://github.com/magento/magento2/issues/28239)
714-
715711
<!--- ENGCOM-8925-->
716712

717713
* WEBP and AVIF support for logo images has been added to the Admin. [GitHub-32495](https://github.com/magento/magento2/issues/32495)

src/guides/v2.4/security/two-factor-authentication.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ MFTF uses Google Authenticator to execute tests with 2FA enabled. The following
8181
bin/magento config:set twofactorauth/google/otp_window 60
8282
```
8383

84-
1. Generate a Base32-encoded string for the shared secret value. For example, encoding the string `abcd` with the online [Base32 Encode](https://emn178.github.io/online-tools/base32_encode.html) tool returns the value `MFRGGZDF`. Use the following key to add the encoded value to the MFTF `.credentials` file:
84+
1. Generate a Base32-encoded string for the shared secret value. For example, encoding the string `abcde` with the online [Base32 Encode](https://emn178.github.io/online-tools/base32_encode.html) tool returns the value `MFRGGZDF`. Use the following key to add the encoded value to the MFTF `.credentials` file:
8585

8686
```bash
8787
magento/tfa/OTP_SHARED_SECRET=MFRGGZDF

src/guides/v2.4/test/integration/annotations/magento-data-fixture.md

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
---
2+
group: testing
3+
title: Data fixture annotation
4+
---
5+
6+
A data fixture is a PHP script that sets data you want to reuse in your test.
7+
The script can be defined in a separate file or as a local test case method.
8+
9+
Use data fixtures to prepare a database for tests.
10+
The Integration Testing Framework (ITF) reverts the database to its initial state automatically.
11+
To set up a date fixture, use the `@magentoDataFixture` annotation.
12+
13+
## Format
14+
15+
`@magentoDataFixture` takes an argument that points to the data fixture as a filename or local method.
16+
17+
```php?start_inline=1
18+
/**
19+
* @magentoDataFixture <script_filename>|<method_name>
20+
*/
21+
```
22+
23+
- `<script_filename>` is the filename of the PHP script.
24+
- `<method_name>` is the name of the method declared in the current class.
25+
26+
## Principles
27+
28+
1. Do not use a direct database connection in fixtures to avoid dependencies on the database structure and vendor.
29+
1. Use an application API to implement your data fixtures.
30+
1. A method that implements a data fixture must be declared as `public` and `static`.
31+
1. Fixtures declared at a test level have a higher priority than fixtures declared at a test case level.
32+
1. Test case fixtures are applied to each test in the test case, unless a test has its own fixtures declared.
33+
1. Annotation declaration at a test case level does not affect tests that have their own annotation declarations.
34+
35+
## Usage
36+
37+
As mentioned above, there are two ways to declare fixtures:
38+
39+
- as a PHP script file that is used by other tests and test cases.
40+
- as a local method that is used by other tests in the test cases.
41+
42+
### Fixture as a separate file
43+
44+
Define the fixture in a separate file when you want to reuse it in different test cases.
45+
To declare the fixture, use one of the following conventions:
46+
47+
- Fixture declaration as a path relative to the test suite directory
48+
- Relative to `dev/tests/integration/<test suite directory>`
49+
- With forward slashes `/`
50+
- No leading slash
51+
52+
Example:
53+
54+
```php
55+
/**
56+
* @magentoDataFixture Magento/Cms/_files/pages.php
57+
*/
58+
```
59+
60+
- Fixture declaration as a path relative to a module
61+
- Relative to the directory of a module available in the project
62+
- With forward slashes `/`
63+
- No leading slash in the path part of the declaration
64+
65+
Example:
66+
67+
```php
68+
/**
69+
* @magentoDataFixture VendorName_ModuleName::Test/Integration/_files/fixture_name.php
70+
*/
71+
```
72+
73+
The ITF includes the declared PHP script to your test and executes it during the test run.
74+
75+
The following example demonstrates a simple implementation of a Cms module page test from the Magento codebase.
76+
77+
Data fixture to test a Cms module page: [`dev/tests/integration/testsuite/Magento/Cms/_files/pages.php`][].
78+
79+
Test case that uses the above data fixture: [`dev/tests/integration/testsuite/Magento/Cms/Block/PageTest.php`][].
80+
81+
### Fixture as a method
82+
83+
[`dev/tests/integration/testsuite/Magento/Cms/Controller/PageTest.php`][] demonstrates an example of the `testCreatePageWithSameModuleName()` test method that uses data from the `cmsPageWithSystemRouteFixture()` data fixture.
84+
85+
### Test case and test method scopes
86+
87+
The `@magentoDataFixture` can be specified for a particular test or for an entire test case.
88+
The basic rules for fixture annotation at different levels are:
89+
90+
- `@magentoDataFixture` at a test case level, makes the framework to apply the declared fixtures to each test in the test case.
91+
When the final test is complete, all class-level fixtures are reverted.
92+
- `@magentoDataFixture` for a particular test, signals the framework to revert the fixtures declared on a test case level and applies the fixtures declared at a test method level instead.
93+
When the test is complete, the ITF reverts the applied fixtures.
94+
95+
{:.bs-callout-info}
96+
The integration testing framework interacts with a database to revert the applied fixtures.
97+
98+
### Fixture rollback
99+
100+
A fixture that contains database transactions only, are reverted automatically.
101+
Otherwise, when a fixture creates files or performs any actions other than database transaction, provide the corresponding rollback logic.
102+
Rollbacks are run after reverting all the fixtures related to database transactions.
103+
104+
A fixture rollback must be of the same format as the corresponding fixture, a script or a method:
105+
106+
- A rollback script must be named according to the corresponding fixture suffixed with `_rollback` and stored in the same directory.
107+
- Rollback methods must be of the same class as the corresponding fixture and suffixed with `Rollback`.
108+
109+
Examples:
110+
111+
Fixture/Rollback | Fixture name | Rollback name
112+
-----------------|------------------------------------------------------|-------------------------------------------------------------
113+
Script | `Magento/Catalog/_files/categories.php` | `Magento/Catalog/_files/categories_rollback.php`
114+
Method | `\Magento\Catalog\Model\ProductTest::prepareProduct` | `\Magento\Catalog\Model\ProductTest::prepareProductRollback`
115+
116+
### Restrictions
117+
118+
Do not rely on and do not modify an application state from within a fixture, because [application isolation annotation][magentoAppIsolation] can reset the application state at any time.
119+
120+
<!-- Link definitions -->
121+
122+
[magentoAppIsolation]: magento-app-isolation.html
123+
[`dev/tests/integration/testsuite/Magento/Cms/_files/pages.php`]: {{ site.mage2bloburl }}/{{ page.guide_version }}/dev/tests/integration/testsuite/Magento/Cms/_files/pages.php
124+
[`dev/tests/integration/testsuite/Magento/Cms/Block/PageTest.php`]: {{ site.mage2bloburl }}/{{ page.guide_version }}/dev/tests/integration/testsuite/Magento/Cms/Block/PageTest.php
125+
[`dev/tests/integration/testsuite/Magento/Cms/Controller/PageTest.php`]: {{ site.mage2bloburl }}/{{ page.guide_version }}/dev/tests/integration/testsuite/Magento/Cms/Controller/PageTest.php

src/guides/v2.4/test/integration/integration_test_execution.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,33 @@ Leave all the settings that do not start with `db-` and `amqp-` at their default
9999
You can include additional setup options—available to the `setup:install` command—in the test configuration file. A
100100
complete list of options is available [here]({{ page.baseurl }}/install-gde/install/cli/install-cli.html).
101101

102+
If your project requires custom entries in the `core_config_data` table, such as the introduction of new 3rd party services
103+
that affect your application on a basic level or configuration for logic that would prevent access if not configured
104+
properly, Magento provides a file template for this purpose.
105+
106+
Copy `dev/tests/integration/etc/config-global.php.dist` to `dev/tests/integration/etc/config-global.php` (without the
107+
`.dist` suffix) and add your path-value pairs there. Do not remove existing entries from the file as they are required
108+
for the Integration Test Framework to run tests properly.
109+
110+
Example:
111+
112+
```php
113+
return [
114+
'customer/password/limit_password_reset_requests_method' => 0,
115+
'admin/security/admin_account_sharing' => 1,
116+
'admin/security/limit_password_reset_requests_method' => 0,
117+
'some/custom/path' => 'some-custom-value'
118+
];
119+
```
120+
121+
Note that the file above is only for configuration files required by all integration tests. If you need to introduce
122+
new configuration values for particular tests to perform their function, use the
123+
[@magentoConfigFixture]({{ page.baseurl }}/test/integration/annotations/magento-config-fixture.html) annotation instead.
124+
125+
{:.bs-callout-info}
126+
You can change the locations and names of both files used by the Integration Test Framework that were described
127+
above using the PHPUnit configuration file.
128+
102129
## Adjust the PHPUnit configuration file
103130

104131
See the `dev/tests/integration/phpunit.xml.dist` file for the default integration test configuration.

0 commit comments

Comments
 (0)