Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/unit-testing/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Magento扩展开发-测试多个config.xml文件-缓存值?_Php_Unit Testing_Magento - Fatal编程技术网

Php Magento扩展开发-测试多个config.xml文件-缓存值?

Php Magento扩展开发-测试多个config.xml文件-缓存值?,php,unit-testing,magento,Php,Unit Testing,Magento,我正在为我正在构建的Magento扩展编写一个测试框架。扩展在下面的etc/config.xml中存储了很多配置值。测试框架实例化一个扩展模型并运行它的一个方法。但是,它首先将config.xml文件复制到/etc/config.xml。其思想是每次使用不同的config.xml实例化模型,以测试各种配置。测试框架循环使用六个不同的config.xml文件 问题是——即使我重新引导Magento,扩展模型也总是使用例程启动时存在的任何文件中的config.xml数据进行实例化。我可以看到etc/

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

问题是——即使我重新引导Magento,扩展模型也总是使用例程启动时存在的任何文件中的config.xml数据进行实例化。我可以看到etc/config.xml文件确实在每次迭代中都会发生更改,当我执行Mage::getConfig->loadmoduleconfiguration->getNode'default/module_name'时,这些更改会显示在全局配置中。这就像扩展在每次运行的基础上缓存其配置值一样。我正在通过PHPCLI执行测试文件


有人对此有什么想法吗?我被难住了。谢谢阅读。

所以我想出了一个解决办法,但我仍然不确定是什么导致了这种行为。在我正在测试的模型中

$this->config = Mage::getStoreConfig('jd_premier/default');
返回相同的缓存?重新初始化Magento并调用Mage::getConfig->reinit之后配置数据。但是,

$this->config = Mage::getConfig()->loadModulesConfiguration('config.xml')
                ->getNode('default/jd_premier/default');
从最新版本的config.xml返回正确的数据

不知道这里发生了什么,所以如果你能启发我,我很高兴接受这个答案