Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[IntegrationTests] Tests in EavSetupTest affect global state #39616

Open
1 of 5 tasks
stollr opened this issue Feb 11, 2025 · 4 comments · May be fixed by #39617
Open
1 of 5 tasks

[IntegrationTests] Tests in EavSetupTest affect global state #39616

stollr opened this issue Feb 11, 2025 · 4 comments · May be fixed by #39617
Labels
Area: Framework Component: Framework/TestFramework Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Reported on 2.4.x Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it

Comments

@stollr
Copy link
Contributor

stollr commented Feb 11, 2025

Preconditions and environment

  • Magento version: 2.4-develop

Steps to reproduce

  1. Open the integration test dev/tests/integration/testsuite/Magento/Eav/Setup/EavSetupTest.php
  2. Append a new test at the end of the file, which should definitely succeed. For example this one:
    public function testAddAttributeAfterInvalidAttributeCodesWereTriedToBeAdded(): void
    {
        $attributeData = $this->getAttributeData();
        $this->eavSetup->addAttribute(\Magento\Catalog\Model\Product::ENTITY, 'test_123', $attributeData);
    }
  1. Now, execute all tests in the file (cd dev/tests/integration && ../../../vendor/bin/phpunit --filter EavSetupTest)

Expected result

All tests should be completed successfully.

Actual result

Our simple test fails, although it should not. The following message is outputted:

There was 1 error:

  1. Magento\Eav\Setup\EavSetupTest::testAddAttributeAfterInvalidAttributeCodesWereTriedToBeAdded
    Magento\Framework\Exception\LocalizedException: An attribute code must not be less than 1 and more than 60 characters.\nAn attribute code must not be less than 1 and more than 60 characters.\nAn attribute code must not be less than 1 and more than 60 characters.\nAn attribute code must not be less than 1 and more than 60 characters.\nAttribute code "1first_character_is_not_letter" is invalid. Please use only letters (a-z or A-Z), numbers (0-9) or underscore () in this field, and the first character should be a letter.\nAttribute code "attribute.with.dots" is invalid. Please use only letters (a-z or A-Z), numbers (0-9) or underscore () in this field, and the first character should be a letter.

The reason is that during the previous tests, which tested to add attributes with invalid codes, the Magento\Eav\Model\Validator\Attribute\Code added error messages to its internal array, which are never resetted. That's why subsequent tests, which try to add attributes, will fail.

Additional information

No response

Release note

No response

Triage and priority

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
@engcom-Bravo engcom-Bravo added Reported on 2.4.x Indicates original Magento version for the Issue report. Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it labels Feb 11, 2025
@github-project-automation github-project-automation bot moved this to Ready for Confirmation in Issue Confirmation and Triage Board Feb 11, 2025
stollr added a commit to stollr/magento2 that referenced this issue Feb 11, 2025
because the affect global state (adding error messages to the `Magento\Eav\Model\Validator\Attribute\Code` service) which will affect further tests that try to add eav attributes.

This change fixes magento#39616.
@stollr stollr linked a pull request Feb 11, 2025 that will close this issue
5 tasks
@engcom-Hotel engcom-Hotel self-assigned this Feb 12, 2025
Copy link

m2-assistant bot commented Feb 12, 2025

Hi @engcom-Hotel. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue.
  • 3. Add Area: XXXXX label to the ticket, indicating the functional areas it may be related to.
  • 4. Verify that the issue is reproducible on 2.4-develop branch
    Details- If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
  • 5. Add label Issue: Confirmed once verification is complete.
  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Hotel
Copy link
Contributor

Hello @stollr,

Thanks for the report and collaboration!

We have tried to reproduce the issue in the latest 2.4-develop branch and the issue is reproducible for us with the mentioned steps in the main description.

Please refer to the below screenshot for reference:

Image

Hence confirming the issue.

Thanks

@engcom-Hotel engcom-Hotel added Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Component: Framework/TestFramework Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Area: Framework labels Feb 12, 2025
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.adobe.com/browse/AC-13910 is successfully created for this GitHub issue.

Copy link

m2-assistant bot commented Feb 12, 2025

✅ Confirmed by @engcom-Hotel. Thank you for verifying the issue.
Issue Available: @engcom-Hotel, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@engcom-Hotel engcom-Hotel added the Priority: P2 A defect with this priority could have functionality issues which are not to expectations. label Feb 12, 2025
@engcom-Hotel engcom-Hotel moved this to Ready for Development in High Priority Backlog Feb 12, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Area: Framework Component: Framework/TestFramework Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Reported on 2.4.x Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Triage: Dev.Experience Issue related to Developer Experience and needs help with Triage to Confirm or Reject it
Projects
Status: Ready for Development
Development

Successfully merging a pull request may close this issue.

4 participants