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

testGetHandler() public method

public testGetHandler ( )
    public function testGetHandler()
    {
        //Application instance is needed to setup container
        $app = new ApiApplication([ApiApplication::SETTING_API_VERSION => '1beta0']);
        $route = $this->getRouteFixture();
        $mdHandleApiVersion = [$app, 'handleApiVersion'];
        $route->addMiddleware($mdHandleApiVersion);
        $handler1 = function ($id) {
        };
        $handler2 = function ($id) {
            return 1;
        };
        $this->assertInternalType('callable', $route->getHandler());
        $route->addDefaults(['controller' => $handler1]);
        $this->assertSame($handler1, $route->getHandler());
        $route->addDefaults($handler2);
        $this->assertSame($handler2, $route->getHandler());
        //AbstractController based handler
        $route->setDefaults(['controller' => $app->getRouteHandler('Admin_Users:get')]);
        $this->assertInternalType('callable', $route->getHandler());
        $this->assertInstanceOf('Scalr\\Api\\Service\\Admin\\V1beta0\\Controller\\Users', $route->getHandler()[0]);
        $this->assertEquals('get', $route->getHandler()[1]);
    }