public function testMagicConstructorsPropogateMinorVersion() { $v = 84; $this->service->setMinorProtocolVersion($v); $feed = $this->service->newFeed(); $this->assertEquals($v, $feed->getMinorProtocolVersion()); }
public function testSetClientIDAndDeveloperKeyHeader() { $applicationId = 'MyTestCompany-MyTestApp-0.1'; $clientId = 'MyClientId'; $developerKey = 'MyDeveloperKey'; $httpClient = new \Zend\Http\Client(); $yt = new YouTube($httpClient, $applicationId, $clientId, $developerKey); $this->assertTrue($yt instanceof YouTube); $client = $yt->getHttpClient(); $this->assertEquals($client->getHeader('User-Agent'), \ZendGData\App::getUserAgentString($applicationId)); $this->assertEquals($client->getHeader('X-GData-Key'), 'key=' . $developerKey); $this->assertEquals($client->getHeader('X-GData-Client'), $clientId); }
public function testLookupNamespaceObeysParentBehavior() { $prefix = 'test'; $testString10 = 'TEST-v1-0'; $testString20 = 'TEST-v2-0'; $testString11 = 'TEST-v1-1'; $testString21 = 'TEST-v2-1'; $testString12 = 'TEST-v1-2'; $testString22 = 'TEST-v2-2'; App\AbstractBase::flushNamespaceLookupCache(); $entry = $this->service->newEntry(); $entry->registerNamespace($prefix, $testString10, 1, 0); $entry->registerNamespace($prefix, $testString20, 2, 0); $entry->registerNamespace($prefix, $testString11, 1, 1); $entry->registerNamespace($prefix, $testString21, 2, 1); $entry->registerNamespace($prefix, $testString12, 1, 2); $entry->registerNamespace($prefix, $testString22, 2, 2); // Assumes default version (1) $result = $entry->lookupNamespace($prefix, 1, null); $this->assertEquals($testString12, $result); $result = $entry->lookupNamespace($prefix, 2, null); $this->assertEquals($testString22, $result); $result = $entry->lookupNamespace($prefix, 1, 1); $this->assertEquals($testString11, $result); $result = $entry->lookupNamespace($prefix, 2, 1); $this->assertEquals($testString21, $result); $result = $entry->lookupNamespace($prefix, null, null); $this->assertEquals($testString12, $result); $result = $entry->lookupNamespace($prefix, null, 1); $this->assertEquals($testString11, $result); // Override to retrieve latest version $entry->setMajorProtocolVersion(null); $result = $entry->lookupNamespace($prefix, null, null); $this->assertEquals($testString22, $result); $result = $entry->lookupNamespace($prefix, null, 1); $this->assertEquals($testString21, $result); }
/** * Retrieve a HTTP client object with AuthSub credentials attached * as the Authorization header * * @param string $token The token to retrieve information about * @param HttpClient $client (optional) HTTP client to use to make the request * @return HttpClient */ public static function getHttpClient($token, HttpClient $client = null) { if ($client == null) { $client = new HttpClient(); } $useragent = App::getUserAgentString(); $client->setOptions(array('strictredirects' => true, 'useragent' => $useragent)); $client->setAuthSubToken($token); return $client; }