Phalcon\Test\Unit\Http\RequestTest::testHttpRequestPort PHP Method

testHttpRequestPort() public method

Tests Request::getPort
Since: 2016-06-26
Author: Serghei Iakovlev ([email protected])
public testHttpRequestPort ( )
    public function testHttpRequestPort()
    {
        $this->specify("http host with https on does not return expected port", function () {
            $request = $this->getRequestObject();
            $this->setServerVar('HTTPS', 'on');
            $this->setServerVar('HTTP_HOST', 'example.com');
            expect($request->getPort())->equals(443);
        });
        $this->specify("http host with https off does not return expected port", function () {
            $request = $this->getRequestObject();
            $this->setServerVar('HTTPS', 'off');
            $this->setServerVar('HTTP_HOST', 'example.com');
            expect($request->getPort())->equals(80);
        });
        $this->specify("http host with port on HTTP_HOST does not return expected port", function () {
            $request = $this->getRequestObject();
            $this->setServerVar('HTTPS', 'off');
            $this->setServerVar('HTTP_HOST', 'example.com:8080');
            expect($request->getPort())->equals(8080);
            $this->setServerVar('HTTPS', 'on');
            $this->setServerVar('HTTP_HOST', 'example.com:8081');
            expect($request->getPort())->equals(8081);
            unset($_SERVER['HTTPS']);
            $this->setServerVar('HTTP_HOST', 'example.com:8082');
            expect($request->getPort())->equals(8082);
        });
    }