Elgg\RouterTest::testCanAllowRewrite PHP Method

testCanAllowRewrite() public method

public testCanAllowRewrite ( )
    public function testCanAllowRewrite()
    {
        $this->hooks->registerHandler('route:rewrite', 'foo', function ($hook, $type, $return, $params) {
            $this->assertEquals('route:rewrite', $hook);
            $this->assertEquals('foo', $type);
            $this->assertEquals($return, $params);
            $this->assertEquals('foo', $return['identifier']);
            $this->assertEquals(['bar', 'baz'], $return['segments']);
            return ['identifier' => 'foo2', 'segments' => ['bar2', 'baz2']];
        });
        $this->request = $this->prepareHttpRequest('foo/bar/baz');
        $this->createService();
        $return = _elgg_services()->router->allowRewrite($this->request);
        $this->assertInstanceOf(Request::class, $return);
        $segments = $return->getUrlSegments();
        $identifier = array_shift($segments);
        $this->assertEquals('foo2', $identifier);
        $this->assertEquals(['bar2', 'baz2'], $segments);
    }
RouterTest