test
This commit is contained in:
@@ -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('{
|
||||
|
||||
Reference in New Issue
Block a user