Skip to content
This repository was archived by the owner on Oct 22, 2019. It is now read-only.

Commit 44cccb4

Browse files
martinssipenkoNoelDavies
authored andcommitted
Update phpunit to version 8 (#23)
* Update phpunit to version 8 * fix shield * Require PHPUnit version at least 8.4
1 parent ce813f7 commit 44cccb4

7 files changed

Lines changed: 56 additions & 46 deletions

File tree

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
*.iml
33
/.idea/
44
composer.lock
5-
composer.phar
5+
composer.phar
6+
.phpunit.result.cache

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# A prometheus client library written in PHP
22

3-
[![Build Status](https://travis-ci.org/Jimdo/prometheus_client_php.svg?branch=master)](https://travis-ci.org/Jimdo/prometheus_client_php)
3+
[![CircleCI](https://circleci.com/gh/endclothing/prometheus_client_php/tree/master.svg?style=shield)](https://circleci.com/gh/endclothing/prometheus_client_php/tree/master)
44

55
This library uses Redis or APCu to do the client side aggregation.
66
If using Redis, we recommend to run a local Redis instance next to your PHP workers.
@@ -101,9 +101,9 @@ exponential / geometric buckets.
101101
Eg:
102102
```
103103
Histogram::exponentialBuckets(0.05, 1.5, 10);
104-
```
104+
```
105105

106-
This will start your buckets with a value of 1.5, grow them by a factor of 1.5 per bucket across a set of 10 buckets.
106+
This will start your buckets with a value of 1.5, grow them by a factor of 1.5 per bucket across a set of 10 buckets.
107107

108108
Also look at the [examples](examples).
109109

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"symfony/polyfill-apcu": "^1.6"
2020
},
2121
"require-dev": {
22-
"phpunit/phpunit": "^7.5",
22+
"phpunit/phpunit": "^8.4",
2323
"squizlabs/php_codesniffer": "^3.5"
2424
},
2525
"suggest": {

tests/Test/Prometheus/AbstractCollectorRegistryTest.php

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use Prometheus\RenderTextFormat;
99
use Prometheus\Storage\Adapter;
1010
use Prometheus\Storage\Redis;
11+
use Prometheus\Exception\MetricsRegistrationException;
12+
use Prometheus\Exception\MetricNotFoundException;
1113

1214
abstract class AbstractCollectorRegistryTest extends TestCase
1315
{
@@ -21,7 +23,7 @@ abstract class AbstractCollectorRegistryTest extends TestCase
2123
*/
2224
private $renderer;
2325

24-
public function setUp()
26+
public function setUp(): void
2527
{
2628
$this->configureAdapter();
2729
$this->renderer = new RenderTextFormat();
@@ -204,77 +206,84 @@ public function itShouldIncreaseACounterWithoutNamespace()
204206

205207
/**
206208
* @test
207-
* @expectedException \Prometheus\Exception\MetricsRegistrationException
208209
*/
209210
public function itShouldForbidRegisteringTheSameCounterTwice()
210211
{
211212
$registry = new CollectorRegistry($this->adapter);
212213
$registry->registerCounter('foo', 'metric', 'help');
214+
215+
$this->expectException(MetricsRegistrationException::class);
213216
$registry->registerCounter('foo', 'metric', 'help');
214217
}
215218

216219
/**
217220
* @test
218-
* @expectedException \Prometheus\Exception\MetricsRegistrationException
219221
*/
220222
public function itShouldForbidRegisteringTheSameCounterWithDifferentLabels()
221223
{
222224
$registry = new CollectorRegistry($this->adapter);
223225
$registry->registerCounter('foo', 'metric', 'help', ["foo", "bar"]);
226+
227+
$this->expectException(MetricsRegistrationException::class);
224228
$registry->registerCounter('foo', 'metric', 'help', ["spam", "eggs"]);
225229
}
226230

227231
/**
228232
* @test
229-
* @expectedException \Prometheus\Exception\MetricsRegistrationException
230233
*/
231234
public function itShouldForbidRegisteringTheSameHistogramTwice()
232235
{
233236
$registry = new CollectorRegistry($this->adapter);
234237
$registry->registerHistogram('foo', 'metric', 'help');
238+
239+
$this->expectException(MetricsRegistrationException::class);
235240
$registry->registerHistogram('foo', 'metric', 'help');
236241
}
237242

238243
/**
239244
* @test
240-
* @expectedException \Prometheus\Exception\MetricsRegistrationException
241245
*/
242246
public function itShouldForbidRegisteringTheSameHistogramWithDifferentLabels()
243247
{
244248
$registry = new CollectorRegistry($this->adapter);
245249
$registry->registerCounter('foo', 'metric', 'help', ["foo", "bar"]);
250+
251+
$this->expectException(MetricsRegistrationException::class);
246252
$registry->registerCounter('foo', 'metric', 'help', ["spam", "eggs"]);
247253
}
248254

249255
/**
250256
* @test
251-
* @expectedException \Prometheus\Exception\MetricsRegistrationException
252257
*/
253258
public function itShouldForbidRegisteringTheSameGaugeTwice()
254259
{
255260
$registry = new CollectorRegistry($this->adapter);
256261
$registry->registerGauge('foo', 'metric', 'help');
262+
263+
$this->expectException(MetricsRegistrationException::class);
257264
$registry->registerGauge('foo', 'metric', 'help');
258265
}
259266

260267
/**
261268
* @test
262-
* @expectedException \Prometheus\Exception\MetricsRegistrationException
263269
*/
264270
public function itShouldForbidRegisteringTheSameGaugeWithDifferentLabels()
265271
{
266272
$registry = new CollectorRegistry($this->adapter);
267273
$registry->registerGauge('foo', 'metric', 'help', ["foo", "bar"]);
274+
275+
$this->expectException(MetricsRegistrationException::class);
268276
$registry->registerGauge('foo', 'metric', 'help', ["spam", "eggs"]);
269277
}
270278

271279
/**
272280
* @test
273-
* @expectedException \Prometheus\Exception\MetricNotFoundException
274281
*/
275282
public function itShouldThrowAnExceptionWhenGettingANonExistentMetric()
276283
{
277284
$registry = new CollectorRegistry($this->adapter);
285+
286+
$this->expectException(MetricNotFoundException::class);
278287
$registry->getGauge("not_here", "go_away");
279288
}
280289

tests/Test/Prometheus/AbstractCounterTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ abstract class AbstractCounterTest extends TestCase
1919
*/
2020
public $adapter;
2121

22-
public function setUp()
22+
public function setUp(): void
2323
{
2424
$this->configureAdapter();
2525
}
@@ -127,19 +127,19 @@ public function itShouldIncreaseTheCounterByAnArbitraryInteger()
127127

128128
/**
129129
* @test
130-
* @expectedException InvalidArgumentException
131130
*/
132131
public function itShouldRejectInvalidMetricsNames()
133132
{
133+
$this->expectException(InvalidArgumentException::class);
134134
new Counter($this->adapter, 'test', 'some metric invalid metric', 'help');
135135
}
136136

137137
/**
138138
* @test
139-
* @expectedException InvalidArgumentException
140139
*/
141140
public function itShouldRejectInvalidLabelNames()
142141
{
142+
$this->expectException(InvalidArgumentException::class);
143143
new Counter($this->adapter, 'test', 'some_metric', 'help', ['invalid label']);
144144
}
145145

@@ -156,20 +156,20 @@ public function isShouldAcceptAnySequenceOfBasicLatinCharactersForLabelValues($v
156156
$histogram->inc([$value]);
157157

158158
$metrics = $this->adapter->collect();
159-
self::assertInternalType('array', $metrics);
160-
self::assertCount(1, $metrics);
161-
self::assertContainsOnlyInstancesOf(MetricFamilySamples::class, $metrics);
159+
$this->assertIsArray($metrics);
160+
$this->assertCount(1, $metrics);
161+
$this->assertContainsOnlyInstancesOf(MetricFamilySamples::class, $metrics);
162162

163163
$metric = reset($metrics);
164164
$samples = $metric->getSamples();
165-
self::assertContainsOnlyInstancesOf(Sample::class, $samples);
165+
$this->assertContainsOnlyInstancesOf(Sample::class, $samples);
166166

167167
foreach ($samples as $sample) {
168168
$labels = array_combine(
169169
array_merge($metric->getLabelNames(), $sample->getLabelNames()),
170170
$sample->getLabelValues()
171171
);
172-
self::assertEquals($value, $labels[$label]);
172+
$this->assertEquals($value, $labels[$label]);
173173
}
174174
}
175175

tests/Test/Prometheus/AbstractGaugeTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ abstract class AbstractGaugeTest extends TestCase
1919
*/
2020
public $adapter;
2121

22-
public function setUp()
22+
public function setUp(): void
2323
{
2424
$this->configureAdapter();
2525
}
@@ -295,19 +295,19 @@ public function itShouldOverwriteWhenSettingTwice()
295295

296296
/**
297297
* @test
298-
* @expectedException InvalidArgumentException
299298
*/
300299
public function itShouldRejectInvalidMetricsNames()
301300
{
301+
$this->expectException(InvalidArgumentException::class);
302302
new Gauge($this->adapter, 'test', 'some metric invalid metric', 'help');
303303
}
304304

305305
/**
306306
* @test
307-
* @expectedException InvalidArgumentException
308307
*/
309308
public function itShouldRejectInvalidLabelNames()
310309
{
310+
$this->expectException(InvalidArgumentException::class);
311311
new Gauge($this->adapter, 'test', 'some_metric', 'help', ['invalid label']);
312312
}
313313

@@ -324,20 +324,20 @@ public function isShouldAcceptAnySequenceOfBasicLatinCharactersForLabelValues($v
324324
$histogram->inc([$value]);
325325

326326
$metrics = $this->adapter->collect();
327-
self::assertInternalType('array', $metrics);
328-
self::assertCount(1, $metrics);
329-
self::assertContainsOnlyInstancesOf(MetricFamilySamples::class, $metrics);
327+
$this->assertIsArray($metrics);
328+
$this->assertCount(1, $metrics);
329+
$this->assertContainsOnlyInstancesOf(MetricFamilySamples::class, $metrics);
330330

331331
$metric = reset($metrics);
332332
$samples = $metric->getSamples();
333-
self::assertContainsOnlyInstancesOf(Sample::class, $samples);
333+
$this->assertContainsOnlyInstancesOf(Sample::class, $samples);
334334

335335
foreach ($samples as $sample) {
336336
$labels = array_combine(
337337
array_merge($metric->getLabelNames(), $sample->getLabelNames()),
338338
$sample->getLabelValues()
339339
);
340-
self::assertEquals($value, $labels[$label]);
340+
$this->assertEquals($value, $labels[$label]);
341341
}
342342
}
343343

tests/Test/Prometheus/AbstractHistogramTest.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ abstract class AbstractHistogramTest extends TestCase
1919
*/
2020
public $adapter;
2121

22-
public function setUp()
22+
public function setUp(): void
2323
{
2424
$this->configureAdapter();
2525
}
@@ -374,51 +374,51 @@ public function itShouldProvideDefaultBuckets()
374374

375375
/**
376376
* @test
377-
* @expectedException InvalidArgumentException
378-
* @expectedExceptionMessage Histogram buckets must be in increasing order
379377
*/
380378
public function itShouldThrowAnExceptionWhenTheBucketSizesAreNotIncreasing()
381379
{
380+
$this->expectException(InvalidArgumentException::class);
381+
$this->expectExceptionMessage('Histogram buckets must be in increasing order');
382382
new Histogram($this->adapter, 'test', 'some_metric', 'this is for testing', [], [1, 1]);
383383
}
384384

385385
/**
386386
* @test
387-
* @expectedException InvalidArgumentException
388-
* @expectedExceptionMessage Histogram must have at least one bucket
389387
*/
390388
public function itShouldThrowAnExceptionWhenThereIsLessThanOneBucket()
391389
{
390+
$this->expectException(InvalidArgumentException::class);
391+
$this->expectExceptionMessage('Histogram must have at least one bucket');
392392
new Histogram($this->adapter, 'test', 'some_metric', 'this is for testing', [], []);
393393
}
394394

395395
/**
396396
* @test
397-
* @expectedException InvalidArgumentException
398-
* @expectedExceptionMessage Histogram cannot have a label named
399397
*/
400398
public function itShouldThrowAnExceptionWhenThereIsALabelNamedLe()
401399
{
400+
$this->expectException(InvalidArgumentException::class);
401+
$this->expectExceptionMessage('Histogram cannot have a label named');
402402
new Histogram($this->adapter, 'test', 'some_metric', 'this is for testing', ['le'], [1]);
403403
}
404404

405405
/**
406406
* @test
407-
* @expectedException InvalidArgumentException
408-
* @expectedExceptionMessage Invalid metric name
409407
*/
410408
public function itShouldRejectInvalidMetricsNames()
411409
{
410+
$this->expectException(InvalidArgumentException::class);
411+
$this->expectExceptionMessage('Invalid metric name');
412412
new Histogram($this->adapter, 'test', 'some invalid metric', 'help', [], [1]);
413413
}
414414

415415
/**
416416
* @test
417-
* @expectedException InvalidArgumentException
418-
* @expectedExceptionMessage Invalid label name
419417
*/
420418
public function itShouldRejectInvalidLabelNames()
421419
{
420+
$this->expectException(InvalidArgumentException::class);
421+
$this->expectExceptionMessage('Invalid label name');
422422
new Histogram($this->adapter, 'test', 'some_metric', 'help', ['invalid label'], [1]);
423423
}
424424

@@ -435,20 +435,20 @@ public function isShouldAcceptAnySequenceOfBasicLatinCharactersForLabelValues($v
435435
$histogram->observe(1, [$value]);
436436

437437
$metrics = $this->adapter->collect();
438-
self::assertInternalType('array', $metrics);
439-
self::assertCount(1, $metrics);
440-
self::assertContainsOnlyInstancesOf(MetricFamilySamples::class, $metrics);
438+
$this->assertIsArray($metrics);
439+
$this->assertCount(1, $metrics);
440+
$this->assertContainsOnlyInstancesOf(MetricFamilySamples::class, $metrics);
441441

442442
$metric = reset($metrics);
443443
$samples = $metric->getSamples();
444-
self::assertContainsOnlyInstancesOf(Sample::class, $samples);
444+
$this->assertContainsOnlyInstancesOf(Sample::class, $samples);
445445

446446
foreach ($samples as $sample) {
447447
$labels = array_combine(
448448
array_merge($metric->getLabelNames(), $sample->getLabelNames()),
449449
$sample->getLabelValues()
450450
);
451-
self::assertEquals($value, $labels[$label]);
451+
$this->assertEquals($value, $labels[$label]);
452452
}
453453
}
454454

@@ -480,7 +480,7 @@ public function itShouldBeAbleToGenerateExponentialBucketsGivenSpecificBounds()
480480
9.7309753417969,
481481
];
482482

483-
self::assertEquals($generatedBuckets, $expectedBuckets);
483+
$this->assertEquals($generatedBuckets, $expectedBuckets);
484484
}
485485

486486
/**

0 commit comments

Comments
 (0)