diff --git a/tests/Unit/ExceptionsTest.php b/tests/Unit/ExceptionsTest.php new file mode 100644 index 0000000..5310fdd --- /dev/null +++ b/tests/Unit/ExceptionsTest.php @@ -0,0 +1,41 @@ +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); + } + +}