douang1243 2015-02-26 04:32
浏览 69

Magento扩展开发 - 测试多个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.

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.

  • 写回答

1条回答 默认 最新

  • dongtu1789 2015-02-26 22:26
    关注

    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');
    

    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');
    

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题