PHP Класс bandwidthThrottle\tokenBucket\TokenBucketTest

См. также: TokenBucket
Автор: Markus Malkusch ([email protected])
Наследование: extends PHPUnit_Framework_TestCase
Показать файл Открыть проект

Открытые методы

Метод Описание
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.

Защищенные методы

Метод Описание
setUp ( )
tearDown ( )

Описание методов

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() публичный Метод

Returns test cases for testBootstrapWithInitialTokens().
public provideTestBootstrapWithInitialTokens ( ) : int[][]
Результат int[][] Test cases.

provideTestInvalidCapacity() публичный Метод

Provides tests cases for testInvalidCapacity().
public provideTestInvalidCapacity ( ) : array
Результат array Test cases.

setUp() защищенный Метод

protected setUp ( )

tearDown() защищенный Метод

protected tearDown ( )

testBootstrapOnce() публичный Метод

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

testBootstrapWithInitialTokens() публичный Метод

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

testCapacity() публичный Метод

Test the capacity limit of the bucket
public testCapacity ( )

testConsume() публичный Метод

Tests comsumption of cumulated tokens.
public testConsume ( )

testConsumeInsufficientDontRemoveTokens() публичный Метод

Tests consuming insuficient tokens wont remove any token.

testConsumeSufficientRemoveTokens() публичный Метод

Tests consuming tokens.

testConsumeTooMany() публичный Метод

Tests consuming more than the capacity.
public testConsumeTooMany ( )

testDefaultBootstrap() публичный Метод

Tests bootstrapping sets to 0 tokens.

testInitialTokensTooMany() публичный Метод

Tests bootstrapping with too many tokens.

testInvalidCapacity() публичный Метод

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

testWaitCalculation() публичный Метод

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

testWaitingAddsTokens() публичный Метод

Test token rate.