I writing a Magento plugin and try to test it with the PHPUnit Testing Integration from http://www.ecomdev.org. Right now I’m trying to test a method which two different sets of config settings but for some reason the second one is never loaded and the first is used again, so the tests which expects the second fixture fails.
Here’s the problem reduced to the important lines:
Modul.php (Model)
<?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 (Test)
<?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();
}
}
?>
Unfortunately the second tests fails, no matter in which order they are performed. Actually the ecomdev test suite should discard the fixtures (I had a look at tearDown() in case.php) but the config data is still there and can’t be overwritten. Is there a workaround or is this a problem with Magento / the test suite?
have you tried the latest version from github? We saw some issues related to config with the new Magento version, so in dev branch it was fixed.
Here is branch url:
https://github.com/IvanChepurnyi/EcomDev_PHPUnit/tree/dev