Imagine, that you creating new module (for example) and you have only your module files without magento core files.

  • How do you run unit tests?
  • What is the best build-process to run tests on this module?

I suppose that you have docker containers with different magento versions and build script that installs your module and executes tests.

Is there any other way to do it?

1 Answer 1


When I write a module, it is always self contained, without Magento core files. During a module development phase, I use composer to install Magento together with other possible dependencies (other modules, phpunit, test tools)

But when I create a build matrix for CI tool, I use mage-ci tools script, that allows to install magento specific version. On top of that I install testing dependencies with composer.

You can check this module as an example: https://github.com/EcomDev/EcomDev_Fixture/tree/develop

example of its build file:

  - MAGE_DIR=build
  # Change composer Magento version
  - cp .travis/composer.json composer.json
  # Install mage-ci
  - source <(curl -s https://raw.githubusercontent.com/EcomDev/MageCI/master/installer)
  # Installing magento version with prepared DB dump
  - bin/mage-ci install $MAGE_DIR $MAGE magento -c
  # Installing dependencies
  - composer install
  # Installing your actual extension module
  - bin/mage-ci install-module $MAGE_DIR $(pwd)
  # Configuring EcomDev_PHPUnit module
  - bin/mage-ci shell $MAGE_DIR ecomdev-phpunit.php -a install
  - bin/mage-ci shell $MAGE_DIR ecomdev-phpunit.php -a magento-config --db-name magento --same-db 1 --base-url http://test.magento.com/
  - bin/mage-ci shell $MAGE_DIR ecomdev-phpunit.php -a change-status

For building an extension I use simplified composer file, without Magento. For development, I use another version, that bundles Magento.

$MAGE environment variable contains version of Magento that is needed to be installed on CI server, $MAGE_DIR is a location where to install it and where to install related modules.

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.