forked from LiveCarta/PayPal-PHP-SDK
Updating User Agent for Internal Purposes
This commit is contained in:
@@ -23,21 +23,20 @@ class PayPalUserAgent
|
|||||||
{
|
{
|
||||||
|
|
||||||
$featureList = array(
|
$featureList = array(
|
||||||
'lang=PHP',
|
'platform-ver=' . PHP_VERSION,
|
||||||
'v=' . PHP_VERSION,
|
|
||||||
'bit=' . self::_getPHPBit(),
|
'bit=' . self::_getPHPBit(),
|
||||||
'os=' . str_replace(' ', '_', php_uname('s') . ' ' . php_uname('r')),
|
'os=' . str_replace(' ', '_', php_uname('s') . ' ' . php_uname('r')),
|
||||||
'machine=' . php_uname('m')
|
'machine=' . php_uname('m')
|
||||||
);
|
);
|
||||||
if (defined('OPENSSL_VERSION_TEXT')) {
|
if (defined('OPENSSL_VERSION_TEXT')) {
|
||||||
$opensslVersion = explode(' ', OPENSSL_VERSION_TEXT);
|
$opensslVersion = explode(' ', OPENSSL_VERSION_TEXT);
|
||||||
$featureList[] = 'openssl=' . $opensslVersion[1];
|
$featureList[] = 'crypto-lib-ver=' . $opensslVersion[1];
|
||||||
}
|
}
|
||||||
if (function_exists('curl_version')) {
|
if (function_exists('curl_version')) {
|
||||||
$curlVersion = curl_version();
|
$curlVersion = curl_version();
|
||||||
$featureList[] = 'curl=' . $curlVersion['version'];
|
$featureList[] = 'curl=' . $curlVersion['version'];
|
||||||
}
|
}
|
||||||
return sprintf("PayPalSDK/%s %s (%s)", $sdkName, $sdkVersion, implode(';', $featureList));
|
return sprintf("PayPalSDK/%s %s (%s)", $sdkName, $sdkVersion, implode('; ', $featureList));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class UserAgentTest extends PHPUnit_Framework_TestCase
|
|||||||
public function testGetValue()
|
public function testGetValue()
|
||||||
{
|
{
|
||||||
$ua = PayPalUserAgent::getValue("name", "version");
|
$ua = PayPalUserAgent::getValue("name", "version");
|
||||||
list($id, $version, $features) = sscanf($ua, "PayPalSDK/%s %s (%s)");
|
list($id, $version, $features) = sscanf($ua, "PayPalSDK/%s %s (%[^[]])");
|
||||||
|
|
||||||
// Check that we pass the useragent in the expected format
|
// Check that we pass the useragent in the expected format
|
||||||
$this->assertNotNull($id);
|
$this->assertNotNull($id);
|
||||||
@@ -19,10 +19,9 @@ class UserAgentTest extends PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals("version", $version);
|
$this->assertEquals("version", $version);
|
||||||
|
|
||||||
// Check that we pass in these mininal features
|
// Check that we pass in these mininal features
|
||||||
$this->assertThat($features, $this->stringContains("OS="));
|
$this->assertThat($features, $this->stringContains("os="));
|
||||||
$this->assertThat($features, $this->stringContains("Bit="));
|
$this->assertThat($features, $this->stringContains("bit="));
|
||||||
$this->assertThat($features, $this->stringContains("Lang="));
|
$this->assertThat($features, $this->stringContains("platform-ver="));
|
||||||
$this->assertThat($features, $this->stringContains("V="));
|
|
||||||
$this->assertGreaterThan(5, count(explode(';', $features)));
|
$this->assertGreaterThan(5, count(explode(';', $features)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user