Skip to content
Permalink
Browse files

Add missing test on MetricFamilySamples class

  • Loading branch information...
LeSuisse committed Jun 3, 2019
1 parent 47a08fc commit 16ac060323a55e1f04402c5ca7177d1a6e35849a
Showing with 39 additions and 1 deletion.
  1. +1 −1 src/Prometheus/MetricFamilySamples.php
  2. +38 −0 tests/unit/Prometheus/MetricFamilySamplesTest.php
@@ -4,7 +4,7 @@
namespace Prometheus;
class MetricFamilySamples
final class MetricFamilySamples
{
/** @var string */
private $name;
@@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
namespace Test\Prometheus;
use PHPUnit\Framework\TestCase;
use Prometheus\MetricFamilySamples;
use Prometheus\Sample;
/**
* @covers Prometheus\MetricFamilySamples
*/
final class MetricFamilySamplesTest extends TestCase
{
public function testMetricFamilySamplesHoldValuesWithoutModification() : void
{
$name = 'name';
$type = 'type';
$help = 'help';
$labelNames = ['labelA', 'labelB'];
$samples = [new Sample('nameA', 1, [], []), new Sample('nameB', 2, [], [])];
$metricFamilySamples = new MetricFamilySamples($name, $type, $help, $labelNames, $samples);
$this->assertSame($name, $metricFamilySamples->getName());
$this->assertSame($type, $metricFamilySamples->getType());
$this->assertSame($help, $metricFamilySamples->getHelp());
$this->assertSame($samples, $metricFamilySamples->getSamples());
$this->assertSame($labelNames, $metricFamilySamples->getLabelNames());
$this->assertTrue($metricFamilySamples->hasLabelNames());
}
public function testMetricFamilySamplesDetectWhenNoLabelNamesAreGiven() : void
{
$metricFamilySamples = new MetricFamilySamples('name', 'type', 'help', [], []);
$this->assertFalse($metricFamilySamples->hasLabelNames());
}
}

0 comments on commit 16ac060

Please sign in to comment.
You can’t perform that action at this time.