Magento扩展开发-测试多个config.xml文件-值是否被缓存? [英] Magento extension development - testing multiple config.xml files - values being cached?

查看:91
本文介绍了Magento扩展开发-测试多个config.xml文件-值是否被缓存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为我正在构建的Magento扩展编写测试框架.该扩展在<global><default>下的etc/config.xml中存储了许多配置值.测试框架实例化扩展模型并运行其方法之一.但是,首先它将config.xml文件复制到/etc/config.xml.想法是每次使用不同的config.xml实例化模型,以测试各种配置.该测试框架遍历了六个不同的config.xml文件.

I am writing a test framework for a Magento extension I'm building. The extension has a lot of configuration values stored in etc/config.xml under <global><default>. The test framework instantiates an extension model and runs one of its methods. However, first it copies a config.xml file to /etc/config.xml. The idea is that the model is instantiated with a different config.xml every time, to test various configurations. The test framework loops through half a dozen different config.xml files.

问题-即使我重新引导Magento,扩展模型总是都使用例程启动时存在的任何文件中的config.xml数据实例化.我可以看到etc/config.xml文件确实在每次迭代中都被更改,并且所做的更改在执行Mage::getConfig()->loadModulesConfiguration->getNode('default/module_name')时显示在全局配置中.就像扩展程序在每次运行时缓存其配置值一样.我正在通过PHP CLI执行测试文件.

The problem - even if I re-bootstrap Magento, the extension model always instantiates with the config.xml data from whatever file was present when the routine was started. I can see that the etc/config.xml file is indeed being changed on every iteration, and the changes show up in the global config when I do Mage::getConfig()->loadModulesConfiguration->getNode('default/module_name'). It's like the extension is caching its config values on a per-run basis. I'm executing the test file via PHP CLI.

有人对此有任何想法吗?我很困惑感谢您的阅读.

Does anyone have any ideas on this one? I'm stumped. Thanks for reading.

推荐答案

所以我想出了一种解决方法,但是我仍然不确定是什么导致了这种现象.在我正在测试的模型中

So I figured out a workaround, but I'm still not sure what's causing the behavior. In the model that I'm testing

$this->config = Mage::getStoreConfig('jd_premier/default');

在我重新初始化Magento并调用Mage :: getConfig-> reinit()之后,

返回相同(缓存的)配置数据.但是,

returns the same (cached?) config data after I re-init Magento and call Mage::getConfig->reinit(). However,

$this->config = Mage::getConfig()->loadModulesConfiguration('config.xml')
                ->getNode('default/jd_premier/default');

从最新版本的config.xml返回正确的数据.

returns the correct data from the newest version of config.xml.

不知道这是怎么回事,所以如果您能启发我,我很高兴接受它作为答案.

No idea what's going on here, so if you can enlighten me I'm glad to accept it as the answer.

这篇关于Magento扩展开发-测试多个config.xml文件-值是否被缓存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆