17 $poolCounterConfig = [
18 'class' =>
'PoolCounterMock',
24 $poolCounter = $this->getMockBuilder( PoolCounterAbstractMock::class )
25 ->setConstructorArgs( [ $poolCounterConfig,
'testCounter',
'someKey' ] )
28 ->setMethods( [
'idontexist' ] )
29 ->getMockForAbstractClass();
30 $this->assertInstanceOf( PoolCounter::class, $poolCounter );
34 $poolCounterConfig = [
35 'class' =>
'PoolCounterMock',
42 $poolCounter = $this->getMockBuilder( PoolCounterAbstractMock::class )
43 ->setConstructorArgs( [ $poolCounterConfig,
'testCounter',
'key' ] )
44 ->setMethods( [
'idontexist' ] )
45 ->getMockForAbstractClass();
46 $this->assertInstanceOf( PoolCounter::class, $poolCounter );
50 $poolCounter = $this->getMockBuilder( PoolCounterAbstractMock::class )
53 ->setMethods( [
'idontexist' ] )
54 ->disableOriginalConstructor()
55 ->getMockForAbstractClass();
57 $hashKeyIntoSlots =
new ReflectionMethod( $poolCounter,
'hashKeyIntoSlots' );
58 $hashKeyIntoSlots->setAccessible(
true );
60 $keysWithTwoSlots = $keysWithFiveSlots = [];
61 foreach ( range( 1, 100 )
as $i ) {
62 $keysWithTwoSlots[] = $hashKeyIntoSlots->invoke( $poolCounter,
'test',
'key ' . $i, 2 );
63 $keysWithFiveSlots[] = $hashKeyIntoSlots->invoke( $poolCounter,
'test',
'key ' . $i, 5 );
67 for ( $i = 0; $i <= 1; $i++ ) {
68 $twoSlotKeys[] =
"test:$i";
71 for ( $i = 0; $i <= 4; $i++ ) {
72 $fiveSlotKeys[] =
"test:$i";
80 $hashKeyIntoSlots->invoke( $poolCounter,
'test',
'asdfgh', 1000 ),
81 $hashKeyIntoSlots->invoke( $poolCounter,
'test',
'asdfgh', 1000 )