Skip to content

Commit

Permalink
Try to cover more test code.
Browse files Browse the repository at this point in the history
  • Loading branch information
terrencegf committed May 25, 2017
1 parent 6637976 commit a9295d0
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions test/src/Provider/CILogonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,10 @@ public function testUserData()
$this->assertEquals($name, $user->getName());
$this->assertEquals($name, $user->toArray()['name']);
$this->assertEquals($given_name, $user->getGivenName());
$this->assertEquals($given_name, $user->getFirstName());
$this->assertEquals($given_name, $user->toArray()['given_name']);
$this->assertEquals($family_name, $user->getFamilyName());
$this->assertEquals($family_name, $user->getLastName());
$this->assertEquals($family_name, $user->toArray()['family_name']);
$this->assertEquals($eppn, $user->getEPPN());
$this->assertEquals($eppn, $user->toArray()['eppn']);
Expand Down Expand Up @@ -173,5 +175,24 @@ public function testExceptionThrownWhenErrorObjectReceived()
$token = $this->provider->getAccessToken('authorization_code',
['code' => 'mock_authorization_code']);
}

/**
* @expectedException League\OAuth2\Client\Provider\Exception\IdentityProviderException
**/
public function testExceptionThrownWnenHTTPErrorStatus()
{
$status = rand(401,599);
$reason = 'HTTP ERROR';
$postResponse = m::mock('Psr\Http\Message\ResponseInterface');
$postResponse->shouldReceive('getStatusCode')->andReturn($status);
$postResponse->shouldReceive('getReasonPhrase')->andReturn($reason);
$client = m::mock('GuzzleHttp\ClientInterface');
$client->shouldReceive('send')
->times(1)
->andReturn($postResponse);
$this->provider->setHttpClient($client);
$token = $this->provider->getAccessToken('authorization_code',
['code' => 'mock_authorization_code']);
}
}

0 comments on commit a9295d0

Please sign in to comment.