Merge remote-tracking branch 'origin/support/3.1' into develop

This commit is contained in:
acognet
2023-08-31 16:25:15 +02:00
9 changed files with 22 additions and 19 deletions

View File

@@ -344,6 +344,7 @@ class AttachmentPlugIn implements iApplicationUIExtension, iApplicationObjectExt
while ($oAttachment = $oSet->Fetch())
{
$oTempAttachment = clone $oAttachment;
$oTempAttachment->Set('expire', time() + utils::GetConfig()->Get('draft_attachments_lifetime'));
$oTempAttachment->Set('item_id', null);
$oTempAttachment->Set('temp_id', $sTempId);
$oTempAttachment->DBInsert();

View File

@@ -733,6 +733,7 @@ class AjaxRenderController
} else {
$oFullSetFilter = new DBObjectSearch($sRemoteClass);
}
$oFullSetFilter->SetShowObsoleteData(utils::ShowObsoleteData());
$oWidget->DoAddObjects($oPage, $iMaxAddedId, $oFullSetFilter, $oObj);
$oKPI->ComputeAndReport('Data write');
}

View File

@@ -87,6 +87,10 @@ Add annotation `@runInSeparateProcess`
Each and every test case will run in a separate
process.
Note : before N°6658 (3.0.4 / 3.1.1 / 3.2.0) we were also adding the `@backupGlobals disabled`
and `@preserveGlobalState disabled` annotations. This is no longer necessary as the first has this default value
already, and the second one is now set in iTopTestCase as a PHP class attribute.
#### At the test class level
Add annotation `@runTestsInSeparateProcesses`
Each and every test case in the class will run in a separate

View File

@@ -16,9 +16,7 @@ namespace Combodo\iTop\Test\UnitTest;
use ArchivedObjectException;
use CMDBObject;
use CMDBSource;
use Combodo\iTop\Service\Events\EventData;
use Combodo\iTop\Service\Events\EventService;
use Config;
use Contact;
use DBObject;
use DBObjectSet;
@@ -34,7 +32,6 @@ use MetaModel;
use Person;
use PluginManager;
use Server;
use SetupUtils;
use TagSetFieldData;
use Ticket;
use URP_UserProfile;
@@ -57,6 +54,7 @@ define('TAG_ATTCODE', 'domains');
*
* @since 2.7.7 3.0.1 3.1.0 N°4624 processIsolation is disabled by default and must be enabled in each test needing it (basically all tests using
* iTop datamodel)
* @since 3.0.4 3.1.1 3.2.0 N°6658 move some setUp/tearDown code to the corresponding methods *BeforeClass to speed up tests process time.
*/
abstract class ItopDataTestCase extends ItopTestCase
{
@@ -950,6 +948,9 @@ abstract class ItopDataTestCase extends ItopTestCase
}
}
/**
* @since 3.0.4 3.1.1 3.2.0 N°6658 method creation
*/
protected function assertDBChangeOpCount(string $sClass, $iId, int $iExpectedCount)
{
$oSearch = new \DBObjectSearch('CMDBChangeOp');

View File

@@ -12,12 +12,9 @@ use PHPUnit\Framework\TestCase;
use SetupUtils;
/**
* Class ItopTestCase
*
* Helper class to extend for tests that DO NOT need to access the DataModel or the Database
*
* @author Eric Espie <eric.espie@combodo.com>
* @package Combodo\iTop\Test\UnitTest
* @since 3.0.4 3.1.1 3.2.0 N°6658 move some setUp/tearDown code to the corresponding methods *BeforeClass to speed up tests process time.
*/
abstract class ItopTestCase extends TestCase
{
@@ -25,7 +22,10 @@ abstract class ItopTestCase extends TestCase
public static $DEBUG_UNIT_TEST = false;
/**
* Override the default value to disable the backup of globals in case of tests run in a separate process
* @link https://docs.phpunit.de/en/9.6/annotations.html#preserveglobalstate PHPUnit `preserveGlobalState` annotation documentation
*
* @since 3.0.4 3.1.1 3.2.0 N°6658 Override default value creation so that we don't need to add the annotation on each test classes that have runInSeparateProcess.
* This parameter isn't used when test is run in the same process so ok to change it globally !
*/
protected $preserveGlobalState = false;
@@ -76,7 +76,9 @@ abstract class ItopTestCase extends TestCase
/**
* @throws \MySQLTransactionNotClosedException see N°5538
*
* @since 2.7.8 3.0.3 3.1.0 N°5538
* @since 3.0.4 3.1.1 3.2.0 N°6658 if transaction not closed, we are now doing a rollback
*/
protected function tearDown(): void
{
@@ -92,7 +94,11 @@ abstract class ItopTestCase extends TestCase
}
}
/** Helper than can be called in the context of a data provider */
/**
* Helper than can be called in the context of a data provider
*
* @since 3.0.4 3.1.1 3.2.0 N°6658 method creation
*/
public static function GetAppRoot()
{
if (defined('APPROOT')) {

View File

@@ -6,8 +6,6 @@
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class ApplicationObjectExtensionTest extends \Combodo\iTop\Test\UnitTest\ItopDataTestCase
{

View File

@@ -6,17 +6,13 @@
namespace Combodo\iTop\Test\UnitTest\Core;
use MockValueSetObjects;
use Combodo\iTop\Test\UnitTest\ItopTestCase;
use MetaModel;
use ValueSetDefinition;
use ValueSetEnum;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class ValueSetDefinitionTest extends ItopTestCase
{

View File

@@ -14,8 +14,6 @@ use Combodo\iTop\Test\UnitTest\ItopDataTestCase;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class TemporaryObjectManagerTest extends ItopDataTestCase
{

View File

@@ -15,8 +15,6 @@ use DBObject;
/**
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
* @backupGlobals disabled
*/
class TemporaryObjectRepositoryTest extends ItopDataTestCase
{