summaryrefslogtreecommitdiff
path: root/vendor/liuggio/statsd-php-client/tests
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/liuggio/statsd-php-client/tests')
-rw-r--r--vendor/liuggio/statsd-php-client/tests/Liuggio/StatsdClient/Entity/StatsdDataTest.php27
-rw-r--r--vendor/liuggio/statsd-php-client/tests/Liuggio/StatsdClient/Monolog/Formatter/StatsDFormatterTest.php169
-rw-r--r--vendor/liuggio/statsd-php-client/tests/Liuggio/StatsdClient/Monolog/Handler/StatsDHandlerTest.php89
-rw-r--r--vendor/liuggio/statsd-php-client/tests/Liuggio/StatsdClient/ReadmeTest.php72
-rw-r--r--vendor/liuggio/statsd-php-client/tests/Liuggio/StatsdClient/StatsdClientTest.php228
-rw-r--r--vendor/liuggio/statsd-php-client/tests/Liuggio/StatsdClient/StatsdDataFactoryTest.php97
-rw-r--r--vendor/liuggio/statsd-php-client/tests/bootstrap.php5
7 files changed, 687 insertions, 0 deletions
diff --git a/vendor/liuggio/statsd-php-client/tests/Liuggio/StatsdClient/Entity/StatsdDataTest.php b/vendor/liuggio/statsd-php-client/tests/Liuggio/StatsdClient/Entity/StatsdDataTest.php
new file mode 100644
index 00000000..fad9175c
--- /dev/null
+++ b/vendor/liuggio/statsd-php-client/tests/Liuggio/StatsdClient/Entity/StatsdDataTest.php
@@ -0,0 +1,27 @@
+<?php
+
+namespace Liuggio\StatsdClient\Entity;
+
+use Liuggio\StatsdClient\Entity\StatsdData;
+
+
+class StatsdDataTest extends \PHPUnit_Framework_TestCase
+{
+ public function testGetMessage()
+ {
+ $statsdData = new StatsdData();
+ $statsdData->setKey('key');
+ $statsdData->setValue('value');
+ $statsdData->setMetric('c');
+
+ $this->assertEquals($statsdData->getMessage(), 'key:value|c');
+
+ $statsdData = new StatsdData();
+ $statsdData->setKey('key');
+ $statsdData->setValue(-1);
+ $statsdData->setMetric('c');
+
+ $this->assertEquals($statsdData->getMessage(), 'key:-1|c');
+
+ }
+}
diff --git a/vendor/liuggio/statsd-php-client/tests/Liuggio/StatsdClient/Monolog/Formatter/StatsDFormatterTest.php b/vendor/liuggio/statsd-php-client/tests/Liuggio/StatsdClient/Monolog/Formatter/StatsDFormatterTest.php
new file mode 100644
index 00000000..daf899aa
--- /dev/null
+++ b/vendor/liuggio/statsd-php-client/tests/Liuggio/StatsdClient/Monolog/Formatter/StatsDFormatterTest.php
@@ -0,0 +1,169 @@
+<?php
+
+namespace Liuggio\StatsdClient\Tests\Monolog\Formatter;
+
+use Monolog\Logger;
+use Liuggio\StatsdClient\Monolog\Formatter\StatsDFormatter;
+
+/**
+ * @covers Liuggio\StatsdClient\Monolog\Formatter\StatsDFormatter
+ */
+class StatsDFormatterTest extends \PHPUnit_Framework_TestCase
+{
+ public function testBatchFormat()
+ {
+ $formatter = new StatsDFormatter(null, 2);
+ $message = $formatter->formatBatch(array(
+ array(
+ 'level_name' => 'CRITICAL',
+ 'channel' => 'test',
+ 'message' => 'bar',
+ 'context' => array(),
+ 'datetime' => new \DateTime,
+ 'extra' => array(),
+ ),
+ array(
+ 'level_name' => 'WARNING',
+ 'channel' => 'log',
+ 'message' => 'foo',
+ 'context' => array(),
+ 'datetime' => new \DateTime,
+ 'extra' => array(),
+ ),
+ ));
+
+ $this->assertEquals(array('test.CRITICAL.bar', 'log.WARNING.foo'), $message);
+ }
+
+ public function testDefFormatWithString()
+ {
+ $formatter = new StatsDFormatter(StatsDFormatter::SIMPLE_FORMAT);
+ $message = $formatter->format(array(
+ 'level_name' => 'WARNING',
+ 'channel' => 'log',
+ 'context' => array(),
+ 'message' => 'foo',
+ 'datetime' => new \DateTime,
+ 'extra' => array(),
+ ));
+ $this->assertEquals(array('log.WARNING.foo'), $message);
+ }
+
+ public function testDefFormatWithArrayContext()
+ {
+ $formatter = new StatsDFormatter();
+ $message = $formatter->format(array(
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'message' => 'foo',
+ 'datetime' => new \DateTime,
+ 'extra' => array(),
+ 'context' => array(
+ 'foo' => 'bar',
+ 'baz' => 'qux',
+ )
+ ));
+
+ $assert = array('meh.ERROR.foo',
+ 'meh.ERROR.foo.context.foo.bar',
+ 'meh.ERROR.foo.context.baz.qux');
+
+ $this->assertEquals($assert, $message);
+ }
+
+ public function testDefFormatWithArrayContextAndExtra()
+ {
+ $formatter = new StatsDFormatter();
+ $message = $formatter->format(array(
+ 'level_name' => 'ERROR',
+ 'channel' => 'meh',
+ 'message' => 'foo',
+ 'datetime' => new \DateTime,
+ 'extra' => array('extra'=>'woow'),
+ 'context' => array(
+ 'foo' => 'bar',
+ 'baz' => 'qux',
+ )
+ ));
+
+ $assert = array('meh.ERROR.foo',
+ 'meh.ERROR.foo.context.foo.bar',
+ 'meh.ERROR.foo.context.baz.qux',
+ 'meh.ERROR.foo.extra.extra.woow');
+
+ $this->assertEquals($assert, $message);
+
+ }
+
+ public function testDefLongFormat()
+ {
+ $formatter = new StatsDFormatter();
+ $message = $formatter->format(array(
+ 'level_name' => 'DEBUG',
+ 'channel' => 'doctrine',
+ 'message' => 'INSERT INTO viaggio_calendar (enable, viaggio_id, calendar_id) VALUES (?, ?, ?)',
+ 'datetime' => new \DateTime,
+ 'extra' => array(),
+ 'context' => array(
+ 'foo' => 'bar',
+ 'baz' => 'qux',
+ )
+ ));
+ $this->assertEquals(array("doctrine.DEBUG.INSERT-INTO",
+ "doctrine.DEBUG.INSERT-INTO.context.foo.bar",
+ "doctrine.DEBUG.INSERT-INTO.context.baz.qux"), $message);
+ }
+
+ public function testDefLongFormatWith3WordsNoContextAndNoExtra()
+ {
+ $formatter = new StatsDFormatter(null, false, false, 3);
+ $message = $formatter->format(array(
+ 'level_name' => 'DEBUG',
+ 'channel' => 'doctrine',
+ 'message' => 'INSERT INTO viaggio_calendar (enable, viaggio_id, calendar_id) VALUES (?, ?, ?)',
+ 'datetime' => new \DateTime,
+ 'extra' => array(),
+ 'context' => array(
+ 'foo' => 'bar',
+ 'baz' => 'qux',
+ )
+ ));
+ $this->assertEquals(array("doctrine.DEBUG.INSERT-INTO-viaggio-calendar"), $message);
+ }
+ public function testDefRouteException()
+ {
+ $formatter = new StatsDFormatter();
+ $message = $formatter->format(array(
+ 'level_name' => 'DEBUG',
+ 'channel' => 'doctrine',
+ 'message' => 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException: No route found for "GET /ddd" (uncaught exception) at /xxxx/classes.php line 5062',
+ 'datetime' => new \DateTime,
+ 'extra' => array(),
+ ));
+ $this->assertEquals(array('doctrine.DEBUG.Symfony-Component-HttpKernel-Exception-NotFoundHttpException--No'), $message);
+ }
+
+ public function testDefKernelException()
+ {
+ $formatter = new StatsDFormatter();
+ $message = $formatter->format(array(
+ 'level_name' => 'DEBUG',
+ 'channel' => 'doctrine',
+ 'message' => 'Notified event "kernel.exception" to listener "Symfony\Component\HttpKernel\EventListener\ProfilerListener::onKernelException"',
+ 'datetime' => new \DateTime,
+ 'extra' => array(),
+ 'context' => array(
+ 'foo' => 'bar',
+ 'baz' => 'qux',
+ )
+ ));
+
+ $assert = array('doctrine.DEBUG.Notified-event',
+ 'doctrine.DEBUG.Notified-event.context.foo.bar',
+ 'doctrine.DEBUG.Notified-event.context.baz.qux');
+
+ $this->assertEquals($assert, $message);
+
+
+ }
+}
diff --git a/vendor/liuggio/statsd-php-client/tests/Liuggio/StatsdClient/Monolog/Handler/StatsDHandlerTest.php b/vendor/liuggio/statsd-php-client/tests/Liuggio/StatsdClient/Monolog/Handler/StatsDHandlerTest.php
new file mode 100644
index 00000000..c1b8eb4b
--- /dev/null
+++ b/vendor/liuggio/statsd-php-client/tests/Liuggio/StatsdClient/Monolog/Handler/StatsDHandlerTest.php
@@ -0,0 +1,89 @@
+<?php
+
+namespace Liuggio\StatsdClient\Tests\Monolog\Handler;
+
+use Monolog\Logger;
+use Liuggio\StatsdClient\Monolog\Handler\StatsDHandler;
+
+
+class StatsDHandlerTest extends \PHPUnit_Framework_TestCase
+{
+ /**
+ * @return array Record
+ */
+ protected function getRecord($level = Logger::WARNING, $message = 'test', $context = array())
+ {
+ return array(
+ 'message' => $message,
+ 'context' => $context,
+ 'level' => $level,
+ 'level_name' => Logger::getLevelName($level),
+ 'channel' => 'test',
+ 'datetime' => \DateTime::createFromFormat('U.u', sprintf('%.6F', microtime(true))),
+ 'extra' => array(),
+ );
+ }
+
+ /**
+ * @return array
+ */
+ protected function getMultipleRecords()
+ {
+ return array(
+ $this->getRecord(Logger::DEBUG, 'debug message 1'),
+ $this->getRecord(Logger::DEBUG, 'debug message 2'),
+ $this->getRecord(Logger::INFO, 'information'),
+ $this->getRecord(Logger::WARNING, 'warning'),
+ $this->getRecord(Logger::ERROR, 'error')
+ );
+ }
+
+ /**
+ * @return Monolog\Formatter\FormatterInterface
+ */
+ protected function getIdentityFormatter()
+ {
+ $formatter = $this->getMock('Monolog\\Formatter\\FormatterInterface');
+ $formatter->expects($this->any())
+ ->method('format')
+ ->will($this->returnCallback(function($record) { return $record['message']; }));
+
+ return $formatter;
+ }
+
+
+ protected function setup()
+ {
+ if (!interface_exists('Liuggio\StatsdClient\StatsdClientInterface')) {
+ $this->markTestSkipped('The "liuggio/statsd-php-client" package is not installed');
+ }
+ }
+
+ public function testHandle()
+ {
+ $client = $this->getMock('Liuggio\StatsdClient\StatsdClientInterface');
+ $factory = $this->getMock('Liuggio\StatsdClient\Factory\StatsdDataFactoryInterface');
+
+ $factory->expects($this->any())
+ ->method('increment')
+ ->will($this->returnCallback(function ($input){
+ return sprintf('%s|c|1', $input);
+ }));
+
+ $prefixToAssert = 'prefix';
+ $messageToAssert = 'test-msg';
+
+ $record = $this->getRecord(Logger::WARNING, $messageToAssert, array('data' => new \stdClass, 'foo' => 34));
+
+ $assert = array(sprintf('%s.test.WARNING.%s|c|1',$prefixToAssert, $messageToAssert),
+ sprintf('%s.test.WARNING.%s.context.data.[object] (stdClass: {})|c|1',$prefixToAssert, $messageToAssert),
+ sprintf('%s.test.WARNING.%s.context.foo.34|c|1',$prefixToAssert, $messageToAssert));
+
+ $client->expects($this->once())
+ ->method('send')
+ ->with($assert);
+
+ $handler = new StatsDHandler($client, $factory, $prefixToAssert);
+ $handler->handle($record);
+ }
+} \ No newline at end of file
diff --git a/vendor/liuggio/statsd-php-client/tests/Liuggio/StatsdClient/ReadmeTest.php b/vendor/liuggio/statsd-php-client/tests/Liuggio/StatsdClient/ReadmeTest.php
new file mode 100644
index 00000000..4608a601
--- /dev/null
+++ b/vendor/liuggio/statsd-php-client/tests/Liuggio/StatsdClient/ReadmeTest.php
@@ -0,0 +1,72 @@
+<?php
+
+namespace Liuggio\StatsdClient;
+
+use Liuggio\StatsdClient\StatsdClient;
+use Liuggio\StatsdClient\Factory\StatsdDataFactory;
+//use Liuggio\StatsdClient\Sender\SocketSender;
+
+
+class ReadmeTest extends \PHPUnit_Framework_TestCase
+{
+ public function testFullUsageWithObject() {
+
+ $sender = $this->mockSender();
+ // $sender = new Sender();
+
+ // StatsdClient(SenderInterface $sender, $host = 'udp://localhost', $port = 8126, $reducePacket = true, $fail_silently = true)
+ $client = new StatsdClient($sender);
+ $factory = new StatsdDataFactory('\Liuggio\StatsdClient\Entity\StatsdData');
+
+ // create the data with the factory
+ $data[] = $factory->timing('usageTime', 100);
+ $data[] = $factory->increment('visitor');
+ $data[] = $factory->decrement('click');
+ $data[] = $factory->gauge('gaugor', 333);
+ $data[] = $factory->set('uniques', 765);
+
+ // send the data as array or directly as object
+ $client->send($data);
+ }
+
+
+
+ public function testFullUsageArray() {
+
+ $sender = $this->mockSender();
+ // $sender = new Sender();
+
+ // StatsdClient(SenderInterface $sender, $host = 'localhost', $port = 8126, $protocol='udp', $reducePacket = true, $fail_silently = true)
+ $client = new StatsdClient($sender, $host = 'localhost', $port = 8126, 'udp', $reducePacket = true, $fail_silently = true);
+
+ $data[] ="increment:1|c";
+ $data[] ="set:value|s";
+ $data[] ="gauge:value|g";
+ $data[] = "timing:10|ms";
+ $data[] = "decrement:-1|c";
+ $data[] ="key:1|c";
+
+ // send the data as array or directly as object
+ $client->send($data);
+ }
+
+
+ private function mockSender() {
+ $sender = $this->getMock('\Liuggio\StatsdClient\Sender\SenderInterface', array('open', 'write', 'close'));
+ $sender->expects($this->once())
+ ->method('open')
+ ->will($this->returnValue(true));
+
+ $sender->expects($this->any()) //If you set the reduce = true into the StatsdClient the write will be called once
+ ->method('write')
+ ->will($this->returnCallBack(function($fp, $message) {
+ // echo PHP_EOL . "- " . $message;
+ }));
+
+ $sender->expects($this->once())
+ ->method('close')
+ ->will($this->returnValue(true));
+
+ return $sender;
+ }
+} \ No newline at end of file
diff --git a/vendor/liuggio/statsd-php-client/tests/Liuggio/StatsdClient/StatsdClientTest.php b/vendor/liuggio/statsd-php-client/tests/Liuggio/StatsdClient/StatsdClientTest.php
new file mode 100644
index 00000000..865f1b2d
--- /dev/null
+++ b/vendor/liuggio/statsd-php-client/tests/Liuggio/StatsdClient/StatsdClientTest.php
@@ -0,0 +1,228 @@
+<?php
+
+namespace Liuggio\StatsdClient;
+
+use Liuggio\StatsdClient\StatsdClient;
+use Liuggio\StatsdClient\Entity\StatsdData;
+
+class StatsdClientTest extends \PHPUnit_Framework_TestCase
+{
+
+ public function mockSenderWithAssertionOnWrite($messageToAssert=null) {
+
+ $mock = $this->getMockBuilder('\Liuggio\StatsdClient\Sender\SocketSender') ->disableOriginalConstructor() ->getMock();
+
+ $phpUnit = $this;
+ $mock->expects($this->any())
+ ->method('open')
+ ->will($this->returnValue(true));
+ // if the input is an array expects a call foreach item
+ if (is_array($messageToAssert)) {
+ $index = 0;
+ foreach ($messageToAssert as $oneMessage) {
+ $index++;
+ $mock->expects($this->at($index))
+ ->method('write')
+ ->will($this->returnCallBack(function($fp, $message) use ($phpUnit, $oneMessage) {
+ $phpUnit->assertEquals($message, $oneMessage);
+ }));
+ }
+ } else if (null !== $messageToAssert){
+ // if the input is a string expects only once
+ $mock->expects($this->once())
+ ->method('write')
+ ->will($this->returnCallBack(function($fp, $message) use ($phpUnit, $messageToAssert) {
+ $phpUnit->assertEquals($message, $messageToAssert);
+ }));
+ }
+ return $mock;
+ }
+
+ public function mockStatsdClientWithAssertionOnWrite($messageToAssert) {
+
+ $mockSender = $this->mockSenderWithAssertionOnWrite($messageToAssert);
+
+ return new StatsdClient($mockSender, false, false);
+ }
+
+ public function mockFactory() {
+
+ $mock = $this->getMock('\Liuggio\StatsdClient\Factory\StatsdDataFactory', array('timing'));
+
+ $statsData = new StatsdData();
+ $statsData->setKey('key');
+ $statsData->setValue('1');
+ $statsData->setMetric('ms');
+
+ $phpUnit = $this;
+ $mock->expects($this->any())
+ ->method('timing')
+ ->will($this->returnValue($statsData));
+
+ return $mock;
+ }
+
+ public static function provider()
+ {
+ /**
+ * First
+ */
+ $statsData0 = new StatsdData();
+ $statsData0->setKey('keyTiming');
+ $statsData0->setValue('1');
+ $statsData0->setMetric('ms');
+ /**
+ * Second
+ */
+ $stats1 = array();
+ $statsData1 = new StatsdData();
+ $statsData1->setKey('keyTiming');
+ $statsData1->setValue('1');
+ $statsData1->setMetric('ms');
+ $stats1[] = $statsData1;
+
+ $statsData1 = new StatsdData();
+ $statsData1->setKey('keyIncrement');
+ $statsData1->setValue('1');
+ $statsData1->setMetric('c');
+ $stats1[] = $statsData1;
+
+ return array(
+ array($statsData0, "keyTiming:1|ms"),
+ array($stats1, array("keyTiming:1|ms", "keyIncrement:1|c")),
+ );
+ }
+ public static function providerSend()
+ {
+ return array(
+ array(array('gauge:value|g'), 'gauge:value|g'),
+ array(array("keyTiming:1|ms", "keyIncrement:1|c"), array("keyTiming:1|ms", "keyIncrement:1|c")),
+ );
+ }
+
+ /**
+ * @dataProvider provider
+ */
+ public function testPrepareAndSend($statsdInput, $assertion) {
+
+ $statsdMock = $this->mockStatsdClientWithAssertionOnWrite($assertion);
+ $statsdMock->send($statsdInput);
+ }
+
+ /**
+ * @dataProvider providerSend
+ */
+ public function testSend($array, $assertion) {
+
+ $statsdMock = $this->mockStatsdClientWithAssertionOnWrite($assertion);
+ $statsdMock->send($array);
+ }
+
+ public function testReduceCount()
+ {
+ $statsd = $this->mockStatsdClientWithAssertionOnWrite(null);
+
+ $entity0 = new StatsdData();
+ $entity0->setKey('key1');
+ $entity0->setValue('1');
+ $entity0->setMetric('c');
+ $array0[] = $entity0;
+
+ $entity0 = new StatsdData();
+ $entity0->setKey('key2');
+ $entity0->setValue('2');
+ $entity0->setMetric('ms');
+ $array0[] = $entity0;
+
+ $reducedMessage = array('key1:1|c' . PHP_EOL . 'key2:2|ms');
+
+ $this->assertEquals($statsd->reduceCount($array0), $reducedMessage);
+
+ }
+
+ public function testReduceWithString()
+ {
+ $statsd = $this->mockStatsdClientWithAssertionOnWrite(null);
+
+ $msg = 'A3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789:';
+ $msg .= '123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789|c';
+ $array0[] = $msg;
+
+ $msg = 'B3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789:';
+ $msg .= '123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789|c';
+ $array0[] = $msg;
+ $reduced = $statsd->reduceCount($array0);
+ $combined = $array0[0] . PHP_EOL . $array0[1];
+ $this->assertEquals($combined, $reduced[0]);
+ }
+
+
+ public function testReduceWithMaxUdpPacketSplitInTwoPacket()
+ {
+ $statsd = $this->mockStatsdClientWithAssertionOnWrite(null);
+
+ $msg = 'A3456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789'; //1
+ $msg .= '123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 '; //2
+ $msg .= '123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 '; //3
+ $msg .= '123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 '; //4
+ $msg .= '123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789|c'; //500
+ $array0[] = $msg;
+
+ $msg = 'Bkey:';
+ $msg .= '123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789|c';
+ $array0[] = $msg;
+
+ $reduced = $statsd->reduceCount($array0);
+
+ $this->assertEquals($array0[0], $reduced[0]);
+ $this->assertEquals($array0[1], $reduced[1]);
+ }
+
+
+
+ public function testMultiplePacketsWithReducing()
+ {
+
+ $msg = 'A23456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789';
+ $array0[] = $msg;
+ $array0[] = $msg;
+ $array0[] = $msg;
+ $array0[] = $msg;
+ $array0[] = $msg;
+ $array0[] = $msg;
+ $array0[] = $msg;
+ $array0[] = $msg;
+
+ $total = count($array0) * strlen($msg);
+
+ $reducedPacketsAssertion = (int) ceil($total / StatsdClientInterface::MAX_UDP_SIZE_STR);
+
+
+ $mockSender = $this->mockSenderWithAssertionOnWrite();
+ $statsd = new StatsdClient($mockSender, true, false);
+ $reduced = $statsd->reduceCount($array0);
+
+ $this->assertEquals($reducedPacketsAssertion, count($reduced));
+ }
+
+ public function testSampleRate()
+ {
+ $senderMock = $this->getMock('Liuggio\StatsdClient\Sender\SenderInterface');
+ $senderMock
+ ->expects($this->once())
+ ->method('open')
+ ->will($this->returnValue(true))
+ ;
+ $senderMock
+ ->expects($this->once())
+ ->method('write')
+ ->with($this->anything(), 'foo|@0.2')
+ ;
+ $client = new StatsdClient($senderMock, false, false);
+
+ $client->send(
+ 'foo',
+ 0.2
+ );
+ }
+}
diff --git a/vendor/liuggio/statsd-php-client/tests/Liuggio/StatsdClient/StatsdDataFactoryTest.php b/vendor/liuggio/statsd-php-client/tests/Liuggio/StatsdClient/StatsdDataFactoryTest.php
new file mode 100644
index 00000000..144f629c
--- /dev/null
+++ b/vendor/liuggio/statsd-php-client/tests/Liuggio/StatsdClient/StatsdDataFactoryTest.php
@@ -0,0 +1,97 @@
+<?php
+
+namespace Liuggio\StatsdClient\Factory;
+
+use Liuggio\StatsdClient\Factory\StatsdDataFactory;
+
+class StatsDataFactoryTest extends \PHPUnit_Framework_TestCase
+{
+ private $statsDataFactory;
+
+ public function setUp()
+ {
+ $this->statsDataFactory = new StatsdDataFactory('\Liuggio\StatsdClient\Entity\StatsdData');
+ }
+
+ public function testProduceStatsdData()
+ {
+ $key = 'key';
+ $value='val';
+
+ $obj = $this->statsDataFactory->produceStatsdData($key, $value);
+ $this->assertEquals($key, $obj->getKey());
+ $this->assertEquals($value, $obj->getValue());
+ }
+
+ public function testTiming()
+ {
+ $key = 'key';
+ $value = microtime();
+ $valueFloat = (string) floatval($value);
+
+ $obj = $this->statsDataFactory->timing($key, $value);
+ $this->assertEquals($key, $obj->getKey());
+ $this->assertContains($valueFloat, $obj->getValue());
+ $this->assertContains('ms', $obj->getMetric());
+ }
+
+ public function testProduceStatsdDataDecrement()
+ {
+ $key = 'key';
+ $value = -1;
+ $stringValue = intval($value);
+
+ $obj = $this->statsDataFactory->produceStatsdData($key, $value);
+ $this->assertEquals($key, $obj->getKey());
+ $this->assertEquals($stringValue, $obj->getValue());
+ $this->assertEquals('c', $obj->getMetric());
+ }
+
+ public function testGauge()
+ {
+ $key = 'key';
+ $value = 1000;
+ $stringValue = (string) intval($value);
+
+ $obj = $this->statsDataFactory->gauge($key, $value);
+ $this->assertEquals($key, $obj->getKey());
+ $this->assertEquals($stringValue, $obj->getValue());
+ $this->assertEquals('g', $obj->getMetric());
+ }
+
+ public function testDecrement()
+ {
+ $key = 'key';
+ $value = -1;
+ $stringValue = intval($value);
+
+ $obj = $this->statsDataFactory->decrement($key);
+ $this->assertEquals($key, $obj->getKey());
+ $this->assertEquals($stringValue, $obj->getValue());
+ $this->assertEquals('c', $obj->getMetric());
+ }
+
+ public function testcreateStatsdDataIncrement()
+ {
+ $key = 'key';
+ $value = 1;
+ $stringValue = intval($value);
+
+ $obj = $this->statsDataFactory->increment($key);
+ $this->assertEquals($key, $obj->getKey());
+ $this->assertEquals($stringValue, $obj->getValue());
+ $this->assertEquals('c', $obj->getMetric());
+ }
+
+ public function testCreateStatsdDataUpdateCount()
+ {
+ $key = 'key';
+ $value = 10;
+ $stringValue = intval($value);
+
+ $obj = $this->statsDataFactory->updateCount($key, 10);
+ $this->assertEquals($key, $obj->getKey());
+ $this->assertEquals($stringValue, $obj->getValue());
+ $this->assertEquals('c', $obj->getMetric());
+ }
+}
diff --git a/vendor/liuggio/statsd-php-client/tests/bootstrap.php b/vendor/liuggio/statsd-php-client/tests/bootstrap.php
new file mode 100644
index 00000000..0594a467
--- /dev/null
+++ b/vendor/liuggio/statsd-php-client/tests/bootstrap.php
@@ -0,0 +1,5 @@
+<?php
+
+
+$loader = require_once __DIR__ . "/../vendor/autoload.php";
+$loader->add('Liuggio\\', __DIR__); \ No newline at end of file