6

I am writing unit tests using the EcomDev PHPUnit extension. When trying to provide values to the Mage::getStoreConfig() method using a fixture, I am not getting the value from my fixture, but the default value (from XML or from DB). The fixture file has been found (I know that, because it threw errors until it was named correctly and in the right folder) and is very simple (myMethod.yaml):

config:
  payment/mymodule/numdays: 5

However in my block test in the method myMethod():

/**
* @test
* @loadFixture
*/
public function myMethod() {
//...
    Mage::getStoreConfig('payment/mymodule/numdays'); // returns 14
//...
}

Also, the store config returns 14 when it is called in the block under test.

Did I misunderstand the way to use these config value fixtures? In the backend, all cache types are turned off.

1
  • 1
    You should use default/payment/mymodule/numdays for global value and stores/<store code>/payment/mymodule/numdays for particular store. See Mage_Core_Model_Store::getConfig() for explanation. Mar 4, 2013 at 21:14

1 Answer 1

5

I was able to fix it by putting "default" in front of the fixture value, so the yaml looks like this:

config:
  default/payment/mymodule/numdays: 5

Comments on whether I am supposed to add this prefix are very welcome.

2
  • If the mock is just a full xpath, wondering if stores/[store_code]/payment/mymodule/numdays would work.
    – benmarks
    Mar 4, 2013 at 21:31
  • As described in the Manual config: default/catalog/price/scope: 1 # Set price scope to website yes, you have to add the prefix. bit.ly/mR6uKc Mar 5, 2013 at 9:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.