Merge "rdbms: avoid LoadBalancer::getConnection waste when using $groups"
[lhc/web/wiklou.git] / tests / phpunit / includes / libs / stats / PrefixingStatsdDataFactoryProxyTest.php
1 <?php
2
3 use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface;
4
5 /**
6 * @covers PrefixingStatsdDataFactoryProxy
7 */
8 class PrefixingStatsdDataFactoryProxyTest extends PHPUnit\Framework\TestCase {
9
10 use PHPUnit4And6Compat;
11
12 public function provideMethodNames() {
13 return [
14 [ 'timing' ],
15 [ 'gauge' ],
16 [ 'set' ],
17 [ 'increment' ],
18 [ 'decrement' ],
19 [ 'updateCount' ],
20 [ 'produceStatsdData' ],
21 ];
22 }
23
24 /**
25 * @dataProvider provideMethodNames
26 */
27 public function testPrefixingAndPassthrough( $method ) {
28 /** @var StatsdDataFactoryInterface|PHPUnit_Framework_MockObject_MockObject $innerFactory */
29 $innerFactory = $this->getMock(
30 \Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface::class
31 );
32 $innerFactory->expects( $this->once() )
33 ->method( $method )
34 ->with( 'testprefix.metricname' );
35
36 $proxy = new PrefixingStatsdDataFactoryProxy( $innerFactory, 'testprefix' );
37 // 1,2,3,4 simply makes sure we provide enough parameters, without caring what they are
38 $proxy->$method( 'metricname', 1, 2, 3, 4 );
39 }
40
41 /**
42 * @dataProvider provideMethodNames
43 */
44 public function testPrefixIsTrimmed( $method ) {
45 /** @var StatsdDataFactoryInterface|PHPUnit_Framework_MockObject_MockObject $innerFactory */
46 $innerFactory = $this->getMock(
47 \Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface::class
48 );
49 $innerFactory->expects( $this->once() )
50 ->method( $method )
51 ->with( 'testprefix.metricname' );
52
53 $proxy = new PrefixingStatsdDataFactoryProxy( $innerFactory, 'testprefix...' );
54 // 1,2,3,4 simply makes sure we provide enough parameters, without caring what they are
55 $proxy->$method( 'metricname', 1, 2, 3, 4 );
56 }
57
58 }