2

I am dropping the test database before invoking phpunit in Ecomdev_PHPUnit.

It creates the database and it's not importing user attributes from eav_attribute.

Is it safe to just clone the real database to a test one ? I can't find the code responsible for attribute loading in Ecomdev's.

Thank you.

1 Answer 1

5

The reason your custom attribute is not imported may be that you didn't write an upgrade script creating the attribute. EcomDev_PHPUnit doesn't copy the database but runs the normal Magento scripts.

When PHPUnit is started the EcomDev extensions kicks in with EcomDev_PHPUnit_Test_Listener::startTestSuite(). This method invokes EcomDev_PHPUnit_Model_App::applyTestScope() and this one calls EcomDev_PHPUnit_Model_App::initTest().

EcomDev_PHPUnit_Model_App::initTest() launches the normal install/upgrade script process by executing Mage_Core_Model_App::_initModules().

This means you can either

  1. write upgrade scripts for attributes,
  2. use fixtures or
  3. copy the database.

As far as I know (I'm still new to EcomDev_PHPUnit myself) your options for EAV attributes are number 1 and 3.

I didn't try copying the database yet but it should work. I'd go with option 1. Writing upgrade scripts for attribute sets, groups and attributes can be much work but it is a best practice and there is a high probability it will pay off in multiple ways (less manual setup for other projects / working copies, better transparency, ...). This nifty script by Alan Storm may be of help.

1
  • Thanks for your post. I ended up cloning the database, and rewrote the store from scratch for 1.9 this time using the UI for attributes. The link with script seems good, I'll keep that.
    – Niloct
    Commented Jul 1, 2014 at 12:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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