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/Connection/ConnectionPoolTest.php | |
parent | 9e06a62f265e3a2aaabecc598d4bc617e06fa32d (diff) |
Update to MediaWiki 1.26.0
Diffstat (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/ConnectionPoolTest.php')
-rw-r--r-- | vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/ConnectionPoolTest.php | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/ConnectionPoolTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/ConnectionPoolTest.php new file mode 100644 index 00000000..ee03587a --- /dev/null +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Connection/ConnectionPoolTest.php @@ -0,0 +1,112 @@ +<?php +namespace Elastica\Test\Connection; + +use Elastica\Connection; +use Elastica\Connection\ConnectionPool; +use Elastica\Connection\Strategy\StrategyFactory; +use Elastica\Test\Base as BaseTest; + +/** + * @author chabior + */ +class ConnectionPoolTest extends BaseTest +{ + /** + * @group unit + */ + public function testConstruct() + { + $pool = $this->createPool(); + + $this->assertEquals($this->getConnections(), $pool->getConnections()); + } + + /** + * @group unit + */ + public function testSetConnections() + { + $pool = $this->createPool(); + + $connections = $this->getConnections(5); + + $pool->setConnections($connections); + + $this->assertEquals($connections, $pool->getConnections()); + + $this->assertInstanceOf('Elastica\Connection\ConnectionPool', $pool->setConnections($connections)); + } + + /** + * @group unit + */ + public function testAddConnection() + { + $pool = $this->createPool(); + $pool->setConnections(array()); + + $connections = $this->getConnections(5); + + foreach ($connections as $connection) { + $pool->addConnection($connection); + } + + $this->assertEquals($connections, $pool->getConnections()); + + $this->assertInstanceOf('Elastica\Connection\ConnectionPool', $pool->addConnection($connections[0])); + } + + /** + * @group unit + */ + public function testHasConnection() + { + $pool = $this->createPool(); + + $this->assertTrue($pool->hasConnection()); + } + + /** + * @group unit + */ + public function testFailHasConnections() + { + $pool = $this->createPool(); + + $pool->setConnections(array()); + + $this->assertFalse($pool->hasConnection()); + } + + /** + * @group unit + */ + public function testGetConnection() + { + $pool = $this->createPool(); + + $this->assertInstanceOf('Elastica\Connection', $pool->getConnection()); + } + + protected function getConnections($quantity = 1) + { + $params = array(); + $connections = array(); + + for ($i = 0; $i < $quantity; $i++) { + $connections[] = new Connection($params); + } + + return $connections; + } + + protected function createPool() + { + $connections = $this->getConnections(); + $strategy = StrategyFactory::create('Simple'); + + $pool = new ConnectionPool($connections, $strategy); + + return $pool; + } +} |