3 use Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface
;
6 * @covers PrefixingStatsdDataFactoryProxy
8 class PrefixingStatsdDataFactoryProxyTest
extends PHPUnit\Framework\TestCase
{
10 use PHPUnit4And6Compat
;
12 public function provideMethodNames() {
20 [ 'produceStatsdData' ],
25 * @dataProvider provideMethodNames
27 public function testPrefixingAndPassthrough( $method ) {
28 /** @var StatsdDataFactoryInterface|PHPUnit_Framework_MockObject_MockObject $innerFactory */
29 $innerFactory = $this->getMock(
30 \Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface
::class
32 $innerFactory->expects( $this->once() )
34 ->with( 'testprefix.metricname' );
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 );
42 * @dataProvider provideMethodNames
44 public function testPrefixIsTrimmed( $method ) {
45 /** @var StatsdDataFactoryInterface|PHPUnit_Framework_MockObject_MockObject $innerFactory */
46 $innerFactory = $this->getMock(
47 \Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface
::class
49 $innerFactory->expects( $this->once() )
51 ->with( 'testprefix.metricname' );
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 );