From b668f54a686ed2296e0b87f9e4d8cb45c1b7dcbe Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Mon, 21 Jul 2025 16:09:27 +0300 Subject: [PATCH] test --- tests/unit/Espo/Core/Utils/DataUtilTest.php | 39 ++++++++++++++++++--- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/tests/unit/Espo/Core/Utils/DataUtilTest.php b/tests/unit/Espo/Core/Utils/DataUtilTest.php index 97c70adcf5..1e6039461a 100644 --- a/tests/unit/Espo/Core/Utils/DataUtilTest.php +++ b/tests/unit/Espo/Core/Utils/DataUtilTest.php @@ -131,11 +131,11 @@ class DataUtilTest extends \PHPUnit\Framework\TestCase public function testUnsetRemoveEmpty(): void { $data = (object) [ - 'scopeNames' => [ + 'scopeNames' => (object) [ 'a' => 'test', 'b' => 'test', ], - 'scopeNamesPlural' => [ + 'scopeNamesPlural' => (object) [ 'a' => 'test', 'b' => 'test', ], @@ -145,11 +145,11 @@ class DataUtilTest extends \PHPUnit\Framework\TestCase $this->assertEquals( (object) [ - 'scopeNames' => [ + 'scopeNames' => (object) [ 'a' => 'test', 'b' => 'test', ], - 'scopeNamesPlural' => [ + 'scopeNamesPlural' => (object) [ 'a' => 'test', 'b' => 'test', ], @@ -158,6 +158,37 @@ class DataUtilTest extends \PHPUnit\Framework\TestCase ); } + public function testSetByPath(): void + { + $data = (object) [ + 'scopeNames' => (object) [ + 'a' => 'A', + 'b' => 'B', + ], + 'scopeNamesPlural' => (object) [ + 'a' => 'As', + 'b' => 'Bs', + ], + ]; + + DataUtil::setByPath($data, ['scopeNamesPlural', 'c'], 'Cs'); + + $this->assertEquals( + (object) [ + 'scopeNames' => (object) [ + 'a' => 'A', + 'b' => 'B', + ], + 'scopeNamesPlural' => (object) [ + 'a' => 'As', + 'b' => 'Bs', + 'c' => 'Cs', + ], + ], + $data + ); + } + public function testUnsetByValue() { $data = json_decode('{