summaryrefslogtreecommitdiff
path: root/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/Transport')
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AbstractTransportTest.php77
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/GuzzleTest.php163
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/HttpTest.php227
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/MemcacheTest.php51
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTest.php59
-rw-r--r--vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/ThriftTest.php132
6 files changed, 0 insertions, 709 deletions
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AbstractTransportTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AbstractTransportTest.php
deleted file mode 100644
index 4f1c7114..00000000
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/AbstractTransportTest.php
+++ /dev/null
@@ -1,77 +0,0 @@
-<?php
-
-namespace Elastica\Test\Transport;
-
-use Elastica\Transport\AbstractTransport;
-use Elastica\Transport\Http;
-use Elastica\Connection;
-use Elastica\Exception\InvalidException;
-
-class AbstractTransportTest extends \PHPUnit_Framework_TestCase
-{
- /**
- * Return transport configuration and the expected HTTP method
- *
- * @return array[]
- */
- public function getValidDefinitions()
- {
- $connection = new Connection();
-
- return array(
- array('Http'),
- array(array('type' => 'Http')),
- array(array('type' => new Http())),
- array(new Http()),
- );
- }
-
- /**
- * @dataProvider getValidDefinitions
- */
- public function testCanCreateTransportInstances($transport)
- {
- $connection = new Connection();
- $params = array();
- $transport = AbstractTransport::create($transport, $connection, $params);
- $this->assertInstanceOf('Elastica\Transport\AbstractTransport', $transport);
- $this->assertSame($connection, $transport->getConnection());
- }
-
- public function getInvalidDefinitions()
- {
- return array(
- array(array('transport' => 'Http')),
- array('InvalidTransport'),
- );
- }
-
- /**
- * @dataProvider getInvalidDefinitions
- * @expectedException Elastica\Exception\InvalidException
- * @expectedExceptionMessage Invalid transport
- */
- public function testThrowsExecptionOnInvalidTransportDefinition($transport)
- {
- AbstractTransport::create($transport, new Connection());
- }
-
- public function testCanInjectParamsWhenUsingArray()
- {
- $connection = new Connection();
- $params = array(
- 'param1' => 'some value',
- 'param3' => 'value3',
- );
-
- $transport = AbstractTransport::create(array(
- 'type' => 'Http',
- 'param1' => 'value1',
- 'param2' => 'value2',
- ), $connection, $params);
-
- $this->assertSame('value1', $transport->getParam('param1'));
- $this->assertSame('value2', $transport->getParam('param2'));
- $this->assertSame('value3', $transport->getParam('param3'));
- }
-}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/GuzzleTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/GuzzleTest.php
deleted file mode 100644
index b2e385bb..00000000
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/GuzzleTest.php
+++ /dev/null
@@ -1,163 +0,0 @@
-<?php
-
-namespace Elastica\Test\Transport;
-
-use Elastica\Client;
-use Elastica\Document;
-use Elastica\Query;
-use Elastica\ResultSet;
-use Elastica\Test\Base as BaseTest;
-use Elastica\Exception\ResponseException;
-
-class GuzzleTest extends BaseTest
-{
- public static function setUpBeforeClass()
- {
- if (!class_exists('GuzzleHttp\\Client')) {
- self::markTestSkipped('guzzlehttp/guzzle package should be installed to run guzzle transport tests');
- }
- }
-
- public function setUp()
- {
- if (defined('DEBUG') && !DEBUG) {
- $this->markTestSkipped('The DEBUG constant must be set to true for this test to run');
- }
-
- if (!defined('DEBUG')) {
- define('DEBUG', true);
- }
- }
-
- /**
- * Return transport configuration and the expected HTTP method
- *
- * @return array[]
- */
- public function getConfig()
- {
- return array(
- array(
- array('transport' => 'Guzzle'),
- 'GET'
- ),
- array(
- array('transport' => array('type' => 'Guzzle', 'postWithRequestBody' => false)),
- 'GET'
- ),
- array(
- array('transport' => array('type' => 'Guzzle', 'postWithRequestBody' => true)),
- 'POST'
- ),
- );
- }
-
- /**
- * @dataProvider getConfig
- */
- public function testDynamicHttpMethodBasedOnConfigParameter(array $config, $httpMethod)
- {
- $client = new Client($config);
-
- $index = $client->getIndex('dynamic_http_method_test');
- $index->create(array(), true);
- $type = $index->getType('test');
- $type->addDocument(new Document(1, array('test' => 'test')));
- $index->refresh();
- $resultSet = $index->search('test');
- $info = $resultSet->getResponse()->getTransferInfo();
- $this->assertStringStartsWith($httpMethod, $info['request_header']);
- }
-
- /**
- * @dataProvider getConfig
- */
- public function testDynamicHttpMethodOnlyAffectsRequestsWithBody(array $config, $httpMethod)
- {
- $client = new Client($config);
-
- $status = $client->getStatus();
- $info = $status->getResponse()->getTransferInfo();
- $this->assertStringStartsWith('GET', $info['request_header']);
- }
-
- public function testWithEnvironmentalProxy()
- {
- putenv('http_proxy=http://127.0.0.1:12345/');
-
- $client = new \Elastica\Client(array('transport' => 'Guzzle'));
- $transferInfo = $client->request('/_nodes')->getTransferInfo();
- $this->assertEquals(200, $transferInfo['http_code']);
-
- $client->getConnection()->setProxy(null); // will not change anything
- $transferInfo = $client->request('/_nodes')->getTransferInfo();
- $this->assertEquals(200, $transferInfo['http_code']);
-
- putenv('http_proxy=');
- }
-
- public function testWithEnabledEnvironmentalProxy()
- {
- putenv('http_proxy=http://127.0.0.1:12346/');
-
- $client = new \Elastica\Client(array('transport' => 'Guzzle'));
-
- $transferInfo = $client->request('/_nodes')->getTransferInfo();
- $this->assertEquals(403, $transferInfo['http_code']);
-
- $client = new \Elastica\Client();
- $client->getConnection()->setProxy('');
- $transferInfo = $client->request('/_nodes')->getTransferInfo();
- $this->assertEquals(200, $transferInfo['http_code']);
-
- putenv('http_proxy=');
- }
-
- public function testWithProxy()
- {
- $client = new \Elastica\Client(array('transport' => 'Guzzle'));
- $client->getConnection()->setProxy('http://127.0.0.1:12345');
-
- $transferInfo = $client->request('/_nodes')->getTransferInfo();
- $this->assertEquals(200, $transferInfo['http_code']);
- }
-
- public function testWithoutProxy()
- {
- $client = new \Elastica\Client(array('transport' => 'Guzzle'));
- $client->getConnection()->setProxy('');
-
- $transferInfo = $client->request('/_nodes')->getTransferInfo();
- $this->assertEquals(200, $transferInfo['http_code']);
- }
-
- public function testBodyReuse()
- {
- $client = new Client(array('transport' => 'Guzzle'));
-
- $index = $client->getIndex('elastica_body_reuse_test');
-
- $index->create(array(), true);
-
- $type = $index->getType('test');
- $type->addDocument(new Document(1, array('test' => 'test')));
-
- $index->refresh();
-
- $resultSet = $index->search(array(
- 'query' => array(
- 'query_string' => array(
- 'query' => 'pew pew pew',
- ),
- ),
- ));
-
- $this->assertEquals(0, $resultSet->getTotalHits());
-
- $response = $index->request('/_search', 'POST');
- $resultSet = new ResultSet($response, Query::create(array()));
-
- $this->assertEquals(1, $resultSet->getTotalHits());
- }
-
-}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/HttpTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/HttpTest.php
deleted file mode 100644
index 88c93bea..00000000
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/HttpTest.php
+++ /dev/null
@@ -1,227 +0,0 @@
-<?php
-
-namespace Elastica\Test\Transport;
-
-use Elastica\Client;
-use Elastica\Document;
-use Elastica\Query;
-use Elastica\ResultSet;
-use Elastica\Test\Base as BaseTest;
-use Elastica\Exception\ResponseException;
-
-class HttpTest extends BaseTest
-{
- public function setUp()
- {
- if (defined('DEBUG') && !DEBUG) {
- $this->markTestSkipped('The DEBUG constant must be set to true for this test to run');
- }
-
- if (!defined('DEBUG')) {
- define('DEBUG', true);
- }
- }
-
- /**
- * Return transport configuration and the expected HTTP method
- *
- * @return array[]
- */
- public function getConfig()
- {
- return array(
- array(
- array('transport' => 'Http'),
- 'GET'
- ),
- array(
- array('transport' => array('type' => 'Http', 'postWithRequestBody' => false)),
- 'GET'
- ),
- array(
- array('transport' => array('type' => 'Http', 'postWithRequestBody' => true)),
- 'POST'
- ),
- );
- }
-
- /**
- * @dataProvider getConfig
- */
- public function testDynamicHttpMethodBasedOnConfigParameter(array $config, $httpMethod)
- {
- $client = new Client($config);
-
- $index = $client->getIndex('dynamic_http_method_test');
-
- $index->create(array(), true);
-
- $type = $index->getType('test');
- $type->addDocument(new Document(1, array('test' => 'test')));
-
- $index->refresh();
-
- $resultSet = $index->search('test');
-
- $info = $resultSet->getResponse()->getTransferInfo();
- $this->assertStringStartsWith($httpMethod, $info['request_header']);
- }
-
- /**
- * @dataProvider getConfig
- */
- public function testDynamicHttpMethodOnlyAffectsRequestsWithBody(array $config, $httpMethod)
- {
- $client = new Client($config);
-
- $status = $client->getStatus();
- $info = $status->getResponse()->getTransferInfo();
- $this->assertStringStartsWith('GET', $info['request_header']);
- }
-
- public function testCurlNobodyOptionIsResetAfterHeadRequest()
- {
- $client = new \Elastica\Client();
- $index = $client->getIndex('curl_test');
- $type = $index->getType('item');
-
- // Force HEAD request to set CURLOPT_NOBODY = true
- $index->exists();
-
- $id = 1;
- $data = array('id' => $id, 'name' => 'Item 1');
- $doc = new \Elastica\Document($id, $data);
-
- $type->addDocument($doc);
-
- $index->refresh();
-
- $doc = $type->getDocument($id);
-
- // Document should be retrieved correctly
- $this->assertSame($data, $doc->getData());
- $this->assertEquals($id, $doc->getId());
- }
-
- public function testUnicodeData()
- {
- $client = new \Elastica\Client();
- $index = $client->getIndex('curl_test');
- $type = $index->getType('item');
-
- // Force HEAD request to set CURLOPT_NOBODY = true
- $index->exists();
-
- $id = 22;
- $data = array('id' => $id, 'name' => '
- Сегодня, я вижу, особенно грустен твой взгляд, /
- И руки особенно тонки, колени обняв. /
- Послушай: далеко, далеко, на озере Чад /
- Изысканный бродит жираф.');
-
- $doc = new \Elastica\Document($id, $data);
-
- $type->addDocument($doc);
-
- $index->refresh();
-
- $doc = $type->getDocument($id);
-
- // Document should be retrieved correctly
- $this->assertSame($data, $doc->getData());
- $this->assertEquals($id, $doc->getId());
- }
-
- public function testWithEnvironmentalProxy()
- {
- putenv('http_proxy=http://127.0.0.1:12345/');
-
- $client = new \Elastica\Client();
- $transferInfo = $client->request('/_nodes')->getTransferInfo();
- $this->assertEquals(200, $transferInfo['http_code']);
-
- $client->getConnection()->setProxy(null); // will not change anything
- $transferInfo = $client->request('/_nodes')->getTransferInfo();
- $this->assertEquals(200, $transferInfo['http_code']);
-
- putenv('http_proxy=');
- }
-
- public function testWithEnabledEnvironmentalProxy()
- {
- putenv('http_proxy=http://127.0.0.1:12346/');
-
- $client = new \Elastica\Client();
-
- $transferInfo = $client->request('/_nodes')->getTransferInfo();
- $this->assertEquals(403, $transferInfo['http_code']);
-
- $client = new \Elastica\Client();
- $client->getConnection()->setProxy('');
- $transferInfo = $client->request('/_nodes')->getTransferInfo();
- $this->assertEquals(200, $transferInfo['http_code']);
-
- putenv('http_proxy=');
- }
-
- public function testWithProxy()
- {
- $client = new \Elastica\Client();
- $client->getConnection()->setProxy('http://127.0.0.1:12345');
-
- $transferInfo = $client->request('/_nodes')->getTransferInfo();
- $this->assertEquals(200, $transferInfo['http_code']);
- }
-
- public function testWithoutProxy()
- {
- $client = new \Elastica\Client();
- $client->getConnection()->setProxy('');
-
- $transferInfo = $client->request('/_nodes')->getTransferInfo();
- $this->assertEquals(200, $transferInfo['http_code']);
- }
-
- public function testBodyReuse()
- {
- $client = new Client();
-
- $index = $client->getIndex('elastica_body_reuse_test');
-
- $index->create(array(), true);
-
- $type = $index->getType('test');
- $type->addDocument(new Document(1, array('test' => 'test')));
-
- $index->refresh();
-
- $resultSet = $index->search(array(
- 'query' => array(
- 'query_string' => array(
- 'query' => 'pew pew pew',
- ),
- ),
- ));
-
- $this->assertEquals(0, $resultSet->getTotalHits());
-
- $response = $index->request('/_search', 'POST');
- $resultSet = new ResultSet($response, Query::create(array()));
-
- $this->assertEquals(1, $resultSet->getTotalHits());
- }
-
- public function testPostWith0Body()
- {
- $client = new Client();
-
- $index = $client->getIndex('elastica_0_body');
- $index->create(array(), true);
- $index->refresh();
-
- $tokens = $index->analyze('0');
-
- $this->assertNotEmpty($tokens);
- }
-
-}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/MemcacheTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/MemcacheTest.php
deleted file mode 100644
index 17d46d88..00000000
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/MemcacheTest.php
+++ /dev/null
@@ -1,51 +0,0 @@
-<?php
-
-namespace Elastica\Test\Transport;
-
-use Elastica\Client;
-use Elastica\Document;
-use Elastica\Test\Base as BaseTest;
-
-class MemcacheTest extends BaseTest
-{
- public function setUp()
- {
- if (!extension_loaded('Memcache')) {
- $this->markTestSkipped('pecl/memcache must be installed to run this test case');
- }
- }
-
- public function testExample()
- {
- // Creates a new index 'xodoa' and a type 'user' inside this index
- $host = 'localhost';
- $port = 11211;
- $client = new Client(array('host' => $host, 'port' => $port, 'transport' => 'Memcache'));
-
- $index = $client->getIndex('elastica_test1');
- $index->create(array(), true);
-
- $type = $index->getType('user');
-
- // Adds 1 document to the index
- $doc1 = new Document(1,
- array('username' => 'hans', 'test' => array('2', '3', '5'))
- );
- $type->addDocument($doc1);
-
- // Adds a list of documents with _bulk upload to the index
- $docs = array();
- $docs[] = new Document(2,
- array('username' => 'john', 'test' => array('1', '3', '6'))
- );
- $docs[] = new Document(3,
- array('username' => 'rolf', 'test' => array('2', '3', '7'))
- );
- $type->addDocuments($docs);
-
- // Refresh index
- $index->refresh();
- $this->markTestIncomplete('Memcache implementation is not finished yet');
- $resultSet = $type->search('rolf');
- }
-}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTest.php
deleted file mode 100644
index c07f5da1..00000000
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTest.php
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-
-namespace Elastica\Test\Transport;
-
-use Elastica\Client;
-use Elastica\Connection;
-use Elastica\Query;
-use Elastica\Test\Base as BaseTest;
-
-/**
- * Elastica Null Transport Test
- *
- * @package Elastica
- * @author James Boehmer <james.boehmer@jamesboehmer.com>
- */
-class NullTest extends BaseTest
-{
-
- public function testEmptyResult()
- {
- // Creates a client with any destination, and verify it returns a response object when executed
- $client = $this->_getClient();
- $connection = new Connection(array('transport' => 'Null'));
- $client->setConnections(array($connection));
-
- $index = $client->getIndex('elasticaNullTransportTest1');
-
- $resultSet = $index->search(new Query());
- $this->assertNotNull($resultSet);
-
- $response = $resultSet->getResponse();
- $this->assertNotNull($response);
-
- // Validate most of the expected fields in the response data. Consumers of the response
- // object have a reasonable expectation of finding "hits", "took", etc
- $responseData = $response->getData();
- $this->assertContains("took", $responseData);
- $this->assertEquals(0, $responseData["took"]);
- $this->assertContains("_shards", $responseData);
- $this->assertContains("hits", $responseData);
- $this->assertContains("total", $responseData["hits"]);
- $this->assertEquals(0, $responseData["hits"]["total"]);
- $this->assertContains("params", $responseData);
-
- $took = $response->getEngineTime();
- $this->assertEquals(0, $took);
-
- $errorString = $response->getError();
- $this->assertEmpty($errorString);
-
- $shards = $response->getShardsStatistics();
- $this->assertContains("total", $shards);
- $this->assertEquals(0, $shards["total"]);
- $this->assertContains("successful", $shards);
- $this->assertEquals(0, $shards["successful"]);
- $this->assertContains("failed", $shards);
- $this->assertEquals(0, $shards["failed"]);
- }
-}
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/ThriftTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/ThriftTest.php
deleted file mode 100644
index f1698ff6..00000000
--- a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/ThriftTest.php
+++ /dev/null
@@ -1,132 +0,0 @@
-<?php
-
-namespace Elastica\Test\Transport;
-
-use Elastica\Client;
-use Elastica\Connection;
-use Elastica\Document;
-use Elastica\Index;
-use Elastica\Query;
-use Elastica\Test\Base as BaseTest;
-
-class ThriftTest extends BaseTest
-{
- public static function setUpBeforeClass()
- {
- if (!class_exists('Elasticsearch\\RestClient')) {
- self::markTestSkipped('munkie/elasticsearch-thrift-php package should be installed to run thrift transport tests');
- }
- }
-
- public function testConstruct()
- {
- $host = 'localhost';
- $port = 9500;
- $client = new Client(array('host' => $host, 'port' => $port, 'transport' => 'Thrift'));
-
- $this->assertEquals($host, $client->getConnection()->getHost());
- $this->assertEquals($port, $client->getConnection()->getPort());
- }
-
- /**
- * @dataProvider configProvider
- */
- public function testSearchRequest($config)
- {
- $this->_checkPlugin();
-
- // Creates a new index 'xodoa' and a type 'user' inside this index
- $client = new Client($config);
-
- $index = $client->getIndex('elastica_test1');
- $index->create(array(), true);
-
- $type = $index->getType('user');
-
- // Adds 1 document to the index
- $doc1 = new Document(1,
- array('username' => 'hans', 'test' => array('2', '3', '5'))
- );
- $doc1->setVersion(0);
- $type->addDocument($doc1);
-
- // Adds a list of documents with _bulk upload to the index
- $docs = array();
- $docs[] = new Document(2,
- array('username' => 'john', 'test' => array('1', '3', '6'))
- );
- $docs[] = new Document(3,
- array('username' => 'rolf', 'test' => array('2', '3', '7'))
- );
- $type->addDocuments($docs);
-
- // Refresh index
- $index->refresh();
- $resultSet = $type->search('rolf');
-
- $this->assertEquals(1, $resultSet->getTotalHits());
- }
-
- /**
- * @expectedException \Elastica\Exception\ConnectionException
- */
- public function testInvalidHostRequest()
- {
- $this->_checkPlugin();
-
- $client = new Client(array('host' => 'unknown', 'port' => 9555, 'transport' => 'Thrift'));
- $client->getStatus();
- }
-
- /**
- * @expectedException \Elastica\Exception\ResponseException
- */
- public function testInvalidElasticRequest()
- {
- $this->_checkPlugin();
-
- $connection = new Connection();
- $connection->setHost('localhost');
- $connection->setPort(9500);
- $connection->setTransport('Thrift');
-
- $client = new Client();
- $client->addConnection($connection);
-
- $index = new Index($client, 'missing_index');
- $index->getStatus();
- }
-
- public function configProvider()
- {
- return array(
- array(
- array(
- 'host' => 'localhost',
- 'port' => 9500,
- 'transport' => 'Thrift'
- )
- ),
- array(
- array(
- 'host' => 'localhost',
- 'port' => 9500,
- 'transport' => 'Thrift',
- 'config' => array(
- 'framedTransport' => false,
- 'sendTimeout' => 10000,
- 'recvTimeout' => 20000,
- )
- )
- )
- );
- }
-
- protected function _checkPlugin()
- {
- $nodes = $this->_getClient()->getCluster()->getNodes();
- if (!$nodes[0]->getInfo()->hasPlugin('transport-thrift')) {
- $this->markTestSkipped("transport-thrift plugin not installed.");
- }
- }
-}