Try fix of phpunit

This commit is contained in:
Laurent Destailleur 2021-06-23 00:58:27 +02:00
parent de7df8ad9f
commit 28d416a00d
5 changed files with 24 additions and 7 deletions

View File

@ -419,6 +419,7 @@ script:
php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_PRODUCTBATCH,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_STRIPE > $TRAVIS_BUILD_DIR/enablemodule.log php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_PRODUCTBATCH,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_STRIPE > $TRAVIS_BUILD_DIR/enablemodule.log
php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKET,MAIN_MODULE_ACCOUNTING,MAIN_MODULE_MRP >> $TRAVIS_BUILD_DIR/enablemodule.log php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKET,MAIN_MODULE_ACCOUNTING,MAIN_MODULE_MRP >> $TRAVIS_BUILD_DIR/enablemodule.log
php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_RECEPTION,MAIN_MODULE_RECRUITMENT >> $TRAVIS_BUILD_DIR/enablemodule.log php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_RECEPTION,MAIN_MODULE_RECRUITMENT >> $TRAVIS_BUILD_DIR/enablemodule.log
php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_KNOWLEDGEMANAGEMENT,MAIN_MODULE_EVENTORGANIZATION,MAIN_MODULE_PARTNERSHIP >> $TRAVIS_BUILD_DIR/enablemodule.log
echo $? echo $?
cd - cd -
set +e set +e
@ -429,7 +430,7 @@ script:
- | - |
echo "Unit testing" echo "Unit testing"
# Ensure we catch errors. Set this to +e if you want to go to the end to see dolibarr.log file. # Ensure we catch errors. Set this to +e if you want to go to the end to see dolibarr.log file.
set +e set -e
phpunit -d memory_limit=-1 -c test/phpunit/phpunittest.xml test/phpunit/AllTests.php phpunit -d memory_limit=-1 -c test/phpunit/phpunittest.xml test/phpunit/AllTests.php
phpunitresult=$? phpunitresult=$?
echo "Phpunit return code = $phpunitresult" echo "Phpunit return code = $phpunitresult"

View File

@ -40,7 +40,10 @@ $langs->load("main");
/** /**
* Class MyObjectTest * Class MyObjectTest
* @package Testmymodule *
* @backupGlobals disabled
* @backupStaticAttributes enabled
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
*/ */
class MyObjectTest extends \PHPUnit_Framework_TestCase class MyObjectTest extends \PHPUnit_Framework_TestCase
{ {
@ -73,6 +76,7 @@ class MyObjectTest extends \PHPUnit_Framework_TestCase
/** /**
* Global test setup * Global test setup
*
* @return void * @return void
*/ */
public static function setUpBeforeClass() public static function setUpBeforeClass()
@ -85,6 +89,7 @@ class MyObjectTest extends \PHPUnit_Framework_TestCase
/** /**
* Unit test setup * Unit test setup
*
* @return void * @return void
*/ */
protected function setUp() protected function setUp()
@ -100,6 +105,7 @@ class MyObjectTest extends \PHPUnit_Framework_TestCase
/** /**
* Unit test teardown * Unit test teardown
*
* @return void * @return void
*/ */
protected function tearDown() protected function tearDown()
@ -109,6 +115,7 @@ class MyObjectTest extends \PHPUnit_Framework_TestCase
/** /**
* Global test teardown * Global test teardown
*
* @return void * @return void
*/ */
public static function tearDownAfterClass() public static function tearDownAfterClass()

View File

@ -36,7 +36,7 @@ if (empty($user->id)) {
$user->getrights(); $user->getrights();
} }
$conf->global->MAIN_DISABLE_ALL_MAILS=1; $conf->global->MAIN_DISABLE_ALL_MAILS = 1;
/** /**

View File

@ -27,22 +27,27 @@ global $conf, $user, $langs, $db;
//require_once 'PHPUnit/Autoload.php'; //require_once 'PHPUnit/Autoload.php';
require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
require_once dirname(__FILE__).'/../../htdocs/knowledgemanagement/class/knowledgerecord.class.php'; require_once dirname(__FILE__).'/../../htdocs/knowledgemanagement/class/knowledgerecord.class.php';
$langs->load("main");
if (empty($user->id)) { if (empty($user->id)) {
print "Load permissions for admin user nb 1\n"; print "Load permissions for admin user nb 1\n";
$user->fetch(1); $user->fetch(1);
$user->getrights(); $user->getrights();
} }
$conf->global->MAIN_DISABLE_ALL_MAILS = 1; $conf->global->MAIN_DISABLE_ALL_MAILS = 1;
$langs->load("main");
/** /**
* Class KnowledgeRecordTest * Class KnowledgeRecordTest
* @package Testknowledgemanagement *
* @backupGlobals disabled
* @backupStaticAttributes enabled
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
*/ */
class KnowledgeRecordTest extends \PHPUnit\Framework\TestCase class KnowledgeRecordTest extends PHPUnit\Framework\TestCase
{ {
protected $savconf; protected $savconf;
protected $savuser; protected $savuser;
@ -73,6 +78,7 @@ class KnowledgeRecordTest extends \PHPUnit\Framework\TestCase
/** /**
* Global test setup * Global test setup
*
* @return void * @return void
*/ */
public static function setUpBeforeClass() public static function setUpBeforeClass()
@ -87,6 +93,7 @@ class KnowledgeRecordTest extends \PHPUnit\Framework\TestCase
/** /**
* Unit test setup * Unit test setup
*
* @return void * @return void
*/ */
protected function setUp() protected function setUp()
@ -102,6 +109,7 @@ class KnowledgeRecordTest extends \PHPUnit\Framework\TestCase
/** /**
* Unit test teardown * Unit test teardown
*
* @return void * @return void
*/ */
protected function tearDown() protected function tearDown()
@ -111,6 +119,7 @@ class KnowledgeRecordTest extends \PHPUnit\Framework\TestCase
/** /**
* Global test teardown * Global test teardown
*
* @return void * @return void
*/ */
public static function tearDownAfterClass() public static function tearDownAfterClass()

View File

@ -198,7 +198,7 @@ class ProjectTest extends PHPUnit\Framework\TestCase
} }
/** /**
* testProjectClose * testProjectOther
* *
* @param Project $localobject Project * @param Project $localobject Project
* @return int * @return int