From a1789ddde42033f1b05cc4929491214ee6e79383 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 17 Dec 2015 09:15:42 +0100 Subject: Update to MediaWiki 1.26.0 --- .../Test/Connection/Strategy/SimpleTest.php | 113 +++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/SimpleTest.php (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/SimpleTest.php') diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/SimpleTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/SimpleTest.php new file mode 100644 index 00000000..3b6ac89d --- /dev/null +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/Strategy/SimpleTest.php @@ -0,0 +1,113 @@ +_getClient(); + $response = $client->request('/_aliases'); + /* @var $response \Elastica\Response */ + + $this->_checkResponse($response); + + $this->_checkStrategy($client); + } + + /** + * @group functional + * @expectedException \Elastica\Exception\ConnectionException + */ + public function testFailConnection() + { + $config = array('host' => '255.255.255.0', 'timeout' => $this->_timeout); + $client = $this->_getClient($config); + + $this->_checkStrategy($client); + + $client->request('/_aliases'); + } + + /** + * @group functional + */ + public function testWithOneFailConnection() + { + $connections = array( + new Connection(array('host' => '255.255.255.0', 'timeout' => $this->_timeout)), + new Connection(array('host' => $this->_getHost(), 'timeout' => $this->_timeout)), + ); + + $count = 0; + $callback = function ($connection, $exception, $client) use (&$count) { + ++$count; + }; + + $client = $this->_getClient(array(), $callback); + $client->setConnections($connections); + + $response = $client->request('/_aliases'); + /* @var $response Response */ + + $this->_checkResponse($response); + + $this->_checkStrategy($client); + + $this->assertLessThan(count($connections), $count); + } + + /** + * @group functional + */ + public function testWithNoValidConnection() + { + $connections = array( + new Connection(array('host' => '255.255.255.0', 'timeout' => $this->_timeout)), + new Connection(array('host' => '45.45.45.45', 'port' => '80', 'timeout' => $this->_timeout)), + new Connection(array('host' => '10.123.213.123', 'timeout' => $this->_timeout)), + ); + + $count = 0; + $client = $this->_getClient(array(), function () use (&$count) { + ++$count; + }); + + $client->setConnections($connections); + + try { + $client->request('/_aliases'); + $this->fail('Should throw exception as no connection valid'); + } catch (ConnectionException $e) { + $this->assertEquals(count($connections), $count); + } + } + + protected function _checkStrategy($client) + { + $strategy = $client->getConnectionStrategy(); + + $this->assertInstanceOf('Elastica\Connection\Strategy\Simple', $strategy); + } + + protected function _checkResponse($response) + { + $this->assertTrue($response->isOk()); + } +} -- cgit v1.2.3-54-g00ecf