File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed
Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments