Magento How-to: Testing Magento Modules
Heads up! This article was written over 16 years ago. While it may still be helpful, please verify any information, as my perspectives and practices may have evolved.
Iβm sure a lot of Magento developers would agree that testing your models when creating a Magento module can be a bit difficult.
During the development of Meanbeeβs Royalmail and Shipwire modules I have found the following script handy:
<?php | |
require_once '../../../../Mage.php'; | |
Varien_Profiler::enable(); | |
Mage::setIsDeveloperMode(true); | |
ini_set('display_errors', 1); | |
umask(0); | |
Mage::app(); | |
$obj = Mage::getModel('shipwire/api_inventorysynch'); | |
$obj->submitRequest(); |
I simply make a file, Test.php
, in my module folder, app/code/community/Meanbee/Shipwire
, for example, and then navigate to the file with my web browser, remembering to allow it through the .htaccess
(and switch it back again). I then have access to the entire Magento class hierarchy along with any site specific settings to which I can perform arbitrary commands.
(EDIT: Remember that you could enable the profiler, set the development environment and enable the error reporting by placing those lines in your /index.php
and feel the effects site wide.)