Skip to content

Commit

Permalink
Fix test codes
Browse files Browse the repository at this point in the history
  • Loading branch information
serima committed Jul 25, 2020
1 parent dd4c728 commit d636404
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions tests/FlexihashTest.php
Expand Up @@ -2,6 +2,7 @@

namespace Flexihash\Tests;

use Flexihash\Exception;
use Flexihash\Flexihash;
use Flexihash\Tests\Hasher\MockHasher;

Expand Down Expand Up @@ -87,26 +88,18 @@ public function testHashSpaceLookupListEmpty()
$this->assertEmpty($hashSpace->lookupList('t1', 2));
}

/**
* @expectedException Flexihash\Exception
* @expectedExceptionMessage No targets exist
*
* @author Dom Morgan <dom@d3r.com>
*/
public function testHashSpaceLookupListNoTargets()
{
$this->expectException('Flexihash\Exception');
$this->expectExceptionMessage('No targets exist');
$hashSpace = new Flexihash();
$hashSpace->lookup('t1');
}

/**
* @expectedException Flexihash\Exception
* @expectedExceptionMessage Invalid count requested
*
* @author Dom Morgan <dom@d3r.com>
*/
public function testHashSpaceLookupListNo()
{
$this->expectException('Flexihash\Exception');
$this->expectExceptionMessage('Invalid count requested');
$hashSpace = new Flexihash();
$hashSpace->lookupList('t1', 0);
}
Expand Down Expand Up @@ -190,7 +183,7 @@ public function testGetMultipleTargets()

$targets = $hashSpace->lookupList('resource', 2);

$this->assertInternalType('array', $targets);
$this->assertIsArray($targets);
$this->assertEquals(count($targets), 2);
$this->assertNotEquals($targets[0], $targets[1]);
}
Expand All @@ -202,7 +195,7 @@ public function testGetMultipleTargetsWithOnlyOneTarget()

$targets = $hashSpace->lookupList('resource', 2);

$this->assertInternalType('array', $targets);
$this->assertIsArray($targets);
$this->assertEquals(count($targets), 1);
$this->assertEquals($targets[0], 'single-target');
}
Expand All @@ -215,7 +208,7 @@ public function testGetMoreTargetsThanExist()

$targets = $hashSpace->lookupList('resource', 4);

$this->assertInternalType('array', $targets);
$this->assertIsArray($targets);
$this->assertEquals(count($targets), 2);
$this->assertNotEquals($targets[0], $targets[1]);
}
Expand Down

0 comments on commit d636404

Please sign in to comment.