updated-packages
This commit is contained in:
@@ -1,20 +1,21 @@
|
||||
<?php namespace League\OAuth1\Client\Tests;
|
||||
|
||||
use League\OAuth1\Client\Server\Xing;
|
||||
use InvalidArgumentException;
|
||||
use League\OAuth1\Client\Credentials\ClientCredentials;
|
||||
use League\OAuth1\Client\Server\Xing;
|
||||
use Mockery as m;
|
||||
use PHPUnit_Framework_TestCase;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class XingTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
class XingTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* Close mockery.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function tearDown()
|
||||
protected function tearDown(): void
|
||||
{
|
||||
m::close();
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
public function testCreatingWithArray()
|
||||
@@ -42,7 +43,7 @@ class XingTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function testGettingTemporaryCredentials()
|
||||
{
|
||||
$server = m::mock('League\OAuth1\Client\Server\Xing[createHttpClient]', array($this->getMockClientCredentials()));
|
||||
$server = m::mock('League\OAuth1\Client\Server\Xing[createHttpClient]', [$this->getMockClientCredentials()]);
|
||||
|
||||
$server->shouldReceive('createHttpClient')->andReturn($client = m::mock('stdClass'));
|
||||
|
||||
@@ -54,13 +55,13 @@ class XingTest extends PHPUnit_Framework_TestCase
|
||||
// OAuth protocol specifies a strict number of
|
||||
// headers should be sent, in the correct order.
|
||||
// We'll validate that here.
|
||||
$pattern = '/OAuth oauth_consumer_key=".*?", oauth_nonce="[a-zA-Z0-9]+", oauth_signature_method="HMAC-SHA1", oauth_timestamp="\d{10}", oauth_version="1.0", oauth_callback="'.preg_quote('http%3A%2F%2Fapp.dev%2F', '/').'", oauth_signature=".*?"/';
|
||||
$pattern = '/OAuth oauth_consumer_key=".*?", oauth_nonce="[a-zA-Z0-9]+", oauth_signature_method="HMAC-SHA1", oauth_timestamp="\d{10}", oauth_version="1.0", oauth_callback="' . preg_quote('http%3A%2F%2Fapp.dev%2F', '/') . '", oauth_signature=".*?"/';
|
||||
|
||||
$matches = preg_match($pattern, $headers['Authorization']);
|
||||
$me->assertEquals(1, $matches, 'Asserting that the authorization header contains the correct expression.');
|
||||
|
||||
return true;
|
||||
}))->once()->andReturn($response = m::mock('stdClass'));
|
||||
}))->once()->andReturn($response = m::mock(ResponseInterface::class));
|
||||
$response->shouldReceive('getBody')->andReturn('oauth_token=temporarycredentialsidentifier&oauth_token_secret=temporarycredentialssecret&oauth_callback_confirmed=true');
|
||||
|
||||
$credentials = $server->getTemporaryCredentials();
|
||||
@@ -82,9 +83,6 @@ class XingTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($expected, $server->getAuthorizationUrl($credentials));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException InvalidArgumentException
|
||||
*/
|
||||
public function testGettingTokenCredentialsFailsWithManInTheMiddle()
|
||||
{
|
||||
$server = new Xing($this->getMockClientCredentials());
|
||||
@@ -92,12 +90,14 @@ class XingTest extends PHPUnit_Framework_TestCase
|
||||
$credentials = m::mock('League\OAuth1\Client\Credentials\TemporaryCredentials');
|
||||
$credentials->shouldReceive('getIdentifier')->andReturn('foo');
|
||||
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
|
||||
$server->getTokenCredentials($credentials, 'bar', 'verifier');
|
||||
}
|
||||
|
||||
public function testGettingTokenCredentials()
|
||||
{
|
||||
$server = m::mock('League\OAuth1\Client\Server\Xing[createHttpClient]', array($this->getMockClientCredentials()));
|
||||
$server = m::mock('League\OAuth1\Client\Server\Xing[createHttpClient]', [$this->getMockClientCredentials()]);
|
||||
|
||||
$temporaryCredentials = m::mock('League\OAuth1\Client\Credentials\TemporaryCredentials');
|
||||
$temporaryCredentials->shouldReceive('getIdentifier')->andReturn('temporarycredentialsidentifier');
|
||||
@@ -120,10 +120,10 @@ class XingTest extends PHPUnit_Framework_TestCase
|
||||
$matches = preg_match($pattern, $headers['Authorization']);
|
||||
$me->assertEquals(1, $matches, 'Asserting that the authorization header contains the correct expression.');
|
||||
|
||||
$me->assertSame($body, array('oauth_verifier' => 'myverifiercode'));
|
||||
$me->assertSame($body, ['oauth_verifier' => 'myverifiercode']);
|
||||
|
||||
return true;
|
||||
}))->once()->andReturn($response = m::mock('stdClass'));
|
||||
}))->once()->andReturn($response = m::mock(ResponseInterface::class));
|
||||
$response->shouldReceive('getBody')->andReturn('oauth_token=tokencredentialsidentifier&oauth_token_secret=tokencredentialssecret');
|
||||
|
||||
$credentials = $server->getTokenCredentials($temporaryCredentials, 'temporarycredentialsidentifier', 'myverifiercode');
|
||||
@@ -134,7 +134,7 @@ class XingTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function testGettingUserDetails()
|
||||
{
|
||||
$server = m::mock('League\OAuth1\Client\Server\Xing[createHttpClient,protocolHeader]', array($this->getMockClientCredentials()));
|
||||
$server = m::mock('League\OAuth1\Client\Server\Xing[createHttpClient,protocolHeader]', [$this->getMockClientCredentials()]);
|
||||
|
||||
$temporaryCredentials = m::mock('League\OAuth1\Client\Credentials\TokenCredentials');
|
||||
$temporaryCredentials->shouldReceive('getIdentifier')->andReturn('tokencredentialsidentifier');
|
||||
@@ -157,7 +157,7 @@ class XingTest extends PHPUnit_Framework_TestCase
|
||||
$me->assertEquals(1, $matches, 'Asserting that the authorization header contains the correct expression.');
|
||||
|
||||
return true;
|
||||
}))->once()->andReturn($response = m::mock('stdClass'));
|
||||
}))->once()->andReturn($response = m::mock(ResponseInterface::class));
|
||||
$response->shouldReceive('getBody')->once()->andReturn($this->getUserPayload());
|
||||
|
||||
$user = $server->getUserDetails($temporaryCredentials);
|
||||
@@ -170,11 +170,11 @@ class XingTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
protected function getMockClientCredentials()
|
||||
{
|
||||
return array(
|
||||
return [
|
||||
'identifier' => $this->getApplicationKey(),
|
||||
'secret' => 'mysecret',
|
||||
'callback_uri' => 'http://app.dev/',
|
||||
);
|
||||
];
|
||||
}
|
||||
|
||||
protected function getApplicationKey()
|
||||
@@ -184,7 +184,7 @@ class XingTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
protected function getApplicationExpiration($days = 0)
|
||||
{
|
||||
return is_numeric($days) && $days > 0 ? $days.'day'.($days == 1 ? '' : 's') : 'never';
|
||||
return is_numeric($days) && $days > 0 ? $days . 'day' . ($days == 1 ? '' : 's') : 'never';
|
||||
}
|
||||
|
||||
protected function getApplicationName()
|
||||
|
||||
Reference in New Issue
Block a user