FoundationEnvironmentDetectorTest.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace Illuminate\Tests\Foundation;
  3. use Illuminate\Foundation\EnvironmentDetector;
  4. use PHPUnit\Framework\TestCase;
  5. class FoundationEnvironmentDetectorTest extends TestCase
  6. {
  7. public function testClosureCanBeUsedForCustomEnvironmentDetection()
  8. {
  9. $env = new EnvironmentDetector;
  10. $result = $env->detect(function () {
  11. return 'foobar';
  12. });
  13. $this->assertSame('foobar', $result);
  14. }
  15. public function testConsoleEnvironmentDetection()
  16. {
  17. $env = new EnvironmentDetector;
  18. $result = $env->detect(function () {
  19. return 'foobar';
  20. }, ['--env=local']);
  21. $this->assertSame('local', $result);
  22. }
  23. public function testConsoleEnvironmentDetectionSeparatedWithSpace()
  24. {
  25. $env = new EnvironmentDetector;
  26. $result = $env->detect(function () {
  27. return 'foobar';
  28. }, ['--env', 'local']);
  29. $this->assertSame('local', $result);
  30. }
  31. public function testConsoleEnvironmentDetectionWithNoValue()
  32. {
  33. $env = new EnvironmentDetector;
  34. $result = $env->detect(function () {
  35. return 'foobar';
  36. }, ['--env']);
  37. $this->assertSame('foobar', $result);
  38. }
  39. }