These are a few and easy steps.
- First you have to get your environment ready (for that read this post).
- Then go to Netbeans and open your Magento project.
- Right click on the index file and select the "Creat PHPUnit tests" option:
- It will ask you to select the tests folder, here you must create one, in this case "_unit_tests":

-Then the next message will appear but don't worry:

- Now you will see the "Test Files" folder.
- Create a test file inside the test folder:
- Complete the file with this example code:
<?php
require_once('../app/Mage.php');
class MyModelTest extends PHPUnit_Framework_TestCase {
public function setUp()
{
Mage::app('default');
$this --->myModel=Mage::getModel('sales/order');
}
public function testGetWebsiteId()
{
$type = $this->myModel->getResourceName();
$this->assertEquals('sales/order',$type);
}
}
?>
- And now you can run the test by doing right click on it and the select "Run" or pressign SHIFT + F6:

- You will see the result at the "Test Results" tag.
All done.
Add comment