-
Notifications
You must be signed in to change notification settings - Fork 9.4k
Intercepted classes don't work correctly when using ReflectionClass - Integration Tests #18668
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
Comments
Hi @domeglic. Thank you for your report.
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
where @domeglic do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?
|
@domeglic what if you define plugin on interface? |
It didn't make a difference, in the end the class is still the Interceptor. But I have found one way to fix it: public function reinitStores()
{
//In order to restore configFixture values
$testAppConfig = ObjectManager::getInstance()->get(Config::class);
$reflection = new \ReflectionClass($testAppConfig);
$dataProperty = $reflection->getProperty('data');
$dataProperty->setAccessible(true);
$savedConfig = $dataProperty->getValue($testAppConfig);
$this->decoratedStoreManager->reinitStores();
$dataProperty->setValue($testAppConfig, $savedConfig);
$this->dispatchInitCurrentStoreAfterEvent();
} There is no property data because it is private and $reflection is of type Interceptor. But it seems the solution is simple by just checking if there is a parent class: if ($reflection->getParentClass()) {
$dataProperty = $reflection->getParentClass()->getProperty('data');
} else {
$dataProperty = $reflection->getProperty('data');
} Then it would work in case a plugin or proxy is set. |
Hi @engcom-backlog-nazar. Thank you for working on this issue.
|
Hi @domeglic thank you for you report, please try to use inserface instand of appConfig class -> |
As I said that didn't make any difference. |
@domeglic ok, wait one second, i'm will recheck. |
@magento-engcom-team give me 2.3-develop instance |
Hi @engcom-backlog-nazar. Thank you for your request. I'm working on Magento 2.3-develop instance for you |
Hi @engcom-backlog-nazar, here is your Magento instance. |
@engcom-backlog-nazar Thank you for verifying the issue. Based on the provided information internal tickets |
@magento-engcom-team give me 2.4-develop instance |
Hi @domeglic. Thank you for your request. I'm working on Magento 2.4-develop instance for you |
Hi @domeglic, here is your Magento instance. |
…on \Magento\TestFramework\App\Config
…\TestFramework\Store\StoreManager
…\Config should be requested in the constructor of \Magento\TestFramework\Store\StoreManager
Summary (*)
Creating a store inside integration tests doesn't work if there is a plugin defined for
Magento\Framework\App\Config
.I have a test that requires a new store and it is not possible to save it. There is an exception "Property data does not exist".
When saving a store, method
\Magento\TestFramework\Store\StoreManager::reinitStores
is called, the reflection class will only have properties from theInterceptor
class and not\Magento\TestFramework\App\Config
.PHP: 7.0
Magento: 2.2.6
Examples (*)
Create a plugin for Config, doesn't matter what it does:
Have an integration test that creates a new store:
Proposed solution
The text was updated successfully, but these errors were encountered: