lithium\tests\cases\net\http\RouterTest::testProcessWithAbsoluteAndPrefixedAttachment PHP Method

testProcessWithAbsoluteAndPrefixedAttachment() public method

    public function testProcessWithAbsoluteAndPrefixedAttachment()
    {
        Router::scope('app', function () {
            Router::connect('/home/welcome', array('Home::app'));
        });
        Router::scope('tests', function () {
            Router::connect('/home/welcome', array('Home::tests'));
        });
        Router::connect('/home/welcome', array('Home::default'));
        Router::attach('tests', array('absolute' => true, 'host' => 'app.mysite.com', 'scheme' => 'http', 'prefix' => '/prefix1'));
        Router::attach('app', array('absolute' => true, 'host' => 'app.mysite.com', 'scheme' => 'http', 'prefix' => '/prefix2'));
        $request = new Request(array('host' => 'app.mysite.com', 'url' => '/home/welcome'));
        $result = Router::process($request);
        $expected = array('controller' => 'Home', 'action' => 'default');
        $this->assertEqual($expected, $result->params);
        $this->assertIdentical(false, Router::scope());
        $request = new Request(array('host' => 'app.mysite.com', 'url' => '/prefix2/home/welcome'));
        $result = Router::process($request);
        $expected = array('library' => 'app', 'controller' => 'Home', 'action' => 'app');
        $this->assertEqual($expected, $result->params);
        $this->assertIdentical('app', Router::scope());
        $request = new Request(array('host' => 'app.mysite.com', 'url' => '/prefix1/home/welcome'));
        $result = Router::process($request);
        $expected = array('library' => 'tests', 'controller' => 'Home', 'action' => 'tests');
        $this->assertEqual($expected, $result->params);
        $this->assertIdentical('tests', Router::scope());
    }
RouterTest