public function testGetLoginUrl()
{
$expected = 'loginUrl';
$state = 'random';
$params = ['response_type' => 'code', 'client_id' => self::APP_ID, 'redirect_uri' => null, 'state' => $state];
$storage = $this->getMock('Happyr\\LinkedIn\\Storage\\DataStorageInterface');
$storage->method('get')->with('state')->willReturn($state);
$auth = $this->getMock('Happyr\\LinkedIn\\Authenticator', ['establishCSRFTokenState', 'getStorage'], [$this->getRequestManagerMock(), self::APP_ID, self::APP_SECRET]);
$auth->expects($this->exactly(2))->method('establishCSRFTokenState')->willReturn(null);
$auth->method('getStorage')->will($this->returnValue($storage));
$generator = m::mock('Happyr\\LinkedIn\\Http\\LinkedInUrlGeneratorInterface')->shouldReceive('getUrl')->once()->with('www', 'oauth/v2/authorization', $params)->andReturn($expected)->getMock();
$this->assertEquals($expected, $auth->getLoginUrl($generator));
/*
* Test with a url in the param
*/
$otherUrl = 'otherUrl';
$scope = ['foo', 'bar', 'baz'];
$params = ['response_type' => 'code', 'client_id' => self::APP_ID, 'redirect_uri' => $otherUrl, 'state' => $state, 'scope' => 'foo bar baz'];
$generator = m::mock('Happyr\\LinkedIn\\Http\\LinkedInUrlGeneratorInterface')->shouldReceive('getUrl')->once()->with('www', 'oauth/v2/authorization', $params)->andReturn($expected)->getMock();
$this->assertEquals($expected, $auth->getLoginUrl($generator, ['redirect_uri' => $otherUrl, 'scope' => $scope]));
}