FunctionsTest.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * For full copyright and license information, please see the LICENSE.txt
  8. * Redistributions of files must retain the above copyright notice
  9. *
  10. * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  11. * @link https://cakephp.org CakePHP(tm) Project
  12. * @since 3.0.0
  13. * @license https://opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace Cake\Test\TestCase\Core;
  16. use Cake\TestSuite\TestCase;
  17. /**
  18. * Test cases for functions in Core\functions.php
  19. */
  20. class FunctionsTest extends TestCase
  21. {
  22. /**
  23. * Test cases for env()
  24. */
  25. public function testEnv()
  26. {
  27. $_ENV['DOES_NOT_EXIST'] = null;
  28. $this->assertNull(env('DOES_NOT_EXIST'));
  29. $this->assertEquals('default', env('DOES_NOT_EXIST', 'default'));
  30. $_ENV['DOES_EXIST'] = 'some value';
  31. $this->assertEquals('some value', env('DOES_EXIST'));
  32. $this->assertEquals('some value', env('DOES_EXIST', 'default'));
  33. $_ENV['EMPTY_VALUE'] = '';
  34. $this->assertEquals('', env('EMPTY_VALUE'));
  35. $this->assertEquals('', env('EMPTY_VALUE', 'default'));
  36. $_ENV['ZERO'] = '0';
  37. $this->assertEquals('0', env('ZERO'));
  38. $this->assertEquals('0', env('ZERO', '1'));
  39. }
  40. }