Skip to content
Permalink
Browse files

Simplify tests for env() with defaults.

  • Loading branch information...
markstory committed Sep 22, 2015
1 parent 5fc4bc6 commit 4bc0f2d4c7c436937fc087e4576e06020c72df1c
Showing with 14 additions and 20 deletions.
  1. +11 −16 tests/TestCase/Core/FunctionsTest.php
  2. +3 −4 tests/TestCase/Network/RequestTest.php
@@ -27,24 +27,19 @@ class FunctionsTest extends TestCase
public function testEnv()
{
$_ENV['DOES_NOT_EXIST'] = null;
$actual = env('DOES_NOT_EXIST');
$this->assertNull($actual);
$actual = env('DOES_NOT_EXIST', 'default');
$this->assertEquals('default', $actual);
$this->assertNull(env('DOES_NOT_EXIST'));
$this->assertEquals('default', env('DOES_NOT_EXIST', 'default'));
$_ENV['DOES_EXIST'] = 'some value';
$actual = env('DOES_EXIST');
$this->assertEquals('some value', $actual);
$actual = env('DOES_EXIST', 'default');
$this->assertEquals('some value', $actual);
$this->assertEquals('some value', env('DOES_EXIST'));
$this->assertEquals('some value', env('DOES_EXIST', 'default'));
$_ENV['EMPTY_VALUE'] = '';
$actual = env('EMPTY_VALUE');
$this->assertEquals('', $actual);
$actuaal = env('EMPTY_VALUE', 'default');
$this->assertEquals('', $actual);
$this->assertEquals('', env('EMPTY_VALUE'));
$this->assertEquals('', env('EMPTY_VALUE', 'default'));
$_ENV['ZERO'] = '0';
$actual = env('ZERO');
$this->assertEquals('0', $actual);
$actual = env('ZERO', '1');
$this->assertEquals('0', $actual);
$this->assertEquals('0', env('ZERO'));
$this->assertEquals('0', env('ZERO', '1'));
}
}
@@ -507,22 +507,21 @@ public function testDefaultEnvValue()
$_ENV['DOES_NOT_EXIST'] = null;
$request = new Request();
$this->assertNull($request->env('DOES_NOT_EXIST'));
$request = new Request();
$this->assertEquals('default', $request->env('DOES_NOT_EXIST', null, 'default'));
$_ENV['DOES_EXIST'] = 'some value';
$request = new Request();
$this->assertEquals('some value', $request->env('DOES_EXIST'));
$request = new Request();
$this->assertEquals('some value', $request->env('DOES_EXIST', null, 'default'));
$_ENV['EMPTY_VALUE'] = '';
$request = new Request();
$this->assertEquals('', $request->env('EMPTY_VALUE'));
$request = new Request();
$this->assertEquals('', $request->env('EMPTY_VALUE', null, 'default'));
$_ENV['ZERO'] = '0';
$request = new Request();
$this->assertEquals('0', $request->env('ZERO'));
$request = new Request();
$this->assertEquals('0', $request->env('ZERO', null, 'default'));
}

0 comments on commit 4bc0f2d

Please sign in to comment.
You can’t perform that action at this time.