Latest Tweets

PHPUnit + Netbeans, integration with Magento

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:

step_01.jpg 

- It will ask you to select the tests folder, here you must create one, in this case "_unit_tests":

step_02.jpg

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

step_03.jpg

- Now you will see the "Test Files" folder.

- Create a test file inside the test folder:

step_04.jpg 

- 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:

step_05.jpg

- You will see the result at the "Test Results" tag.

All done.

Author

PHP Developer
Always giving my best.

Add comment

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.