我编写了一个Magento插件,并尝试使用http://www.ecomdev.org中的PHPUnit测试集成进行测试。现在我正在尝试测试一个方法,它有两组不同的配置设置,但由于某种原因第二个从未加载,第一个再次使用,所以需要第二个灯具的测试失败。
问题在于重要的问题:
Modul.php (型号)
<?php
class MyModule_Module_Model_TestModel extends Mage_Payment_Model_Method_Abstract {
protected $sandbox;
public function __construct() {
$this->sandbox = $this->getConfigData('sandbox');
}
public function getSandboxSetting() {
return $this->sandbox;
}
}
?>
fixture config.yaml
config
default/payment/modul/sandbox: 0
fixture configSB.yaml
config
default/payment/modul/sandbox: 1
Modul.php (测试)
<?php
class MyModule_Module_Test_Model_TestModel extends EcomDev_PHPUnit_Test_Case {
public function setUp() {
parent::setUp();
$this->object = Mage::getModel('module/testmodel');
}
/**
* @test
* @loadFixture config
*/
public function testCorrectShopSettingsWithoutSandbox() {
$this->assertEquals('0', $this->object->getSandboxSetting());
}
/**
* @test
* @loadFixture configSB
*/
public function testCorrectShopSettingsWithSandbox() {
$this->assertEquals('1', $this->object->getSandboxSetting());
}
protected function tearDown() {
unset($this->object);
parent::tearDown();
}
}
?>
不幸的是,无论执行顺序如何,第二次测试都会失败。实际上ecomdev测试套件应该丢弃灯具(我在case.php中查看了tearDown())但配置数据仍然存在且无法覆盖。是否存在解决方法,或者这是Magento /测试套件的问题?
答案 0 :(得分:1)
你试过github的最新版本吗?我们看到了一些与使用新Magento版本配置相关的问题,因此在开发分支中它已修复。
这是分支网址: https://github.com/IvanChepurnyi/EcomDev_PHPUnit/tree/dev