Magento: Tips and tricks how to test Unirgy Dropship module with EcomDev PHPUnit

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone

A couple of months ago I had a really interesting and very importatnt task. I had to code an automated process that creates Unirgy_DropshipPo purchase orders (Unirgy_DropshipPo_Model_Po objects). Because the task had a very high business value and everything had to work flawlessly, I decided to invest more energy and time in order to write a good test coverage with phpunit. I also knew that I needed tests because there was a big chance my code would be modified in the following weeks because of the business dynamics. I decided to “step” on something that I already knew how to utilise – EcomDev_PHPUnit ( Thank you Ivan Chepurnyi ).

Initially, my idea was to use EcomDev_PHPUnit only as a unit-testing tool and to test functions in isolation, but at a later stage of the development I found out that it would be even better if I used EcomDev_PHPUnit to test different branches of my algorithm.

During the development phase I had 3 main technical challenges:

  1. Unknown / Unexpected behaviour of Unirgy Dropship
  2. Collecting fixtures data in order to simulate test cases close to production environment
  3. Querying the database in order to prove that entities have been modified or created (Purchase order, credit memos and etc.)

Continue reading “Magento: Tips and tricks how to test Unirgy Dropship module with EcomDev PHPUnit”

Tweet about this on TwitterShare on LinkedInShare on Google+Share on FacebookEmail this to someone