PHP Class bandwidthThrottle\tokenBucket\TokenBucketTest

See also: TokenBucket
Author: Markus Malkusch ([email protected])
Inheritance: extends PHPUnit_Framework_TestCase
Afficher le fichier Open project: bandwidth-throttle/token-bucket

Méthodes publiques

Méthode Description
getTokensShouldReturnCapacityAfterWaitingLongerThanRefillPeriod ( ) After waiting longer than the complete refill period on an empty bucket, getTokens() should return the capacity of the bucket.
getTokensShouldReturnCapacityAfterWaitingRefillPeriod ( ) After waiting the complete refill period on an empty bucket, getTokens() should return the capacity of the bucket.
getTokensShouldReturnInitialAmountOnBootstrap ( ) After bootstraping, getTokens() should return the initial amount.
getTokensShouldReturnMoreAfterWaiting ( ) After waiting on an non full bucket, getTokens() should return more.
getTokensShouldReturnRemainingTokensAfterConsumption ( ) After one consumtion, getTokens() should return the initial amount - 1.
getTokensShouldReturnSameAfterConsumingTooMany ( ) After consuming too many, getTokens() should return the same as before.
getTokensShouldReturnZeroTokensAfterConsumingAll ( ) After consuming all, getTokens() should return 0.
provideTestBootstrapWithInitialTokens ( ) : int[][] Returns test cases for testBootstrapWithInitialTokens().
provideTestInvalidCapacity ( ) : array Provides tests cases for testInvalidCapacity().
testBootstrapOnce ( ) Tests bootstrap() is bootstraps not on already bootstrapped storages.
testBootstrapWithInitialTokens ( integer $capacity, integer $tokens ) Tests bootstrapping with tokens.
testCapacity ( ) Test the capacity limit of the bucket
testConsume ( ) Tests comsumption of cumulated tokens.
testConsumeInsufficientDontRemoveTokens ( ) Tests consuming insuficient tokens wont remove any token.
testConsumeSufficientRemoveTokens ( ) Tests consuming tokens.
testConsumeTooMany ( ) Tests consuming more than the capacity.
testDefaultBootstrap ( ) Tests bootstrapping sets to 0 tokens.
testInitialTokensTooMany ( ) Tests bootstrapping with too many tokens.
testInvalidCapacity ( $capacity ) Tests building a token bucket with an invalid caüacity fails.
testWaitCalculation ( ) Tests consume() returns the expected amount of seconds to wait.
testWaitingAddsTokens ( ) Test token rate.

Méthodes protégées

Méthode Description
setUp ( )
tearDown ( )

Method Details

getTokensShouldReturnCapacityAfterWaitingLongerThanRefillPeriod() public méthode

After waiting longer than the complete refill period on an empty bucket, getTokens() should return the capacity of the bucket.

getTokensShouldReturnCapacityAfterWaitingRefillPeriod() public méthode

After waiting the complete refill period on an empty bucket, getTokens() should return the capacity of the bucket.

getTokensShouldReturnInitialAmountOnBootstrap() public méthode

After bootstraping, getTokens() should return the initial amount.

getTokensShouldReturnMoreAfterWaiting() public méthode

After waiting on an non full bucket, getTokens() should return more.

getTokensShouldReturnRemainingTokensAfterConsumption() public méthode

After one consumtion, getTokens() should return the initial amount - 1.

getTokensShouldReturnSameAfterConsumingTooMany() public méthode

After consuming too many, getTokens() should return the same as before.

getTokensShouldReturnZeroTokensAfterConsumingAll() public méthode

After consuming all, getTokens() should return 0.

provideTestBootstrapWithInitialTokens() public méthode

Returns test cases for testBootstrapWithInitialTokens().
public provideTestBootstrapWithInitialTokens ( ) : int[][]
Résultat int[][] Test cases.

provideTestInvalidCapacity() public méthode

Provides tests cases for testInvalidCapacity().
public provideTestInvalidCapacity ( ) : array
Résultat array Test cases.

setUp() protected méthode

protected setUp ( )

tearDown() protected méthode

protected tearDown ( )

testBootstrapOnce() public méthode

Tests bootstrap() is bootstraps not on already bootstrapped storages.
public testBootstrapOnce ( )

testBootstrapWithInitialTokens() public méthode

Tests bootstrapping with tokens.
public testBootstrapWithInitialTokens ( integer $capacity, integer $tokens )
$capacity integer The capacity.
$tokens integer The initial amount of tokens.

testCapacity() public méthode

Test the capacity limit of the bucket
public testCapacity ( )

testConsume() public méthode

Tests comsumption of cumulated tokens.
public testConsume ( )

testConsumeInsufficientDontRemoveTokens() public méthode

Tests consuming insuficient tokens wont remove any token.

testConsumeSufficientRemoveTokens() public méthode

Tests consuming tokens.

testConsumeTooMany() public méthode

Tests consuming more than the capacity.
public testConsumeTooMany ( )

testDefaultBootstrap() public méthode

Tests bootstrapping sets to 0 tokens.

testInitialTokensTooMany() public méthode

Tests bootstrapping with too many tokens.

testInvalidCapacity() public méthode

Tests building a token bucket with an invalid caüacity fails.
public testInvalidCapacity ( $capacity )

testWaitCalculation() public méthode

Tests consume() returns the expected amount of seconds to wait.
public testWaitCalculation ( )

testWaitingAddsTokens() public méthode

Test token rate.