Skip to content

Commit

Permalink
Exceptions unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan Hall committed Mar 21, 2018
1 parent 9454079 commit 43d7170
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/Unit/ExceptionsTest.php
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);
}

}

0 comments on commit 43d7170

Please sign in to comment.