Skip to content

Commit b88ed46

Browse files
authored
[11.x] adding tests for null & * key given in data_get (#54059)
* test(data-get): add tests for `null` key given * test(data-get): add coverage for simple `*` with both array and `Collection` * style(data-get-tests): remove extra spaces
1 parent bb89cc5 commit b88ed46

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/Support/SupportHelpersTest.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,27 @@ public function testDataGetEscapedSegmentKeys()
411411
$this->assertEquals('caret', data_get($array, 'symbols.{last}.description'));
412412
}
413413

414+
public function testDataGetStar()
415+
{
416+
$data = ['foo' => 'bar'];
417+
$this->assertEquals(['bar'], data_get($data, '*'));
418+
419+
$data = collect(['foo' => 'bar']);
420+
$this->assertEquals(['bar'], data_get($data, '*'));
421+
}
422+
423+
public function testDataGetNullKey()
424+
{
425+
$data = ['foo' => 'bar'];
426+
427+
$this->assertEquals(['foo' => 'bar'], data_get($data, null));
428+
$this->assertEquals(['foo' => 'bar'], data_get($data, null, '42'));
429+
$this->assertEquals(['foo' => 'bar'], data_get($data, [null]));
430+
431+
$data = ['foo' => 'bar', 'baz' => 42];
432+
$this->assertEquals(['foo' => 'bar', 'baz' => 42], data_get($data, [null, 'foo']));
433+
}
434+
414435
public function testDataFill()
415436
{
416437
$data = ['foo' => 'bar'];

0 commit comments

Comments
 (0)