Skip to content

Commit

Permalink
[11.x] adding tests for null & * key given in data_get (#54059)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jwjenkin authored Jan 2, 2025
1 parent bb89cc5 commit b88ed46
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/Support/SupportHelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,27 @@ public function testDataGetEscapedSegmentKeys()
$this->assertEquals('caret', data_get($array, 'symbols.{last}.description'));
}

public function testDataGetStar()
{
$data = ['foo' => 'bar'];
$this->assertEquals(['bar'], data_get($data, '*'));

$data = collect(['foo' => 'bar']);
$this->assertEquals(['bar'], data_get($data, '*'));
}

public function testDataGetNullKey()
{
$data = ['foo' => 'bar'];

$this->assertEquals(['foo' => 'bar'], data_get($data, null));
$this->assertEquals(['foo' => 'bar'], data_get($data, null, '42'));
$this->assertEquals(['foo' => 'bar'], data_get($data, [null]));

$data = ['foo' => 'bar', 'baz' => 42];
$this->assertEquals(['foo' => 'bar', 'baz' => 42], data_get($data, [null, 'foo']));
}

public function testDataFill()
{
$data = ['foo' => 'bar'];
Expand Down

0 comments on commit b88ed46

Please sign in to comment.