From 28d416a00d7ae01d4b562d00fb5ec3dde2a64200 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 23 Jun 2021 00:58:27 +0200 Subject: [PATCH] Try fix of phpunit --- .travis.yml | 3 ++- .../template/test/phpunit/MyObjectTest.php | 9 ++++++++- test/phpunit/HolidayTest.php | 2 +- test/phpunit/KnowledgeRecordTest.php | 15 ++++++++++++--- test/phpunit/ProjectTest.php | 2 +- 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 1ee46ea483f..75c688e735d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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_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_KNOWLEDGEMANAGEMENT,MAIN_MODULE_EVENTORGANIZATION,MAIN_MODULE_PARTNERSHIP >> $TRAVIS_BUILD_DIR/enablemodule.log echo $? cd - set +e @@ -429,7 +430,7 @@ script: - | echo "Unit testing" # 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 phpunitresult=$? echo "Phpunit return code = $phpunitresult" diff --git a/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php b/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php index 9301737d5f5..5de2ca29b83 100644 --- a/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php +++ b/htdocs/modulebuilder/template/test/phpunit/MyObjectTest.php @@ -40,7 +40,10 @@ $langs->load("main"); /** * 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 { @@ -73,6 +76,7 @@ class MyObjectTest extends \PHPUnit_Framework_TestCase /** * Global test setup + * * @return void */ public static function setUpBeforeClass() @@ -85,6 +89,7 @@ class MyObjectTest extends \PHPUnit_Framework_TestCase /** * Unit test setup + * * @return void */ protected function setUp() @@ -100,6 +105,7 @@ class MyObjectTest extends \PHPUnit_Framework_TestCase /** * Unit test teardown + * * @return void */ protected function tearDown() @@ -109,6 +115,7 @@ class MyObjectTest extends \PHPUnit_Framework_TestCase /** * Global test teardown + * * @return void */ public static function tearDownAfterClass() diff --git a/test/phpunit/HolidayTest.php b/test/phpunit/HolidayTest.php index bba5d68c41e..418b81f8b41 100644 --- a/test/phpunit/HolidayTest.php +++ b/test/phpunit/HolidayTest.php @@ -36,7 +36,7 @@ if (empty($user->id)) { $user->getrights(); } -$conf->global->MAIN_DISABLE_ALL_MAILS=1; +$conf->global->MAIN_DISABLE_ALL_MAILS = 1; /** diff --git a/test/phpunit/KnowledgeRecordTest.php b/test/phpunit/KnowledgeRecordTest.php index 0122d8a8e6b..a1d2c0a854b 100644 --- a/test/phpunit/KnowledgeRecordTest.php +++ b/test/phpunit/KnowledgeRecordTest.php @@ -27,22 +27,27 @@ global $conf, $user, $langs, $db; //require_once 'PHPUnit/Autoload.php'; require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; require_once dirname(__FILE__).'/../../htdocs/knowledgemanagement/class/knowledgerecord.class.php'; +$langs->load("main"); if (empty($user->id)) { print "Load permissions for admin user nb 1\n"; $user->fetch(1); $user->getrights(); } + $conf->global->MAIN_DISABLE_ALL_MAILS = 1; -$langs->load("main"); + /** * 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 $savuser; @@ -73,6 +78,7 @@ class KnowledgeRecordTest extends \PHPUnit\Framework\TestCase /** * Global test setup + * * @return void */ public static function setUpBeforeClass() @@ -87,6 +93,7 @@ class KnowledgeRecordTest extends \PHPUnit\Framework\TestCase /** * Unit test setup + * * @return void */ protected function setUp() @@ -102,6 +109,7 @@ class KnowledgeRecordTest extends \PHPUnit\Framework\TestCase /** * Unit test teardown + * * @return void */ protected function tearDown() @@ -111,6 +119,7 @@ class KnowledgeRecordTest extends \PHPUnit\Framework\TestCase /** * Global test teardown + * * @return void */ public static function tearDownAfterClass() diff --git a/test/phpunit/ProjectTest.php b/test/phpunit/ProjectTest.php index d9f76f26635..7aa73181436 100644 --- a/test/phpunit/ProjectTest.php +++ b/test/phpunit/ProjectTest.php @@ -198,7 +198,7 @@ class ProjectTest extends PHPUnit\Framework\TestCase } /** - * testProjectClose + * testProjectOther * * @param Project $localobject Project * @return int