MediaWiki REL1_32
PrefixingStatsdDataFactoryProxyTest.php
Go to the documentation of this file.
1<?php
2
3use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface;
4
8class 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
27 public function testPrefixingAndPassthrough( $method ) {
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
44 public function testPrefixIsTrimmed( $method ) {
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}
Proxy to prefix metric keys sent to a StatsdDataFactoryInterface.