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 public function testUnsetRemoveEmpty(): void
{ {
$data = (object) [ $data = (object) [
'scopeNames' => [ 'scopeNames' => (object) [
'a' => 'test', 'a' => 'test',
'b' => 'test', 'b' => 'test',
], ],
'scopeNamesPlural' => [ 'scopeNamesPlural' => (object) [
'a' => 'test', 'a' => 'test',
'b' => 'test', 'b' => 'test',
], ],
@@ -145,11 +145,11 @@ class DataUtilTest extends \PHPUnit\Framework\TestCase
$this->assertEquals( $this->assertEquals(
(object) [ (object) [
'scopeNames' => [ 'scopeNames' => (object) [
'a' => 'test', 'a' => 'test',
'b' => 'test', 'b' => 'test',
], ],
'scopeNamesPlural' => [ 'scopeNamesPlural' => (object) [
'a' => 'test', 'a' => 'test',
'b' => '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() public function testUnsetByValue()
{ {
$data = json_decode('{ $data = json_decode('{