Happyr\LinkedIn\Http\UrlGeneratorTest::testGetCurrentURL PHP Method

testGetCurrentURL() public method

public testGetCurrentURL ( )
    public function testGetCurrentURL()
    {
        $gen = $this->getMock('Happyr\\LinkedIn\\Http\\UrlGenerator', ['getHttpProtocol', 'getHttpHost', 'dropLinkedInParams'], []);
        $gen->expects($this->any())->method('getHttpProtocol')->will($this->returnValue('http'));
        $gen->expects($this->any())->method('getHttpHost')->will($this->returnValue('www.test.com'));
        $gen->expects($this->any())->method('dropLinkedInParams')->will($this->returnCallback(function ($arg) {
            return empty($arg) ? '' : '?' . $arg;
        }));
        // fake the HPHP $_SERVER globals
        $_SERVER['REQUEST_URI'] = '/unit-tests.php?one=one&two=two&three=three';
        $this->assertEquals('http://www.test.com/unit-tests.php?one=one&two=two&three=three', $gen->getCurrentUrl(), 'getCurrentUrl function is changing the current URL');
        // ensure structure of valueless GET params is retained (sometimes
        // an = sign was present, and sometimes it was not)
        // first test when equal signs are present
        $_SERVER['REQUEST_URI'] = '/unit-tests.php?one=&two=&three=';
        $this->assertEquals('http://www.test.com/unit-tests.php?one=&two=&three=', $gen->getCurrentUrl(), 'getCurrentUrl function is changing the current URL');
        // now confirm that
        $_SERVER['REQUEST_URI'] = '/unit-tests.php?one&two&three';
        $this->assertEquals('http://www.test.com/unit-tests.php?one&two&three', $gen->getCurrentUrl(), 'getCurrentUrl function is changing the current URL');
    }