Skip to content

Commit

Permalink
Added some tests to show the success of a request with the compressio…
Browse files Browse the repository at this point in the history
…n parameter
  • Loading branch information
yboucher committed Dec 12, 2015
1 parent a1bed14 commit 713c6cf
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions test/lib/Elastica/Test/Transport/HttpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,18 +227,33 @@ public function testBodyReuse()
/**
* @group functional
*/
public function testPostWith0Body()
public function testRequestSuccessWithHttpCompressionEnabled()
{
$client = $this->_getClient();
$client = $this->_getClient(array('transport' => array('type' => 'Http', 'compression' => true, 'curl' => array(CURLINFO_HEADER_OUT => true))));

$index = $client->getIndex('elastica_0_body');
$index->create(array(), true);
$this->_waitForAllocation($index);
$index->refresh();
$index = $client->getIndex('elastica_request_with_body_and_http_compression_enabled');

$createIndexResponse = $index->create(array(), true);

$createIndexResponseTransferInfo = $createIndexResponse->getTransferInfo();
$this->assertRegExp('/Accept-Encoding:\ (gzip|deflate)/', $createIndexResponseTransferInfo['request_header']);
$this->assertArrayHasKey('acknowledged', $createIndexResponse->getData());
}

/**
* @group functional
*/
public function testRequestSuccessWithHttpCompressionDisabled()
{
$client = $this->_getClient(array('transport' => array('type' => 'Http', 'compression' => false, 'curl' => array(CURLINFO_HEADER_OUT => true))));

$index = $client->getIndex('elastica_request_with_body_and_http_compression_disabled');

$tokens = $index->analyze('0');
$createIndexResponse = $index->create(array(), true);

$this->assertNotEmpty($tokens);
$createIndexResponseTransferInfo = $createIndexResponse->getTransferInfo();
$this->assertRegExp('/Accept-Encoding:\ (gzip|deflate)/', $createIndexResponseTransferInfo['request_header']);
$this->assertArrayHasKey('acknowledged', $createIndexResponse->getData());
}

protected function checkProxy($url)
Expand Down

0 comments on commit 713c6cf

Please sign in to comment.