SupportTest.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. // Copyright 2022 Hackware SpA <human@hackware.cl>
  3. // "Hackware Web Services Core" is released under the MIT License terms.
  4. namespace Hawese\Tests;
  5. use Hawese\Core\Support\Arr;
  6. class SupportTest extends TestCase
  7. {
  8. public function testArrKeyExistsCaseInsensitive()
  9. {
  10. $arr = ['a' => 'a', 'b' => 'b', 'c' => 'c'];
  11. $this->assertFalse(Arr::keyExists($arr, 'd'));
  12. $this->assertTrue(Arr::keyExists($arr, 'B'));
  13. $this->assertTrue(Arr::keyExists($arr, 'b'));
  14. }
  15. public function testArrKeyExistsCaseSensitive()
  16. {
  17. $arr = ['a' => 'a', 'b' => 'b', 'c' => 'c'];
  18. $this->assertFalse(Arr::keyExists($arr, 'd', false));
  19. $this->assertFalse(Arr::keyExists($arr, 'B', false));
  20. $this->assertTrue(Arr::keyExists($arr, 'b', false));
  21. }
  22. public function testArrGetCaseInsensitive()
  23. {
  24. $arr = ['a' => 'a', 'b' => 'b', 'c' => 'c'];
  25. $this->assertNull(Arr::get($arr, 'd'));
  26. $this->assertSame('b', Arr::get($arr, 'B'));
  27. $this->assertSame('b', Arr::get($arr, 'b'));
  28. }
  29. public function testArrExistsCaseSensitive()
  30. {
  31. $arr = ['a' => 'a', 'b' => 'b', 'c' => 'c'];
  32. $this->assertNull(Arr::get($arr, 'd', false));
  33. $this->assertNull(Arr::get($arr, 'B', false));
  34. $this->assertSame('b', Arr::get($arr, 'b', false));
  35. }
  36. }