diff options
author | wiki <wiki@proton.parabola.nu> | 2016-08-02 21:10:30 +0100 |
---|---|---|
committer | wiki <wiki@proton.parabola.nu> | 2016-08-02 21:10:30 +0100 |
commit | d386934962c15a79703588812dc5815f32d70cbf (patch) | |
tree | 1251b086744a5305855c107eacbcf3e96005ab6e /StatsdDataFactoryTest.php | |
parent | a5f917bbc55e295896b8084f6657eb8b6abaf8a8 (diff) |
files were sitting here on productionemulatorman/master
Diffstat (limited to 'StatsdDataFactoryTest.php')
-rw-r--r-- | StatsdDataFactoryTest.php | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/StatsdDataFactoryTest.php b/StatsdDataFactoryTest.php new file mode 100644 index 00000000..144f629c --- /dev/null +++ b/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()); + } +} |