lithium\tests\cases\net\http\RouterTest::testRouteRetrievalWithScope PHP Метод

testRouteRetrievalWithScope() публичный Метод

    public function testRouteRetrievalWithScope()
    {
        Router::scope('loc1', function () use(&$expected) {
            $expected = Router::connect('/hello', array('controller' => 'Posts', 'action' => 'index'));
        });
        $result = Router::get(0, true);
        $this->assertIdentical(null, $result);
        $result = Router::get(0, 'loc1');
        $this->assertIdentical($expected, $result);
        Router::scope('loc1', function () {
            Router::connect('/helloworld', array('controller' => 'Posts', 'action' => 'index'));
        });
        Router::scope('loc2', function () {
            Router::connect('/hello', array('controller' => 'Posts', 'action' => 'index'));
        });
        $this->assertCount(0, Router::get(null, true));
        $result = count(Router::get(null, 'loc1'));
        $this->assertCount(2, Router::get(null, 'loc1'));
        $scopes = Router::get();
        $result = 0;
        foreach ($scopes as $routes) {
            $result += count($routes);
        }
        $this->assertIdentical(3, $result);
    }
RouterTest