Here is how to unitest within PhpDesigner. The following was done on a Windows 7 machine with PhpDesigner 7.2.

  1. Install WAMP server on your Windows machine. This is needed because the default PhpDesigner PHP engine cannot connect to databases (i.e. MySQL).
  • Just use the default installer setup and location
  • We’ll assume your WAMP is installed in c:\wamp
  1. Now point your PhpDesigner at the WAMP.
  • PhpDesigner > Tools > Preferences…
  • Set the Debugger to use the PHP Interpreter your c:\wamp\bin\php\php5.3.0\php-cgi.exe and the init file c:\WAMP\bin\php\php5.3.0\php.ini
  • Set the Syntax Checker to use the above values too
  • Set Run to use the above values too
  • Point your Localhost folder to the WAMP localhost c:\wamp\www\
  • Restart your PhpDesigner installation
  1. Now download and install the SimpleTest unittesting framework
  • Just download the files (1.0.1 recommended, I could not get 1.1 released 2 days ago to run)
  • Unzip the files to the location of your PHP project
  1. Create a helloworld test and run it from the comfort of PhpDesginer!

    <?php
    // hide warnings from  SimpleTest 1.0.1
    require_once(dirname(__FILE__).'/error_suppress.inc');
    // autorun this test<br />
    require_once(dirname(__FILE__).'/simpletest/autorun.php');
    // test all harvesters
    class TestOfHelloWorld extends UnitTestCase {
        function testHelloWorld()   {
            this->assertEqual( 4, 4, 'Numbers do not match');
        }
    }
    ?>
    
  • Note I’ve made a PHP file to hide Warnings from SimpleTest 1.0.1

Example: error_suppress.php

<?php
//Include this to override some common warnings when running SimpleTest in PhpDesigner
error_reporting(E_ALL &amp; ~E_DEPRECATED);// surpress dep errors - using old testing scripts
date_default_timezone_set('US/Eastern');       // suppress errors of unset timezone
?>
  • Click Run and look for the green lights!

If you are a Dreamhost user (like me)

  • For database unittests, you’ll need to open an external IP on your database
  • Login to panel.dreamhost.com for your account
  • Click Goodies >MySQL Databases [on left]
  • Click on the name of your database user [in “Users with Access” column]
  • Copy your local computer’s IP address to the list of allowed address and click “Modify”