1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace Predis\Cluster\Distributor;
- use PredisTestCase;
- abstract class PredisDistributorTestCase extends PredisTestCase
- {
-
- abstract protected function getDistributorInstance();
-
- protected function getNodes(DistributorInterface $distributor, $iterations = 10)
- {
- $nodes = array();
- for ($i = 0; $i < $iterations; ++$i) {
- $hash = $distributor->hash($i * $i);
- $nodes[] = $distributor->getByHash($hash);
- }
- return $nodes;
- }
-
- protected function getSampleDistribution(array $nodes)
- {
- $distributor = $this->getDistributorInstance();
- foreach ($nodes as $node) {
- $distributor->add($node);
- }
- return $distributor;
- }
-
- public function testEmptyRingThrowsException()
- {
- $this->setExpectedException('Predis\Cluster\Distributor\EmptyRingException');
- $distributor = $this->getDistributorInstance();
- $distributor->getByHash('nodehash');
- }
-
- public function testRemoveOnEmptyRingDoesNotThrowException()
- {
- $distributor = $this->getDistributorInstance();
- $this->assertNull($distributor->remove('node'));
- }
- }
|