Skip to content

#18668: Fixed store reinitialization for integration tests on projects with plugins on \Magento\TestFramework\App\Config #34372

New issue

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

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

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: 2.4-develop
Choose a base branch
from

Conversation

bgorski
Copy link
Contributor

@bgorski bgorski commented Oct 18, 2021

Description (*)

This PR fixes store reinitialization for integration tests done on projects with plugins on \Magento\Framework\App\Config\ScopeConfigInterface which effectively makes the system use that plugin on all preferences for that interface.

When you have such a plugin, it forces the system to generate an Interceptor class for the \Magento\TestFramework\App\Config class (the implementation of ScopeConfigInterface in the integration tests framework). When a reflection is created for that Interceptor class, it doesn't have the 'data' property which its parents has, which results in a \ReflectionException being thrown on $reflection->getProperty('data'). In this case, the property has to be fetched from the parent class (the actual Config class).

Related Pull Requests

Fixed Issues (if relevant)

  1. Fixes Intercepted classes don't work correctly when using ReflectionClass - Integration Tests #18668

Manual testing scenarios (*)

Create a module with two things:

  1. A plugin for \Magento\Framework\App\Config\ScopeConfigInterface with anything inside, like:
public function afterGetValue(
    \Magento\Framework\App\Config\ScopeConfigInterface $subject,
    $result
) {
    return $result;
}

di.xml:

<type name="Magento\Framework\App\Config\ScopeConfigInterface">
    <plugin name="myplugin" type="MyVendor\MyModule\Plugin\MyPlugin"/>
</type>
  1. An integration test that creates a new website via fixture or is doing anything else that triggers the reinitStores() function. Actual asserts inside the test don't matter, so you can just create an assert that true is true: $this->assertTrue(true)

Then run your test. The expected result is that it doesn't fail with "Error in fixture: [path here]. Property data does not exist

Questions or comments

IMPORTANT: Although the issue this PR fixes concerns only projects with customization, not a clean Magento instance, this is exactly the purpose of integration tests framework - to let people test their custom modules (with the only two use cases when it's not testing custom code being the core team and contributors using it to test new code introduced to the core). Because of this I believe it's justified to process this PR with a high priority (higher than P3). Once you hit the issue, there's no workaround for it and you have to patch the integration tests framework to be able to keep using it on your project.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

@m2-assistant
Copy link

m2-assistant bot commented Oct 18, 2021

Hi @bgorski. Thank you for your contribution
Here are some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

For more details, please, review the Magento Contributor Guide documentation.

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@magento-engcom-team magento-engcom-team added Partner: MRM Commerce partners-contribution Pull Request is created by Magento Partner labels Oct 18, 2021
@m2-community-project m2-community-project bot added Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Severity: S2 Major restrictions or short-term circumventions are required until a fix is available. Progress: pending review labels Oct 18, 2021
@bgorski
Copy link
Contributor Author

bgorski commented Oct 18, 2021

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

…\Config should be requested in the constructor of \Magento\TestFramework\Store\StoreManager
@bgorski
Copy link
Contributor Author

bgorski commented Oct 18, 2021

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@bgorski
Copy link
Contributor Author

bgorski commented Oct 19, 2021

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@bgorski
Copy link
Contributor Author

bgorski commented Oct 19, 2021

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@bgorski
Copy link
Contributor Author

bgorski commented Oct 19, 2021

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@bgorski
Copy link
Contributor Author

bgorski commented Oct 19, 2021

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@bgorski
Copy link
Contributor Author

bgorski commented Oct 19, 2021

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@bgorski bgorski changed the title #18668: Fixed store reinitialization for integration tests on projects with plugins on \Magento\TestFramework\App\Config [WIP] #18668: Fixed store reinitialization for integration tests on projects with plugins on \Magento\TestFramework\App\Config Oct 19, 2021
@bgorski
Copy link
Contributor Author

bgorski commented Oct 19, 2021

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@bgorski
Copy link
Contributor Author

bgorski commented Oct 20, 2021

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@bgorski
Copy link
Contributor Author

bgorski commented Oct 21, 2021

I need to deal with this issue reported by static tests:

FILE: /var/www/html/dev/tests/integration/framework/Magento/TestFramework/Store/StoreManager.php
------------------------------------------------------------------------------------------------------------------------
FOUND 1 ERROR AFFECTING 1 LINE
------------------------------------------------------------------------------------------------------------------------
 1 | ERROR | An error occurred during processing; checking has been aborted. The error message was: Undefined index:
   |       | comment_opener in
   |       | /var/www/html/vendor/magento/magento-coding-standard/Magento2/Sniffs/Commenting/ClassPropertyPHPDocFormattingSniff.php
   |       | on line 71
------------------------------------------------------------------------------------------------------------------------

Then I guess I can remove the WIP mark.

@bgorski
Copy link
Contributor Author

bgorski commented Oct 22, 2021

quick update on this - the error is there due to the magento coding standard having a bug that prevents it from working with classes with typed properties. I reported the bug here: magento/magento-coding-standard#315.
While I could simply remove those typed properties, I prefer not to impact code quality because the check has a bug, hopefully we won't wait for a resolution for very long.
Removing the [WIP] mark as this the code here won't change.

@bgorski bgorski changed the title [WIP] #18668: Fixed store reinitialization for integration tests on projects with plugins on \Magento\TestFramework\App\Config #18668: Fixed store reinitialization for integration tests on projects with plugins on \Magento\TestFramework\App\Config Oct 22, 2021
@bgorski
Copy link
Contributor Author

bgorski commented Oct 30, 2021

@magento run Static Tests, Functional Tests B2B, Functional Tests CE

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@bgorski
Copy link
Contributor Author

bgorski commented Nov 9, 2021

@magento run Static Tests, Functional Tests CE

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@bgorski
Copy link
Contributor Author

bgorski commented Nov 23, 2021

@magento run Static Tests, Functional Tests CE

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@bgorski
Copy link
Contributor Author

bgorski commented Nov 29, 2021

@magento run all tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@bgorski
Copy link
Contributor Author

bgorski commented Dec 16, 2021

@magento run Static Tests, Functional Tests EE, Functional Tests B2B

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@bgorski
Copy link
Contributor Author

bgorski commented Oct 15, 2022

@magento run Static Tests, Functional Tests B2B

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@bgorski
Copy link
Contributor Author

bgorski commented Feb 21, 2023

@magento run Static Tests

@magento-automated-testing
Copy link

The requested builds are added to the queue. You should be able to see them here within a few minutes. Please re-request them if they don't show in a reasonable amount of time.

@bgorski
Copy link
Contributor Author

bgorski commented Mar 18, 2024

@magento give me 2.4.1 instance

Copy link

Hi @bgorski. Thank you for your request. I'm working on Magento instance for you.

Copy link

Hi @bgorski, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

@bgorski
Copy link
Contributor Author

bgorski commented Mar 18, 2024

@magento give me 2.4.6-p2 instance

Copy link

Hi @bgorski. Thank you for your request. I'm working on Magento instance for you.

Copy link

Hi @bgorski, unfortunately there is no ability to deploy Magento instance at the moment. Please try again later.

@Zaahed
Copy link
Contributor

Zaahed commented Sep 24, 2024

@magento run all tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Partner: MRM Commerce partners-contribution Pull Request is created by Magento Partner Priority: P2 A defect with this priority could have functionality issues which are not to expectations. Progress: pending review Release Line: 2.4 Severity: S2 Major restrictions or short-term circumventions are required until a fix is available.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Intercepted classes don't work correctly when using ReflectionClass - Integration Tests
3 participants