lithium\tests\cases\core\EnvironmentTest::testDetectionWithArrayMap PHP Method

testDetectionWithArrayMap() public method

Tests that environment names can be mapped to lists of host names, or a hostname-matching regular expression.
    public function testDetectionWithArrayMap()
    {
        Environment::is(array('development' => '/^local|^\\.console/', 'test' => array('test1.myapp.com', 'test2.myapp.com'), 'staging' => array('staging.myapp.com')));
        Environment::set(new MockRequest(array('http:host' => 'localhost')));
        $this->assertTrue(Environment::is('development'));
        Environment::set(new MockRequest(array('http:host' => 'test1.myapp.com')));
        $this->assertTrue(Environment::is('test'));
        Environment::set(new MockRequest(array('http:host' => 'test3.myapp.com')));
        $this->assertTrue(Environment::is('production'));
        Environment::set(new MockRequest(array('http:host' => 'localhost:3030')));
        $this->assertTrue(Environment::is('development'));
        $request = new MockRequest();
        $request->params = array('env' => 'whatever');
        Environment::set($request);
        $this->assertTrue(Environment::is('whatever'));
    }