Improve PHPUNIT

This commit is contained in:
sparkyx 2022-09-16 15:03:08 +02:00
parent 68d41b82ca
commit 9de599e9bc
3 changed files with 18 additions and 9 deletions

View file

@ -32,7 +32,7 @@ use PHPUnit\Framework\TestCase;
* @backupGlobals enabled
* @coversDefaultClass \Follow_Up_Detail
*/
require DIRTEST.'/global.php';
class Follow_Up_DetailTest extends TestCase
{
@ -48,7 +48,11 @@ class Follow_Up_DetailTest extends TestCase
*/
protected function setUp():void
{
include 'global.php';
require DIRTEST.'/global.php';
global $g_connection;
$this->g_connection=$g_connection;
$this->assertNotNull($this->g_connection , "Database",'invalide ressource');
$this->assertEquals(get_class ($this->g_connection) , "Database",'invalide ressource');
}
/**
@ -62,12 +66,15 @@ class Follow_Up_DetailTest extends TestCase
/**
* the setUpBeforeClass():void template methods is called before the first test of the test case
* class is run
* class is run
* @backupGlobals enabled
*/
public static function setUpBeforeClass():void
{
global $g_connection;
$g_connection->exec_sql('delete from action_detail');
}
/**
@ -114,14 +121,16 @@ class Follow_Up_DetailTest extends TestCase
*/
public function testSQL_Update()
{
global $g_connection;
$obj=new Follow_Up_Detail($g_connection);
$obj=new Follow_Up_Detail($this->g_connection);
$this->insert($obj);
$this->assertTrue($obj->get_parameter("id")>0,"Cannot insert");
$obj->set_parameter('text','TEST UPDATE');
$obj->save();
$reload=new Follow_Up_Detail($g_connection,$obj->get_parameter("id"));
$reload=new Follow_Up_Detail($this->g_connection,$obj->get_parameter("id"));
$reload->load();
$this->assertTrue($reload->get_parameter("text") == $obj->get_parameter("text"),"cannot update");
$reload->delete();

View file

@ -54,7 +54,7 @@ fi
if [ ! -z "$FOLDERTEST" -a -d "$FOLDERTEST" ] ; then
$PHPINI $PHPUNIT --bootstrap bootstrap.php $COVERAGE --testdox --color $FOLDERTEST
$PHPINI $PHPUNIT --globals-backup --bootstrap bootstrap.php $COVERAGE --testdox --color $FOLDERTEST
exit $?
fi
@ -65,12 +65,12 @@ fi
if [ ! -z "$FUNCTION" ] ; then
echo "testing $FILETOTEST $FUNCTION"
$PHPINI $PHPUNIT --bootstrap $CUR_DIR/bootstrap.php --verbose --color --filter $FUNCTION $FILETOTEST
$PHPINI $PHPUNIT --bootstrap $CUR_DIR/bootstrap.php --globals-backup --verbose --color --filter $FUNCTION $FILETOTEST
else
# $PHPUNIT --bootstrap bootstrap.php --whitelist $FILETOTEST --coverage-text=${FILETOTEST%.php}.txt --color $FILETOTEST
# $PHPUNIT --bootstrap $CUR_DIR/bootstrap.php --whitelist=$CUR_DIR/../include/class --coverage-html=coverage --color $FILETOTEST
$PHPINI $PHPUNIT --bootstrap bootstrap.php $COVERAGE $FILETOTEST --testdox --color $FILETOTEST
#$PHPUNIT --bootstrap bootstrap.php --whitelist=../include --coverage-html=coverage $FILETOTEST --testdox-html ${FILETOTEST%.php}-testdox.html --color $FILETOTEST
#$PHPUNIT --bootstrap bootstrap.php --whitelist=../include --globals-backup --coverage-html=coverage $FILETOTEST --testdox-html ${FILETOTEST%.php}-testdox.html --color $FILETOTEST
fi