I set up unit tests for Magento using EcomDev PHPUnit. I was able to make almost everything working properly. The only thing which I haven't figured out is how to use fixtures in multiple database setup.

There are two database resources set in local.xml:

  • default_setup used by the whole codebase as default connection
  • my_extension used by one custom extension, declared in module config.xml

Then I have following fixtures in default.yaml file:

    user: &user
        id: 1
        login: john
        password: foo
        email: [email protected]
        customer_id: 1
        firstname: John
        lastname: Doe
        customer_id: 1

        <<: *user
        id: 1

        <<: *eav_customer
        entity_id: 1
        firstname: John
        lastname: Smith
        email: [email protected]

I would like to have eav/customer fixture added using default_setup resource and my_extension/user fixture added using my_extension resource.

As far as I see in EcomDev_PHPUnit_Model_Fixture_Processor_Tables, it always uses default resource.

For now I just configured test Magento environment to have both resources using the same database.

Do you know any elegant way to make fixtures working with different resources?

1 Answer 1


Good question but looking back at the projects I have used Ecom_Dev on I don't think that this is possible. By having the data split out as well it would look more like you are testing the infrastructure. E.g. Another DB connection can write / read.

When using unit testing and Ecom_Dev where the data is stored should not really make much of a difference, This could be covered at a higher level to ensure it works..

  • Thanks James, it makes sense. It looks it's not supported, however using one database for testing purposes is enough there. Commented Feb 13, 2015 at 20:59

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.