Skip to content

Commit

Permalink
Merge pull request #87 from piotrooo/features/update-php
Browse files Browse the repository at this point in the history
New php versions
  • Loading branch information
jcchavezs authored Apr 10, 2019
2 parents 1edd0a9 + e90cb03 commit 42eb0e5
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 87 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
language: php

php:
- '5.6'
- '7.0'
- '7.1'
- '7.2'
- '7.3'

cache:
directories:
Expand Down
76 changes: 38 additions & 38 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
{
"name": "opentracing/opentracing",
"type": "library",
"description": "OpenTracing API for PHP",
"license": "Apache-2.0",
"authors": [
{
"name": "José Carlos Chávez",
"email": "jcchavezs@gmail.com"
}
],
"require": {
"php": "^5.6 || ^7.0"
},
"require-dev": {
"phpunit/phpunit": "~5.7.19",
"squizlabs/php_codesniffer": "3.*"
},
"config": {
"sort-packages": true
},
"autoload": {
"psr-4": {
"OpenTracing\\": "./src/OpenTracing/"
},
"files": [
"./src/OpenTracing/Tags.php",
"./src/OpenTracing/Formats.php"
]
},
"autoload-dev": {
"psr-4": {
"OpenTracing\\Tests\\": "./tests/OpenTracing"
}
"name": "opentracing/opentracing",
"type": "library",
"description": "OpenTracing API for PHP",
"license": "Apache-2.0",
"minimum-stability": "stable",
"authors": [
{
"name": "José Carlos Chávez",
"email": "jcchavezs@gmail.com"
}
],
"require": {
"php": "^7.1"
},
"require-dev": {
"phpunit/phpunit": "~7.5.8",
"squizlabs/php_codesniffer": "3.*"
},
"config": {
"sort-packages": true
},
"autoload": {
"psr-4": {
"OpenTracing\\": "src/OpenTracing/"
},
"minimum-stability": "stable",
"scripts": {
"fix-lint": "phpcbf --standard=ZEND --standard=PSR2 --ignore=*/vendor/* ./",
"lint": "phpcs --standard=ZEND --standard=PSR2 --ignore=*/vendor/* ./",
"test": "phpunit tests"
"files": [
"src/OpenTracing/Tags.php",
"src/OpenTracing/Formats.php"
]
},
"autoload-dev": {
"psr-4": {
"OpenTracing\\Tests\\": "tests/OpenTracing"
}
},
"scripts": {
"fix-lint": "phpcbf --standard=ZEND --standard=PSR2 --ignore=*/vendor/* ./",
"lint": "phpcs --standard=ZEND --standard=PSR2 --ignore=*/vendor/* ./",
"test": "phpunit tests"
}
}
8 changes: 4 additions & 4 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/7.5/phpunit.xsd"
backupGlobals="true"
backupStaticAttributes="false"
bootstrap="./vendor/autoload.php"
Expand All @@ -11,16 +11,16 @@
convertWarningsToExceptions="true"
forceCoversAnnotation="false"
mapTestClassNameToCoveredClassName="false"
printerClass="PHPUnit_TextUI_ResultPrinter"
printerClass="PHPUnit\TextUI\ResultPrinter"
processIsolation="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
stopOnRisky="false"
testSuiteLoaderClass="PHPUnit_Runner_StandardTestSuiteLoader"
testSuiteLoaderClass="PHPUnit\Runner\StandardTestSuiteLoader"
timeoutForSmallTests="1"
timeoutForMediumTests="10"
timeoutForLargeTests="60"
verbose="false">
</phpunit>
</phpunit>
11 changes: 8 additions & 3 deletions tests/OpenTracing/Mock/MockScopeManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@

use OpenTracing\Mock\MockScopeManager;
use OpenTracing\Mock\MockTracer;
use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;

final class MockScopeManagerTest extends PHPUnit_Framework_TestCase
final class MockScopeManagerTest extends TestCase
{
const OPERATION_NAME = 'test_name';
private const OPERATION_NAME = 'test_name';

public function testGetActiveFailsWithNoActiveSpans()
{
$scopeManager = new MockScopeManager();

$this->assertNull($scopeManager->getActive());
}

Expand All @@ -22,6 +23,7 @@ public function testActivateSuccess()
$span = $tracer->startSpan(self::OPERATION_NAME);
$scopeManager = new MockScopeManager();
$scopeManager->activate($span);

$this->assertSame($span, $scopeManager->getActive()->getSpan());
}

Expand All @@ -30,6 +32,7 @@ public function testGetScopeReturnsNull()
$tracer = new MockTracer();
$tracer->startSpan(self::OPERATION_NAME);
$scopeManager = new MockScopeManager();

$this->assertNull($scopeManager->getActive());
}

Expand All @@ -40,6 +43,7 @@ public function testGetScopeSuccess()
$scopeManager = new MockScopeManager();
$scopeManager->activate($span);
$scope = $scopeManager->getActive();

$this->assertSame($span, $scope->getSpan());
}

Expand All @@ -51,6 +55,7 @@ public function testDeactivateSuccess()
$scopeManager->activate($span);
$scope = $scopeManager->getActive();
$scopeManager->deactivate($scope);

$this->assertNull($scopeManager->getActive());
}
}
15 changes: 8 additions & 7 deletions tests/OpenTracing/Mock/MockSpanContextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,21 @@
namespace OpenTracing\Mock\Tests;

use OpenTracing\Mock\MockSpanContext;
use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;

final class MockSpanContextTest extends PHPUnit_Framework_TestCase
final class MockSpanContextTest extends TestCase
{
const TRACE_ID = 'test_trace_id';
const SPAN_ID = 'test_span_id';
const IS_SAMPLED = true;
const BAGGAGE_ITEM_KEY = 'test_key';
const BAGGAGE_ITEM_VALUE = 'test_value';
private const TRACE_ID = 'test_trace_id';
private const SPAN_ID = 'test_span_id';
private const IS_SAMPLED = true;
private const BAGGAGE_ITEM_KEY = 'test_key';
private const BAGGAGE_ITEM_VALUE = 'test_value';

public function testCreateAsRootSuccess()
{
$parentContext = MockSpanContext::createAsRoot();
$childContext = MockSpanContext::createAsChildOf($parentContext);

$this->assertEquals($parentContext->getTraceId(), $childContext->getTraceId());
}

Expand Down
34 changes: 12 additions & 22 deletions tests/OpenTracing/Mock/MockSpanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,34 @@

namespace OpenTracing\Mock\Tests;

use OpenTracing\NoopScopeManager;
use OpenTracing\Mock\MockSpan;
use OpenTracing\Mock\MockSpanContext;
use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;

/**
* @covers MockSpan
*/
final class MockSpanTest extends PHPUnit_Framework_TestCase
final class MockSpanTest extends TestCase
{
const OPERATION_NAME = 'test';
const DURATION = 10;
const TAG_KEY = 'test_key';
const TAG_VALUE = 'test_value';
const LOG_FIELD = 'test_log';
private const OPERATION_NAME = 'test';
private const DURATION = 10;
private const TAG_KEY = 'test_key';
private const TAG_VALUE = 'test_value';
private const LOG_FIELD = 'test_log';

public function testCreateSpanSuccess()
{
$startTime = time();
$span = new MockSpan(
self::OPERATION_NAME,
MockSpanContext::createAsRoot(),
$startTime
);
$span = new MockSpan(self::OPERATION_NAME, MockSpanContext::createAsRoot(), $startTime);

$this->assertEquals($startTime, $span->getStartTime());
$this->assertEmpty($span->getTags());
$this->assertEmpty($span->getLogs());
}

public function testAddTagsAndLogsToSpanSuccess()
{
$span = new MockSpan(
self::OPERATION_NAME,
MockSpanContext::createAsRoot()
);
$span = new MockSpan(self::OPERATION_NAME, MockSpanContext::createAsRoot());

$span->setTag(self::TAG_KEY, self::TAG_VALUE);
$span->log([self::LOG_FIELD]);
Expand All @@ -48,12 +41,9 @@ public function testAddTagsAndLogsToSpanSuccess()
public function testSpanIsFinished()
{
$startTime = time();
$span = new MockSpan(
self::OPERATION_NAME,
MockSpanContext::createAsRoot(),
$startTime
);
$span = new MockSpan(self::OPERATION_NAME, MockSpanContext::createAsRoot(), $startTime);
$span->finish($startTime + self::DURATION);

$this->assertTrue($span->isFinished());
$this->assertEquals(self::DURATION, $span->getDuration());
}
Expand Down
20 changes: 15 additions & 5 deletions tests/OpenTracing/Mock/MockTracerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@
use OpenTracing\Exceptions\UnsupportedFormat;
use OpenTracing\Mock\MockTracer;
use OpenTracing\NoopSpan;
use PHPUnit_Framework_TestCase;
use OpenTracing\Span;
use PHPUnit\Framework\TestCase;

/**
* @covers MockTracer
*/
final class MockTracerTest extends PHPUnit_Framework_TestCase
final class MockTracerTest extends TestCase
{
const OPERATION_NAME = 'test_name';
const FORMAT = 'test_format';
private const OPERATION_NAME = 'test_name';
private const FORMAT = 'test_format';

public function testStartActiveSpanSuccess()
{
$tracer = new MockTracer();
$scope = $tracer->startActiveSpan(self::OPERATION_NAME);
$activeSpan = $tracer->getActiveSpan();

$this->assertEquals($scope->getSpan(), $activeSpan);
}

Expand All @@ -28,6 +30,7 @@ public function testStartSpanSuccess()
$tracer = new MockTracer();
$tracer->startSpan(self::OPERATION_NAME);
$activeSpan = $tracer->getActiveSpan();

$this->assertNull($activeSpan);
}

Expand All @@ -36,6 +39,7 @@ public function testInjectWithNoInjectorsFails()
$tracer = new MockTracer();
$span = $tracer->startSpan(self::OPERATION_NAME);
$carrier = [];

$this->expectException(UnsupportedFormat::class);
$tracer->inject($span->getContext(), self::FORMAT, $carrier);
}
Expand Down Expand Up @@ -63,6 +67,7 @@ public function testExtractWithNoExtractorsFails()
{
$tracer = new MockTracer();
$carrier = [];

$this->expectException(UnsupportedFormat::class);
$tracer->extract(self::FORMAT, $carrier);
}
Expand All @@ -82,15 +87,20 @@ public function testExtractSuccess()
'TRACE_ID' => 'trace_id'
];

$tracer->extract(self::FORMAT, $carrier);
$spanContext = $tracer->extract(self::FORMAT, $carrier);

$this->assertInstanceOf(Span::class, $spanContext);
}

public function testFlushSuccess()
{
$tracer = new MockTracer();
$tracer->startSpan(self::OPERATION_NAME);

$this->assertCount(1, $tracer->getSpans());

$tracer->flush();

$this->assertCount(0, $tracer->getSpans());
}
}
7 changes: 5 additions & 2 deletions tests/OpenTracing/ReferenceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@
use OpenTracing\Exceptions\InvalidReferenceArgument;
use OpenTracing\NoopSpanContext;
use OpenTracing\Reference;
use PHPUnit_Framework_TestCase;
use PHPUnit\Framework\TestCase;

/**
* @covers Reference
*/
final class ReferenceTest extends PHPUnit_Framework_TestCase
final class ReferenceTest extends TestCase
{
const REFERENCE_TYPE = 'ref_type';

public function testCreateAReferenceFailsOnInvalidContext()
{
$context = 'invalid_context';

$this->expectException(InvalidReferenceArgument::class);
$this->expectExceptionMessage(
'Reference expects \OpenTracing\Span or \OpenTracing\SpanContext as context, got string'
Expand All @@ -27,6 +28,7 @@ public function testCreateAReferenceFailsOnInvalidContext()
public function testCreateAReferenceFailsOnEmptyType()
{
$context = new NoopSpanContext();

$this->expectException(InvalidReferenceArgument::class);
$this->expectExceptionMessage('Reference type can not be an empty string');
Reference::create('', $context);
Expand All @@ -36,6 +38,7 @@ public function testAReferenceCanBeCreatedAsACustomType()
{
$context = new NoopSpanContext();
$reference = Reference::create(self::REFERENCE_TYPE, $context);

$this->assertSame($context, $reference->getContext());
$this->assertTrue($reference->isType(self::REFERENCE_TYPE));
}
Expand Down
Loading

0 comments on commit 42eb0e5

Please sign in to comment.