diff options
Diffstat (limited to 'vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health')
-rw-r--r-- | vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/IndexTest.php | 113 | ||||
-rw-r--r-- | vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/ShardTest.php | 63 |
2 files changed, 176 insertions, 0 deletions
diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/IndexTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/IndexTest.php new file mode 100644 index 00000000..085ac13a --- /dev/null +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/IndexTest.php @@ -0,0 +1,113 @@ +<?php + +namespace Elastica\Test\Cluster\Health; + +use Elastica\Cluster\Health\Index as HealthIndex; +use Elastica\Test\Base as BaseTest; + +class IndexTest extends BaseTest +{ + /** + * @var \Elastica\Cluster\Health\Index + */ + protected $_index; + + public function setUp() + { + $data = array( + "status" => "yellow", + "number_of_shards" => 1, + "number_of_replicas" => 2, + "active_primary_shards" => 3, + "active_shards" => 4, + "relocating_shards" => 5, + "initializing_shards" => 6, + "unassigned_shards" => 7, + "shards" => array( + "0" => array( + "status" => "yellow", + "primary_active" => false, + "active_shards" => 0, + "relocating_shards" => 1, + "initializing_shards" => 0, + "unassigned_shards" => 1 + ), + "1" => array( + "status" => "yellow", + "primary_active" => true, + "active_shards" => 1, + "relocating_shards" => 0, + "initializing_shards" => 0, + "unassigned_shards" => 1 + ), + "2" => array( + "status" => "green", + "primary_active" => true, + "active_shards" => 1, + "relocating_shards" => 0, + "initializing_shards" => 0, + "unassigned_shards" => 0, + ), + ) + ); + + $this->_index = new HealthIndex('test', $data); + } + + public function testGetName() + { + $this->assertEquals('test', $this->_index->getName()); + } + + public function testGetStatus() + { + $this->assertEquals('yellow', $this->_index->getStatus()); + } + + public function testGetNumberOfShards() + { + $this->assertEquals(1, $this->_index->getNumberOfShards()); + } + + public function testGetNumberOfReplicas() + { + $this->assertEquals(2, $this->_index->getNumberOfReplicas()); + } + + public function testGetActivePrimaryShards() + { + $this->assertEquals(3, $this->_index->getActivePrimaryShards()); + } + + public function testGetActiveShards() + { + $this->assertEquals(4, $this->_index->getActiveShards()); + } + + public function testGetRelocatingShards() + { + $this->assertEquals(5, $this->_index->getRelocatingShards()); + } + + public function testGetInitializingShards() + { + $this->assertEquals(6, $this->_index->getInitializingShards()); + } + + public function testGetUnassignedShards() + { + $this->assertEquals(7, $this->_index->getUnassignedShards()); + } + + public function testGetShards() + { + $shards = $this->_index->getShards(); + + $this->assertInternalType('array', $shards); + $this->assertEquals(3, count($shards)); + + foreach ($shards as $shard) { + $this->assertInstanceOf('Elastica\Cluster\Health\Shard', $shard); + } + } +} diff --git a/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/ShardTest.php b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/ShardTest.php new file mode 100644 index 00000000..b63195a0 --- /dev/null +++ b/vendor/ruflin/elastica/test/lib/Elastica/Test/Cluster/Health/ShardTest.php @@ -0,0 +1,63 @@ +<?php + +namespace Elastica\Test\Cluster\Health; + +use Elastica\Cluster\Health\Shard as HealthShard; +use Elastica\Test\Base as BaseTest; + +class ShardTest extends BaseTest +{ + /** + * @var \Elastica\Cluster\Health\Shard + */ + protected $_shard; + + public function setUp() + { + $shardData = array( + 'status' => 'red', + 'primary_active' => true, + 'active_shards' => 1, + 'relocating_shards' => 0, + 'initializing_shards' => 0, + 'unassigned_shards' => 1, + ); + + $this->_shard = new HealthShard(2, $shardData); + } + + public function testGetShardNumber() + { + $this->assertEquals(2, $this->_shard->getShardNumber()); + } + + public function testGetStatus() + { + $this->assertEquals('red', $this->_shard->getStatus()); + } + + public function testisPrimaryActive() + { + $this->assertTrue($this->_shard->isPrimaryActive()); + } + + public function testIsActive() + { + $this->assertTrue($this->_shard->isActive()); + } + + public function testIsRelocating() + { + $this->assertFalse($this->_shard->isRelocating()); + } + + public function testIsInitialized() + { + $this->assertFalse($this->_shard->isInitialized()); + } + + public function testIsUnassigned() + { + $this->assertTrue($this->_shard->isUnassigned()); + } +} |