-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jordan Hall
committed
Mar 21, 2018
1 parent
9454079
commit 43d7170
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use RapidWeb\BucketTesting\BucketManager; | ||
use RapidWeb\BucketTesting\WeightedBucket; | ||
use RapidWeb\BucketTesting\Bucket; | ||
|
||
final class ExceptionsTest extends TestCase | ||
{ | ||
|
||
public function testGetRandomBucketWhenNoBucketsAreAdded() | ||
{ | ||
$this->expectException(Exception::class); | ||
(new BucketManager)->getRandomBucket(); | ||
} | ||
|
||
public function testCreatingWeightedBucketWithStringWeight() | ||
{ | ||
$this->expectException(Exception::class); | ||
(new WeightedBucket(new Bucket('https://php.net/')))->setWeight('not a number!'); | ||
} | ||
|
||
public function testCreatingWeightedBucketWithFloatWeight() | ||
{ | ||
$this->expectException(Exception::class); | ||
(new WeightedBucket(new Bucket('https://php.net/')))->setWeight(2.75); | ||
} | ||
|
||
public function testCreatingWeightedBucketWithNegativeWeight() | ||
{ | ||
$this->expectException(Exception::class); | ||
(new WeightedBucket(new Bucket('https://php.net/')))->setWeight(-1); | ||
} | ||
|
||
public function testCreatingWeightedBucketWithZeroWeight() | ||
{ | ||
$this->expectException(Exception::class); | ||
(new WeightedBucket(new Bucket('https://php.net/')))->setWeight(0); | ||
} | ||
|
||
} |