I'd like to run unit test for a functions library file...
that is, I don't have a class, it's just a file with helper functions in it...
for example, I've created a php project at ~/www/test
and a file ~/www/test/lib/format.php
<?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) );
}
?>
tools -> create PHPUnit tests gives me the following error:
PHPUnit 3.4.5 by Sebastian Bergmann.
Could not find class "format" in "/home/sas/www/test/lib/format.php".
now, if I code (by hand!) the file ~/www/test/tests/lib/FormatTest.php
<?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->assertEquals(
'Sebastian',
toProper( 'sebastian' )
);
}
}
?>
it works fine, I can run it...
but if I select test file from format.php i get
Test file for the selected source file was not found
any idea?
saludos
sas
ps: another question, is there a way to update generated tests without having to manually delete them???
ps2: using netbeans 2.8 dev