This commit is contained in:
Yuri Kuznetsov
2025-07-21 16:09:27 +03:00
parent c1a23a9d49
commit b668f54a68
+35 -4
View File
@@ -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('{