use Psr\Log\AbstractLogger;
use Psr\Log\LoggerInterface;
use Psr\Log\NullLogger;
+use Wikimedia\TestingAccessWrapper;
/**
* @group AuthManager
[ 'type' => 'foo', 'cache' => $cache ]
);
$throttler->setLogger( $logger );
- $throttlerPriv = \TestingAccessWrapper::newFromObject( $throttler );
+ $throttlerPriv = TestingAccessWrapper::newFromObject( $throttler );
$this->assertSame( [ [ 'count' => 123, 'seconds' => 456 ] ], $throttlerPriv->conditions );
$this->assertSame( 'foo', $throttlerPriv->type );
$this->assertSame( $cache, $throttlerPriv->cache );
$throttler = new Throttler( [ [ 'count' => 123, 'seconds' => 456 ] ] );
$throttler->setLogger( new NullLogger() );
- $throttlerPriv = \TestingAccessWrapper::newFromObject( $throttler );
+ $throttlerPriv = TestingAccessWrapper::newFromObject( $throttler );
$this->assertSame( [ [ 'count' => 123, 'seconds' => 456 ] ], $throttlerPriv->conditions );
$this->assertSame( 'custom', $throttlerPriv->type );
$this->assertInstanceOf( BagOStuff::class, $throttlerPriv->cache );
'seconds' => 654 ] ] ] );
$throttler = new Throttler();
$throttler->setLogger( new NullLogger() );
- $throttlerPriv = \TestingAccessWrapper::newFromObject( $throttler );
+ $throttlerPriv = TestingAccessWrapper::newFromObject( $throttler );
$this->assertSame( [ [ 'count' => 321, 'seconds' => 654 ] ], $throttlerPriv->conditions );
$this->assertSame( 'password', $throttlerPriv->type );
$this->assertInstanceOf( BagOStuff::class, $throttlerPriv->cache );
public function testNormalizeThrottleConditions( $condition, $normalized ) {
$throttler = new Throttler( $condition );
$throttler->setLogger( new NullLogger() );
- $throttlerPriv = \TestingAccessWrapper::newFromObject( $throttler );
+ $throttlerPriv = TestingAccessWrapper::newFromObject( $throttler );
$this->assertSame( $normalized, $throttlerPriv->conditions );
}
}
public function testNormalizeThrottleConditions2() {
- $priv = \TestingAccessWrapper::newFromClass( Throttler::class );
+ $priv = TestingAccessWrapper::newFromClass( Throttler::class );
$this->assertSame( [], $priv->normalizeThrottleConditions( null ) );
$this->assertSame( [], $priv->normalizeThrottleConditions( 'bad' ) );
}
}
public function testExpiration() {
- $cache = $this->getMock( HashBagOStuff::class, [ 'add' ] );
+ $cache = $this->getMockBuilder( HashBagOStuff::class )
+ ->setMethods( [ 'add' ] )->getMock();
$throttler = new Throttler( [ [ 'count' => 3, 'seconds' => 10 ] ], [ 'cache' => $cache ] );
$throttler->setLogger( new NullLogger() );