Autarky\Application::setEnvironment PHP Method

setEnvironment() public method

Set the environment of the application. Has to be called before boot().
public setEnvironment ( string $environment )
$environment string
    public function setEnvironment($environment)
    {
        if ($this->booting) {
            throw new \RuntimeException('Cannot set environment after application has booted');
        }
        if ($environment instanceof Closure) {
            $environment = call_user_func($environment);
        }
        if (!is_string($environment)) {
            throw new \InvalidArgumentException('Environment must be a string');
        }
        $this->environment = $environment;
    }

Usage Example

コード例 #1
0
ファイル: TestCase.php プロジェクト: autarky/framework
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     $this->app = $this->createApplication();
     $this->app->setEnvironment('testing');
     $this->app->boot();
     $this->app->getErrorHandler()->setRethrow(true);
 }