<?php /** * Test: Nette\Schema\Helpers::merge() */ declare(strict_types=1); use Nette\Schema\Helpers; use Tester\Assert; require __DIR__ . '/../bootstrap.php'; $obj = new stdClass; $arr1 = ['a' => 'b', 'x']; $arr2 = ['c' => 'd', 'y']; $arr3 = [Helpers::PREVENT_MERGING => true, 'c' => 'd', 'y']; Assert::same(null, Helpers::merge(null, null)); Assert::same(null, Helpers::merge(null, 231)); Assert::same(null, Helpers::merge(null, $obj)); Assert::same([], Helpers::merge(null, [])); Assert::same($arr1, Helpers::merge(null, $arr1)); Assert::same(231, Helpers::merge(231, null)); Assert::same(231, Helpers::merge(231, 231)); Assert::same(231, Helpers::merge(231, $obj)); Assert::same(231, Helpers::merge(231, [])); Assert::same(231, Helpers::merge(231, $arr1)); Assert::same($obj, Helpers::merge($obj, null)); Assert::same($obj, Helpers::merge($obj, 231)); Assert::same($obj, Helpers::merge($obj, $obj)); Assert::same($obj, Helpers::merge($obj, [])); Assert::same($obj, Helpers::merge($obj, $arr1)); Assert::same([], Helpers::merge([], null)); Assert::same([], Helpers::merge([], 231)); Assert::same([], Helpers::merge([], $obj)); Assert::same([], Helpers::merge([], [])); Assert::same($arr1, Helpers::merge([], $arr1)); Assert::same($arr2, Helpers::merge($arr2, null)); Assert::same($arr2, Helpers::merge($arr2, 231)); Assert::same($arr2, Helpers::merge($arr2, $obj)); Assert::same($arr2, Helpers::merge($arr2, [])); Assert::same(['a' => 'b', 'x', 'c' => 'd', 'y'], Helpers::merge($arr2, $arr1)); Assert::same(['c' => 'd', 'y'], Helpers::merge($arr3, $arr1)); Assert::same(['inner' => ['c' => 'd', 'y']], Helpers::merge(['inner' => $arr3], ['inner' => $arr1])); Assert::same([['a' => 'b', 'x'], [Helpers::PREVENT_MERGING => true, 'c' => 'd', 'y']], Helpers::merge([$arr3], [$arr1])); Assert::same([Helpers::PREVENT_MERGING => true, 'c' => 'd', 'y', 'a' => 'b', 'x'], Helpers::merge($arr1, $arr3)); Assert::same([20 => 'b', 10 => 'a'], Helpers::merge([10 => 'a'], [20 => 'b'])); Assert::same(['b', 'a'], Helpers::merge(['a'], ['b']));
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
fixtures | Folder | 0755 |
|
|
Expect.anyOf.phpt | File | 8.17 KB | 0644 |
|
Expect.array.phpt | File | 8.14 KB | 0644 |
|
Expect.assert.phpt | File | 1.61 KB | 0644 |
|
Expect.before.phpt | File | 2.26 KB | 0644 |
|
Expect.castTo.phpt | File | 635 B | 0644 |
|
Expect.dynamic.phpt | File | 1.87 KB | 0644 |
|
Expect.from.php74.phpt | File | 906 B | 0644 |
|
Expect.from.php80.phpt | File | 951 B | 0644 |
|
Expect.from.phpt | File | 2.34 KB | 0644 |
|
Expect.list.phpt | File | 3.08 KB | 0644 |
|
Expect.minmax.phpt | File | 3.91 KB | 0644 |
|
Expect.pattern.phpt | File | 722 B | 0644 |
|
Expect.scalars.phpt | File | 2.46 KB | 0644 |
|
Expect.structure.phpt | File | 14.15 KB | 0644 |
|
Helpers.formatValue().phpt | File | 644 B | 0644 |
|
Helpers.getPropertyType.php74.phpt | File | 1.49 KB | 0644 |
|
Helpers.getPropertyType.phpt | File | 974 B | 0644 |
|
Helpers.merge.phpt | File | 2.05 KB | 0644 |
|
Helpers.parseAnnotation().phpt | File | 1.06 KB | 0644 |
|
Processor.context.phpt | File | 828 B | 0644 |
|
heterogenous.phpt | File | 1.34 KB | 0644 |
|