Scalr\Tests\Api\Rest\Routing\RouteTest::testDipatch PHP Method

testDipatch() public method

public testDipatch ( )
    public function testDipatch()
    {
        $me = $this;
        $app = new ApiApplication();
        $actual = new ArrayObject([]);
        $route = $this->getRouteFixture();
        $route->addMiddleware([$app, 'handleApiVersion']);
        $route->setMiddleware([function ($r) use($actual) {
            $actual['md1'] = $r->getPath();
        }, function ($r) use($actual) {
            $actual['md2'] = true;
        }]);
        $route->addDefaults(function ($id) use($route, $me, $actual) {
            $me->assertEquals(123, $id);
            $me->assertArrayHas($route->getPath(), 'md1', $actual, 'First middleware has not been run.');
            $me->assertArrayHas(true, 'md2', $actual, 'Second middleware has not been run.');
            $actual['handler'] = true;
        });
        $this->assertTrue($route->matches('/api/path/123'));
        $this->assertEquals(true, $route->dispatch());
        $this->assertArrayHasKey('handler', $actual, 'Route handler has not been run.');
    }