From c8810708efd35f0b331f446f6212cf166ed8322c Mon Sep 17 00:00:00 2001 From: vdumas Date: Wed, 28 Feb 2024 12:52:08 +0100 Subject: [PATCH 1/2] =?UTF-8?q?N=C2=B07268=20-=20Add=20test=20on=20method?= =?UTF-8?q?=20SetComputedDate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unitary-tests/core/DBObjectTest.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/php-unit-tests/unitary-tests/core/DBObjectTest.php b/tests/php-unit-tests/unitary-tests/core/DBObjectTest.php index 321610d78b..94111d6eb4 100644 --- a/tests/php-unit-tests/unitary-tests/core/DBObjectTest.php +++ b/tests/php-unit-tests/unitary-tests/core/DBObjectTest.php @@ -1356,4 +1356,27 @@ class DBObjectTest extends ItopDataTestCase $oOrganisation->SetTrim('name', $sName); $this->assertEquals($sResult, $oOrganisation->Get('name'), 'SetTrim must limit string to 255 characters'); } + + /** + * @covers DBObject::SetComputedDate + * @return void + */ + public function testSetComputedDateOnAttributeDate(){ + $oObject = MetaModel::NewObject(\CustomerContract::class, ['name'=>'Test contract','org_id'=>'3','provider_id'=>'2']); + $oObject->Set('start_date',time()); + $oObject->SetComputedDate('end_date', "+2 weeks", 'start_date'); + $this->assertTrue(true,'No fatal error on computing date'); + } + /** + * @covers DBObject::SetComputedDate + * @return void + */ + public function testSetComputedDateOnAttributeDateTime(){ + $oObject = MetaModel::NewObject(\WorkOrder::class, ['name'=>'Test workorder','description'=>'Toto']); + $oObject->Set('start_date','2024-01-01 09:45:00'); + $oObject->SetComputedDate('end_date', "+2 weeks", 'start_date'); + $this->assertTrue(true,'No fatal error on computing date'); + $this->assertEquals("2024-01-15 09:45:00", $oObject->Get('end_date'), 'SetComputedDate +2 weeks on a WorkOrder DateTimeAttribute'); + + } } From fbe7f559d21698ec5f1281a2e107140bff485dfc Mon Sep 17 00:00:00 2001 From: Pierre Goiffon Date: Wed, 28 Feb 2024 15:10:06 +0100 Subject: [PATCH 2/2] =?UTF-8?q?N=C2=B07251=20Remove=20usages=20of=20deprec?= =?UTF-8?q?ated=20JS=20libs=20Only=20js/json.js=20was=20used,=20but=20it?= =?UTF-8?q?=20is=20a=20polyfill=20that=20is=20not=20necessary=20anymore=20?= =?UTF-8?q?considering=20our=20browser=20requirements=20(see=20https://www?= =?UTF-8?q?.itophub.io/wiki/page=3Fid=3Dlatest:install:requirements#web=5F?= =?UTF-8?q?browser)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/UniversalSearch.php | 1 - pages/tagadmin.php | 1 - sources/Controller/Base/Layout/ObjectController.php | 1 - 3 files changed, 3 deletions(-) diff --git a/pages/UniversalSearch.php b/pages/UniversalSearch.php index 75ae8f9062..4c8dc4585a 100644 --- a/pages/UniversalSearch.php +++ b/pages/UniversalSearch.php @@ -33,7 +33,6 @@ ApplicationMenu::CheckMenuIdEnabled('UniversalSearchMenu'); $oAppContext = new ApplicationContext(); $oP = new iTopWebPage(Dict::S('UI:UniversalSearchTitle')); -$oP->add_linked_script("../js/json.js"); $oP->add_linked_script("../js/forms-json-utils.js"); $oP->add_linked_script("../js/wizardhelper.js"); $oP->add_linked_script("../js/wizard.utils.js"); diff --git a/pages/tagadmin.php b/pages/tagadmin.php index b9f6b4987a..9f0aa8c4bf 100644 --- a/pages/tagadmin.php +++ b/pages/tagadmin.php @@ -37,7 +37,6 @@ try // Main program // $oP = new iTopWebPage(Dict::S('Menu:TagAdminMenu+')); - $oP->add_linked_script("../js/json.js"); $oP->add_linked_script("../js/forms-json-utils.js"); $oP->add_linked_script("../js/wizardhelper.js"); $oP->add_linked_script("../js/wizard.utils.js"); diff --git a/sources/Controller/Base/Layout/ObjectController.php b/sources/Controller/Base/Layout/ObjectController.php index 78c93cb7a0..c8c557b549 100644 --- a/sources/Controller/Base/Layout/ObjectController.php +++ b/sources/Controller/Base/Layout/ObjectController.php @@ -781,7 +781,6 @@ JS; public static function EnumRequiredForModificationJsFilesRelPaths(): array { return [ - 'js/json.js', 'js/forms-json-utils.js', 'js/wizardhelper.js', 'js/wizard.utils.js',