@@ -4,6 +4,7 @@ declare(strict_types=1);
44
55use Nette \Schema \Expect ;
66use Nette \Schema \Helpers ;
7+ use Nette \Schema \MergeMode ;
78use Nette \Schema \Processor ;
89use Tester \Assert ;
910
@@ -343,3 +344,34 @@ test('array shape', function () {
343344 (new Processor )->process ($ schema , []),
344345 );
345346});
347+
348+
349+ test ('merge modes ' , function () {
350+ $ schema = Expect::structure ([
351+ 'foo1 ' => Expect::array ()->mergeMode (MergeMode::Replace),
352+ 'foo2 ' => Expect::array ()->mergeMode (MergeMode::OverwriteKeys),
353+ 'foo3 ' => Expect::array ()->mergeMode (MergeMode::AppendKeys),
354+ ]);
355+
356+ $ processor = new Processor ;
357+
358+ Assert::equal (
359+ (object ) [
360+ 'foo1 ' => ['key ' => 'new ' ],
361+ 'foo2 ' => ['new ' , 'key ' => 'new ' ],
362+ 'foo3 ' => ['old ' , 'new ' , 'key ' => 'new ' ],
363+ ],
364+ $ processor ->processMultiple ($ schema , [
365+ [
366+ 'foo1 ' => ['old ' , 'key ' => '1 ' ],
367+ 'foo2 ' => ['old ' , 'key ' => '1 ' ],
368+ 'foo3 ' => ['old ' , 'key ' => '1 ' ],
369+ ],
370+ [
371+ 'foo1 ' => ['key ' => 'new ' ],
372+ 'foo2 ' => ['new ' , 'key ' => 'new ' ],
373+ 'foo3 ' => ['new ' , 'key ' => 'new ' ],
374+ ],
375+ ]),
376+ );
377+ });
0 commit comments