public function testPost()
 {
     $response = $this->mockHttpClient->post('http://test-collector.com/collect?v=1');
     $this->assertInstanceOf('Psr\\Http\\Message\\ResponseInterface', $response);
     $responseAsync = $this->mockHttpClient->post('http://test-collector.com/collect?v=1', true);
     $this->assertInstanceOf('GuzzleHttp\\Promise\\PromiseInterface', $responseAsync);
     $response = $this->httpClient->post('http://test-collector.com/collect?v=1');
     $this->assertInstanceOf('TheIconic\\Tracking\\GoogleAnalytics\\AnalyticsResponse', $response);
     // Promises should be unwrapped on the object destruction
     $this->httpClient = null;
     $this->mockHttpClient = null;
 }
 public function testPost()
 {
     $singleParameter = new SingleTestParameter();
     $singleParameter->setValue('hey');
     $singleParameterIdx = new SingleTestParameterIndexed(4);
     $singleParameterIdx->setValue(9);
     $singles = [$singleParameter, $singleParameterIdx];
     $compoundCollection = new CompoundParameterTestCollection(6);
     $compoundParameter = new CompoundTestParameter(['sku' => 555, 'name' => 'cathy']);
     $compoundCollection->add($compoundParameter);
     $compoundParameter2 = new CompoundTestParameter(['sku' => 666, 'name' => 'isa']);
     $compoundCollection->add($compoundParameter2);
     $compounds = [$compoundCollection];
     $response = $this->httpClient->post('http://test-collector.com', $singles, $compounds);
     $this->assertInstanceOf('TheIconic\\Tracking\\GoogleAnalytics\\AnalyticsResponse', $response);
     $payload = $this->httpClient->getPayloadParameters();
     $expect = ['test' => 'hey', 'testi4' => 9, 'cp6t1id' => 555, 'cp6t1nm' => 'cathy', 'cp6t2id' => 666, 'cp6t2nm' => 'isa'];
     $this->assertEquals($expect, $payload);
 }