Skip to content
This repository was archived by the owner on Aug 11, 2025. It is now read-only.

Commit 42eb0e5

Browse files
authored
Merge pull request #87 from piotrooo/features/update-php
New php versions
2 parents 1edd0a9 + e90cb03 commit 42eb0e5

File tree

9 files changed

+97
-87
lines changed

9 files changed

+97
-87
lines changed

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
language: php
22

33
php:
4-
- '5.6'
5-
- '7.0'
64
- '7.1'
75
- '7.2'
6+
- '7.3'
87

98
cache:
109
directories:

composer.json

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
{
2-
"name": "opentracing/opentracing",
3-
"type": "library",
4-
"description": "OpenTracing API for PHP",
5-
"license": "Apache-2.0",
6-
"authors": [
7-
{
8-
"name": "José Carlos Chávez",
9-
"email": "[email protected]"
10-
}
11-
],
12-
"require": {
13-
"php": "^5.6 || ^7.0"
14-
},
15-
"require-dev": {
16-
"phpunit/phpunit": "~5.7.19",
17-
"squizlabs/php_codesniffer": "3.*"
18-
},
19-
"config": {
20-
"sort-packages": true
21-
},
22-
"autoload": {
23-
"psr-4": {
24-
"OpenTracing\\": "./src/OpenTracing/"
25-
},
26-
"files": [
27-
"./src/OpenTracing/Tags.php",
28-
"./src/OpenTracing/Formats.php"
29-
]
30-
},
31-
"autoload-dev": {
32-
"psr-4": {
33-
"OpenTracing\\Tests\\": "./tests/OpenTracing"
34-
}
2+
"name": "opentracing/opentracing",
3+
"type": "library",
4+
"description": "OpenTracing API for PHP",
5+
"license": "Apache-2.0",
6+
"minimum-stability": "stable",
7+
"authors": [
8+
{
9+
"name": "José Carlos Chávez",
10+
"email": "[email protected]"
11+
}
12+
],
13+
"require": {
14+
"php": "^7.1"
15+
},
16+
"require-dev": {
17+
"phpunit/phpunit": "~7.5.8",
18+
"squizlabs/php_codesniffer": "3.*"
19+
},
20+
"config": {
21+
"sort-packages": true
22+
},
23+
"autoload": {
24+
"psr-4": {
25+
"OpenTracing\\": "src/OpenTracing/"
3526
},
36-
"minimum-stability": "stable",
37-
"scripts": {
38-
"fix-lint": "phpcbf --standard=ZEND --standard=PSR2 --ignore=*/vendor/* ./",
39-
"lint": "phpcs --standard=ZEND --standard=PSR2 --ignore=*/vendor/* ./",
40-
"test": "phpunit tests"
27+
"files": [
28+
"src/OpenTracing/Tags.php",
29+
"src/OpenTracing/Formats.php"
30+
]
31+
},
32+
"autoload-dev": {
33+
"psr-4": {
34+
"OpenTracing\\Tests\\": "tests/OpenTracing"
4135
}
36+
},
37+
"scripts": {
38+
"fix-lint": "phpcbf --standard=ZEND --standard=PSR2 --ignore=*/vendor/* ./",
39+
"lint": "phpcs --standard=ZEND --standard=PSR2 --ignore=*/vendor/* ./",
40+
"test": "phpunit tests"
41+
}
4242
}

phpunit.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<phpunit
22
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/7.5/phpunit.xsd"
44
backupGlobals="true"
55
backupStaticAttributes="false"
66
bootstrap="./vendor/autoload.php"
@@ -11,16 +11,16 @@
1111
convertWarningsToExceptions="true"
1212
forceCoversAnnotation="false"
1313
mapTestClassNameToCoveredClassName="false"
14-
printerClass="PHPUnit_TextUI_ResultPrinter"
14+
printerClass="PHPUnit\TextUI\ResultPrinter"
1515
processIsolation="false"
1616
stopOnError="false"
1717
stopOnFailure="false"
1818
stopOnIncomplete="false"
1919
stopOnSkipped="false"
2020
stopOnRisky="false"
21-
testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader"
21+
testSuiteLoaderClass="PHPUnit\Runner\StandardTestSuiteLoader"
2222
timeoutForSmallTests="1"
2323
timeoutForMediumTests="10"
2424
timeoutForLargeTests="60"
2525
verbose="false">
26-
</phpunit>
26+
</phpunit>

tests/OpenTracing/Mock/MockScopeManagerTest.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@
44

55
use OpenTracing\Mock\MockScopeManager;
66
use OpenTracing\Mock\MockTracer;
7-
use PHPUnit_Framework_TestCase;
7+
use PHPUnit\Framework\TestCase;
88

9-
final class MockScopeManagerTest extends PHPUnit_Framework_TestCase
9+
final class MockScopeManagerTest extends TestCase
1010
{
11-
const OPERATION_NAME = 'test_name';
11+
private const OPERATION_NAME = 'test_name';
1212

1313
public function testGetActiveFailsWithNoActiveSpans()
1414
{
1515
$scopeManager = new MockScopeManager();
16+
1617
$this->assertNull($scopeManager->getActive());
1718
}
1819

@@ -22,6 +23,7 @@ public function testActivateSuccess()
2223
$span = $tracer->startSpan(self::OPERATION_NAME);
2324
$scopeManager = new MockScopeManager();
2425
$scopeManager->activate($span);
26+
2527
$this->assertSame($span, $scopeManager->getActive()->getSpan());
2628
}
2729

@@ -30,6 +32,7 @@ public function testGetScopeReturnsNull()
3032
$tracer = new MockTracer();
3133
$tracer->startSpan(self::OPERATION_NAME);
3234
$scopeManager = new MockScopeManager();
35+
3336
$this->assertNull($scopeManager->getActive());
3437
}
3538

@@ -40,6 +43,7 @@ public function testGetScopeSuccess()
4043
$scopeManager = new MockScopeManager();
4144
$scopeManager->activate($span);
4245
$scope = $scopeManager->getActive();
46+
4347
$this->assertSame($span, $scope->getSpan());
4448
}
4549

@@ -51,6 +55,7 @@ public function testDeactivateSuccess()
5155
$scopeManager->activate($span);
5256
$scope = $scopeManager->getActive();
5357
$scopeManager->deactivate($scope);
58+
5459
$this->assertNull($scopeManager->getActive());
5560
}
5661
}

tests/OpenTracing/Mock/MockSpanContextTest.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
33
namespace OpenTracing\Mock\Tests;
44

55
use OpenTracing\Mock\MockSpanContext;
6-
use PHPUnit_Framework_TestCase;
6+
use PHPUnit\Framework\TestCase;
77

8-
final class MockSpanContextTest extends PHPUnit_Framework_TestCase
8+
final class MockSpanContextTest extends TestCase
99
{
10-
const TRACE_ID = 'test_trace_id';
11-
const SPAN_ID = 'test_span_id';
12-
const IS_SAMPLED = true;
13-
const BAGGAGE_ITEM_KEY = 'test_key';
14-
const BAGGAGE_ITEM_VALUE = 'test_value';
10+
private const TRACE_ID = 'test_trace_id';
11+
private const SPAN_ID = 'test_span_id';
12+
private const IS_SAMPLED = true;
13+
private const BAGGAGE_ITEM_KEY = 'test_key';
14+
private const BAGGAGE_ITEM_VALUE = 'test_value';
1515

1616
public function testCreateAsRootSuccess()
1717
{
1818
$parentContext = MockSpanContext::createAsRoot();
1919
$childContext = MockSpanContext::createAsChildOf($parentContext);
20+
2021
$this->assertEquals($parentContext->getTraceId(), $childContext->getTraceId());
2122
}
2223

tests/OpenTracing/Mock/MockSpanTest.php

Lines changed: 12 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,41 +2,34 @@
22

33
namespace OpenTracing\Mock\Tests;
44

5-
use OpenTracing\NoopScopeManager;
65
use OpenTracing\Mock\MockSpan;
76
use OpenTracing\Mock\MockSpanContext;
8-
use PHPUnit_Framework_TestCase;
7+
use PHPUnit\Framework\TestCase;
98

109
/**
1110
* @covers MockSpan
1211
*/
13-
final class MockSpanTest extends PHPUnit_Framework_TestCase
12+
final class MockSpanTest extends TestCase
1413
{
15-
const OPERATION_NAME = 'test';
16-
const DURATION = 10;
17-
const TAG_KEY = 'test_key';
18-
const TAG_VALUE = 'test_value';
19-
const LOG_FIELD = 'test_log';
14+
private const OPERATION_NAME = 'test';
15+
private const DURATION = 10;
16+
private const TAG_KEY = 'test_key';
17+
private const TAG_VALUE = 'test_value';
18+
private const LOG_FIELD = 'test_log';
2019

2120
public function testCreateSpanSuccess()
2221
{
2322
$startTime = time();
24-
$span = new MockSpan(
25-
self::OPERATION_NAME,
26-
MockSpanContext::createAsRoot(),
27-
$startTime
28-
);
23+
$span = new MockSpan(self::OPERATION_NAME, MockSpanContext::createAsRoot(), $startTime);
24+
2925
$this->assertEquals($startTime, $span->getStartTime());
3026
$this->assertEmpty($span->getTags());
3127
$this->assertEmpty($span->getLogs());
3228
}
3329

3430
public function testAddTagsAndLogsToSpanSuccess()
3531
{
36-
$span = new MockSpan(
37-
self::OPERATION_NAME,
38-
MockSpanContext::createAsRoot()
39-
);
32+
$span = new MockSpan(self::OPERATION_NAME, MockSpanContext::createAsRoot());
4033

4134
$span->setTag(self::TAG_KEY, self::TAG_VALUE);
4235
$span->log([self::LOG_FIELD]);
@@ -48,12 +41,9 @@ public function testAddTagsAndLogsToSpanSuccess()
4841
public function testSpanIsFinished()
4942
{
5043
$startTime = time();
51-
$span = new MockSpan(
52-
self::OPERATION_NAME,
53-
MockSpanContext::createAsRoot(),
54-
$startTime
55-
);
44+
$span = new MockSpan(self::OPERATION_NAME, MockSpanContext::createAsRoot(), $startTime);
5645
$span->finish($startTime + self::DURATION);
46+
5747
$this->assertTrue($span->isFinished());
5848
$this->assertEquals(self::DURATION, $span->getDuration());
5949
}

tests/OpenTracing/Mock/MockTracerTest.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,23 @@
55
use OpenTracing\Exceptions\UnsupportedFormat;
66
use OpenTracing\Mock\MockTracer;
77
use OpenTracing\NoopSpan;
8-
use PHPUnit_Framework_TestCase;
8+
use OpenTracing\Span;
9+
use PHPUnit\Framework\TestCase;
910

1011
/**
1112
* @covers MockTracer
1213
*/
13-
final class MockTracerTest extends PHPUnit_Framework_TestCase
14+
final class MockTracerTest extends TestCase
1415
{
15-
const OPERATION_NAME = 'test_name';
16-
const FORMAT = 'test_format';
16+
private const OPERATION_NAME = 'test_name';
17+
private const FORMAT = 'test_format';
1718

1819
public function testStartActiveSpanSuccess()
1920
{
2021
$tracer = new MockTracer();
2122
$scope = $tracer->startActiveSpan(self::OPERATION_NAME);
2223
$activeSpan = $tracer->getActiveSpan();
24+
2325
$this->assertEquals($scope->getSpan(), $activeSpan);
2426
}
2527

@@ -28,6 +30,7 @@ public function testStartSpanSuccess()
2830
$tracer = new MockTracer();
2931
$tracer->startSpan(self::OPERATION_NAME);
3032
$activeSpan = $tracer->getActiveSpan();
33+
3134
$this->assertNull($activeSpan);
3235
}
3336

@@ -36,6 +39,7 @@ public function testInjectWithNoInjectorsFails()
3639
$tracer = new MockTracer();
3740
$span = $tracer->startSpan(self::OPERATION_NAME);
3841
$carrier = [];
42+
3943
$this->expectException(UnsupportedFormat::class);
4044
$tracer->inject($span->getContext(), self::FORMAT, $carrier);
4145
}
@@ -63,6 +67,7 @@ public function testExtractWithNoExtractorsFails()
6367
{
6468
$tracer = new MockTracer();
6569
$carrier = [];
70+
6671
$this->expectException(UnsupportedFormat::class);
6772
$tracer->extract(self::FORMAT, $carrier);
6873
}
@@ -82,15 +87,20 @@ public function testExtractSuccess()
8287
'TRACE_ID' => 'trace_id'
8388
];
8489

85-
$tracer->extract(self::FORMAT, $carrier);
90+
$spanContext = $tracer->extract(self::FORMAT, $carrier);
91+
92+
$this->assertInstanceOf(Span::class, $spanContext);
8693
}
8794

8895
public function testFlushSuccess()
8996
{
9097
$tracer = new MockTracer();
9198
$tracer->startSpan(self::OPERATION_NAME);
99+
92100
$this->assertCount(1, $tracer->getSpans());
101+
93102
$tracer->flush();
103+
94104
$this->assertCount(0, $tracer->getSpans());
95105
}
96106
}

tests/OpenTracing/ReferenceTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,19 @@
55
use OpenTracing\Exceptions\InvalidReferenceArgument;
66
use OpenTracing\NoopSpanContext;
77
use OpenTracing\Reference;
8-
use PHPUnit_Framework_TestCase;
8+
use PHPUnit\Framework\TestCase;
99

1010
/**
1111
* @covers Reference
1212
*/
13-
final class ReferenceTest extends PHPUnit_Framework_TestCase
13+
final class ReferenceTest extends TestCase
1414
{
1515
const REFERENCE_TYPE = 'ref_type';
1616

1717
public function testCreateAReferenceFailsOnInvalidContext()
1818
{
1919
$context = 'invalid_context';
20+
2021
$this->expectException(InvalidReferenceArgument::class);
2122
$this->expectExceptionMessage(
2223
'Reference expects \OpenTracing\Span or \OpenTracing\SpanContext as context, got string'
@@ -27,6 +28,7 @@ public function testCreateAReferenceFailsOnInvalidContext()
2728
public function testCreateAReferenceFailsOnEmptyType()
2829
{
2930
$context = new NoopSpanContext();
31+
3032
$this->expectException(InvalidReferenceArgument::class);
3133
$this->expectExceptionMessage('Reference type can not be an empty string');
3234
Reference::create('', $context);
@@ -36,6 +38,7 @@ public function testAReferenceCanBeCreatedAsACustomType()
3638
{
3739
$context = new NoopSpanContext();
3840
$reference = Reference::create(self::REFERENCE_TYPE, $context);
41+
3942
$this->assertSame($context, $reference->getContext());
4043
$this->assertTrue($reference->isType(self::REFERENCE_TYPE));
4144
}

0 commit comments

Comments
 (0)