Skip to content

Commit 3363a36

Browse files
committed
- add unot test for extended() function
1 parent 7799d12 commit 3363a36

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Tests\Koded\Stdlib;
4+
5+
use Koded\Stdlib\ExtendedArguments;
6+
use PHPUnit\Framework\TestCase;
7+
use function Koded\Stdlib\extended;
8+
9+
class ExtendedArgumentsFunctionTest extends TestCase
10+
{
11+
public function test_extended_arguments_function()
12+
{
13+
$actual = [
14+
'foo.bar' => [1, 2, 3]
15+
];
16+
$expected = [
17+
'foo' => [
18+
'bar' => [1, 2, 3]
19+
]
20+
];
21+
22+
$data = extended($actual);
23+
$this->assertInstanceOf(ExtendedArguments::class, $data);
24+
$this->assertSame($expected, $data->toArray());
25+
26+
$this->assertSame(3, $data->get('foo.bar.2'));
27+
$this->assertSame(['foo.bar.2' => 3], $data->extract(['foo.bar.2']));
28+
29+
// mutate the value
30+
$data->foo = 'bar';
31+
$this->assertSame(['foo' => 'bar'], $data->toArray());
32+
}
33+
34+
}

0 commit comments

Comments
 (0)