Beberlei\Metrics\Tests\Collector\PrometheusTest::testMeasureWhenSetNewVariableWithTags PHP Method

testMeasureWhenSetNewVariableWithTags() public method

    public function testMeasureWhenSetNewVariableWithTags()
    {
        $expectedVariableValue = 123;
        $expectedTagsNames = array('tag1', 'tag2');
        $expectedTagsValues = array('value1', 'value2');
        $gaugeMock = $this->getMockBuilder('\\Prometheus\\Gauge')->disableOriginalConstructor()->getMock();
        $gaugeMock->expects($this->once())->method('set')->with($expectedVariableValue, $expectedTagsValues);
        $this->collectorRegistryMock->expects($this->once())->method('getGauge')->with(self::TEST_NAMESPACE, self::TEST_VARIABLE_NAME)->willThrowException(new MetricNotFoundException());
        $this->collectorRegistryMock->expects($this->once())->method('registerGauge')->with(self::TEST_NAMESPACE, self::TEST_VARIABLE_NAME, '', $expectedTagsNames)->willReturn($gaugeMock);
        $this->collector->setTags(array('tag1' => 'value1', 'tag2' => 'value2'));
        $this->collector->measure(self::TEST_VARIABLE_NAME, $expectedVariableValue);
        $this->collector->flush();
    }