/** * Tests that the user agent header is properly set for this client library. */ public function testIntegrationCheckUserAgent() { // Get the response xml $xmlResponse = $this->assetHelper->getAsset(sprintf(self::RESPONSE_NAME, self::SERVICE)); // Create a regular AdWordsUser $user = new AdWordsUser($this->assetHelper->getAssetPath('auth.ini')); $campaignService = $user->getService(self::SERVICE); // Build a mocked SoapClient $headerPortion = implode('/', $user->GetClientLibraryNameAndVersion()); // Setup the test. $soapClientMock = $this->getMockBuilder('SoapClient')->setMethods(array('__doRequest'))->disableOriginalConstructor()->getMock(); $soapClientMock->expects($this->any())->method('__doRequest')->with($this->stringContains($headerPortion, false))->will($this->returnValue($xmlResponse)); // Set the transport layer on the soap client to be the mocked soap client. $campaignService->__SetTransportLayer($soapClientMock); // Create selector. $selector = new Selector(); // Specify the fields to retrieve. $selector->fields = array('Login', 'CustomerId', 'Name'); // Make the get request. $graph = $campaignService->get($selector); $this->assertEquals($graph->entries[0]->id, self::CAMPAIGN_ID); }