diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2015-12-17 09:15:42 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2015-12-17 09:44:51 +0100 |
commit | a1789ddde42033f1b05cc4929491214ee6e79383 (patch) | |
tree | 63615735c4ddffaaabf2428946bb26f90899f7bf /vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTransportTest.php | |
parent | 9e06a62f265e3a2aaabecc598d4bc617e06fa32d (diff) |
Update to MediaWiki 1.26.0
Diffstat (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTransportTest.php')
-rw-r--r-- | vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTransportTest.php | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTransportTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTransportTest.php new file mode 100644 index 00000000..cea3e3ba --- /dev/null +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Transport/NullTransportTest.php @@ -0,0 +1,96 @@ +<?php +namespace Elastica\Test\Transport; + +use Elastica\Connection; +use Elastica\Query; +use Elastica\Request; +use Elastica\Test\Base as BaseTest; +use Elastica\Transport\NullTransport; + +/** + * Elastica Null Transport Test. + * + * @author James Boehmer <james.boehmer@jamesboehmer.com> + */ +class NullTransportTest extends BaseTest +{ + /** + * @group functional + */ + 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' => 'NullTransport')); + $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']); + } + + /** + * @group functional + */ + public function testExec() + { + $request = new Request('/test'); + $params = array('name' => 'ruflin'); + $transport = new NullTransport(); + $response = $transport->exec($request, $params); + + $this->assertInstanceOf('\Elastica\Response', $response); + + $data = $response->getData(); + $this->assertEquals($params, $data['params']); + } + + /** + * @group functional + */ + public function testOldObject() + { + if (version_compare(phpversion(), 7, '>=')) { + self::markTestSkipped('These objects are not supported in PHP 7'); + } + + $request = new Request('/test'); + $params = array('name' => 'ruflin'); + $transport = new \Elastica\Transport\Null(); + $response = $transport->exec($request, $params); + + $this->assertInstanceOf('\Elastica\Response', $response); + + $data = $response->getData(); + $this->assertEquals($params, $data['params']); + } +} |