Updated OAuthToken to throw proper error on not receiving access token

- Updated Samples, Tests
This commit is contained in:
japatel
2015-01-13 23:57:56 -06:00
parent df00ab2602
commit baf06a66be
4 changed files with 229 additions and 11 deletions

View File

@@ -0,0 +1,73 @@
<?php
namespace PayPal\Test\Handler;
use PayPal\Core\PayPalHttpConfig;
use PayPal\Exception\PayPalConfigurationException;
use PayPal\Rest\ApiContext;
use PayPal\Auth\OAuthTokenCredential;
use PayPal\Handler\OauthHandler;
class OauthHandlerTest extends \PHPUnit_Framework_TestCase
{
/**
* @var \PayPal\Handler\OauthHandler
*/
public $handler;
/**
* @var PayPalHttpConfig
*/
public $httpConfig;
/**
* @var ApiContext
*/
public $apiContext;
/**
* @var array
*/
public $config;
public function setUp()
{
$this->apiContext = new ApiContext(
new OAuthTokenCredential(
'clientId',
'clientSecret'
)
);
}
public function modeProvider()
{
return array(
array( array('mode' => 'sandbox') ),
array( array('mode' => 'live')),
array( array( 'mode' => 'sandbox','oauth.EndPoint' => 'http://localhost/')),
array( array('mode' => 'sandbox','service.EndPoint' => 'http://service.localhost/'))
);
}
/**
* @dataProvider modeProvider
* @param $configs
*/
public function testGetEndpoint($configs)
{
$config = $configs + array(
'cache.enabled' => true,
'http.headers.header1' => 'header1value'
);
$this->apiContext->setConfig($config);
$this->httpConfig = new PayPalHttpConfig(null, 'POST', $config);
$this->handler = new OauthHandler($this->apiContext);
$this->handler->handle($this->httpConfig, null, $this->config);
}
}