Phalcon\Test\Unit\Http\RequestTest::testHttpRequestPort PHP Метод

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

Tests Request::getPort
С версии: 2016-06-26
Автор: 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);
        });
    }