File tree Expand file tree Collapse file tree 1 file changed +60
-0
lines changed
Expand file tree Collapse file tree 1 file changed +60
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ declare (strict_types=1 );
4+
5+ namespace Jet \Tests \Unit \Actions ;
6+
7+ use Illuminate \Container \Container ;
8+ use Jet \JsonDiff \Actions \AddRemovalsToJsonDiffAction ;
9+ use Jet \JsonDiff \Actions \GetUnmappedOriginalIndexesAction ;
10+ use Jet \JsonDiff \JsonDiff ;
11+ use Jet \JsonDiff \ValueRemoved ;
12+ use Jet \Tests \Traits \InteractsWithContainer ;
13+ use PHPUnit \Framework \TestCase ;
14+
15+ class AddRemovalsToJsonDiffActionTest extends TestCase
16+ {
17+ use InteractsWithContainer;
18+
19+ public function test_it_adds_removals_to_a_json_diff (): void
20+ {
21+ $ originalArray = [
22+ 0 => 'mapped ' ,
23+ 1 => 'unmapped ' ,
24+ ];
25+
26+ $ this
27+ ->stub (GetUnmappedOriginalIndexesAction::class)
28+ ->method ('execute ' )
29+ ->willReturn (
30+ collect ([1 ])
31+ );
32+
33+ $ jsonDiff = new JsonDiff ([], []);
34+
35+ /** @var AddRemovalsToJsonDiffAction $action */
36+ $ action = Container::getInstance ()->make (AddRemovalsToJsonDiffAction::class);
37+
38+ $ action
39+ ->execute (
40+ collect (),
41+ $ originalArray ,
42+ $ jsonDiff ,
43+ ''
44+ );
45+
46+ $ this ->assertCount (1 , $ jsonDiff ->getValuesRemoved ());
47+
48+ /** @var ValueRemoved $valueRemoved */
49+ $ valueRemoved = $ jsonDiff ->getValuesRemoved ()->first ();
50+
51+ $ this ->assertSame (
52+ '1 ' ,
53+ $ valueRemoved ->getPath ()
54+ );
55+ $ this ->assertSame (
56+ 'unmapped ' ,
57+ $ valueRemoved ->getValue ()
58+ );
59+ }
60+ }
You can’t perform that action at this time.
0 commit comments