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