PHP 클래스 bandwidthThrottle\tokenBucket\TokenBucketTest

또한 보기: TokenBucket
저자: Markus Malkusch ([email protected])
상속: extends PHPUnit_Framework_TestCase
파일 보기 프로젝트 열기: bandwidth-throttle/token-bucket

공개 메소드들

메소드 설명
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.