title: test php functions (not classes) with netbeans and PHPUnit
body: <p>I'd like to run unit test for a functions library file...</p>
  
  <p>that is, I don't have a class, it's just a file with helper functions in it...</p>
  
  <p>for example, I've created a php project at ~/www/test</p>
  
  <p>and a file ~/www/test/lib/format.php</p>
  
  <pre><code>&lt;?php
  
  function toUpper( $text ) {
    return strtoupper( $text );
  }
  
  function toLower( $text ) {
    return strtolower( $text );
  }
  
  function toProper( $text ) {
    return toUpper( substr( $text, 0, 1 ) ) .  toLower( substr( $text, 1) );
  }
  ?&gt;
  </code></pre>
  
  <p>tools -> create PHPUnit tests gives me the following error:</p>
  
  <blockquote>
    <p>PHPUnit 3.4.5 by Sebastian Bergmann.</p>
    
    <p>Could not find class "format" in
    "/home/sas/www/test/lib/format.php".</p>
  </blockquote>
  
  <p>now, if I code (by hand!) the file
  ~/www/test/tests/lib/FormatTest.php</p>
  
  <pre><code>&lt;?php
  require_once 'PHPUnit/Framework.php';
  require_once dirname(__FILE__).'/../../lib/format.php';
  
  class FormatTest extends PHPUnit_Framework_TestCase {
  
    protected function setUp() {}
  
    protected function tearDown() {}
  
    public function testToProper() {
      $this-&gt;assertEquals(
              'Sebastian',
              toProper( 'sebastian' )
      );
    }
  }
  ?&gt;
  </code></pre>
  
  <p>it works fine, I can run it...</p>
  
  <p>but if I select test file from format.php i get</p>
  
  <blockquote>
    <p>Test file for the selected source file
    was not found</p>
  </blockquote>
  
  <p>any idea?</p>
  
  <p>saludos</p>
  
  <p>sas</p>
  
  <p>ps: another question, is there a way to update generated tests without having to manually delete them???</p>
  
  <p>ps2: using netbeans 2.8 dev</p>