Arrays.normalize.phpt 507 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. /**
  3. * Test: Nette\Utils\Arrays::searchKey()
  4. */
  5. declare(strict_types=1);
  6. use Nette\Utils\Arrays;
  7. use Tester\Assert;
  8. require __DIR__ . '/../bootstrap.php';
  9. Assert::same(
  10. [
  11. 'first' => null,
  12. 'a' => 'second',
  13. 'd' => ['third'],
  14. 'fourth' => null,
  15. ],
  16. Arrays::normalize([
  17. 1 => 'first',
  18. 'a' => 'second',
  19. 'd' => ['third'],
  20. 7 => 'fourth',
  21. ]),
  22. );
  23. Assert::same(
  24. [
  25. 'first' => true,
  26. '' => 'second',
  27. ],
  28. Arrays::normalize([
  29. 1 => 'first',
  30. '' => 'second',
  31. ], filling: true),
  32. );