12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <?php
- namespace Predis\Cluster\Distribution;
- use \PHPUnit_Framework_TestCase as StandardTestCase;
- abstract class DistributionStrategyTestCase extends StandardTestCase
- {
-
- protected abstract function getDistributorInstance();
-
- protected function getNodes(DistributionStrategyInterface $ring, $iterations = 10)
- {
- $nodes = array();
- for ($i = 0; $i < $iterations; $i++) {
- $key = $ring->hash($i * $i);
- $nodes[] = $ring->get($key);
- }
- return $nodes;
- }
-
- public function testEmptyRingThrowsException()
- {
- $this->setExpectedException('Predis\Cluster\Distribution\EmptyRingException');
- $ring = $this->getDistributorInstance();
- $ring->get('nodekey');
- }
-
- public function testRemoveOnEmptyRingDoesNotThrowException()
- {
- $ring = $this->getDistributorInstance();
- $this->assertNull($ring->remove('node'));
- }
- }
|