Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
"psr/log": "^1.0"
},
"require-dev": {
"ergebnis/phpunit-slow-test-detector": "^2.17",
"phpdocumentor/phpdocumentor": "^2.8.5",
"phpunit/phpunit": "~4.8.20"
"phpunit/phpunit": "~9"
},
"autoload": {
"psr-4": {
Expand Down
2,271 changes: 1,575 additions & 696 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/Client/ClientTracer.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ protected function joinFromArray(Span $span, $carrier) {
}

protected function _startsWith($haystack, $needle) {
return (substr($haystack, 0, strlen($needle)) === $needle);
return (str_starts_with($haystack, $needle));
}

// PHP does not have an event loop or timer threads. Instead manually check as
Expand Down
2 changes: 1 addition & 1 deletion lib/Client/Transports/TransportHTTPJSON.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class TransportHTTPJSON {
*/
protected $logger;

public function __construct(LoggerInterface $logger = null) {
public function __construct(?LoggerInterface $logger = null) {

$this->logger = $logger ?: new SystemLogger;
$this->_timeout = ini_get("default_socket_timeout");
Expand Down
2 changes: 1 addition & 1 deletion lib/Client/Transports/TransportHTTPPROTO.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class TransportHTTPPROTO {
*/
protected $logger;

public function __construct(LoggerInterface $logger = null) {
public function __construct(?LoggerInterface $logger = null) {

$this->logger = $logger ?: new SystemLogger;
$this->_timeout = ini_get("default_socket_timeout");
Expand Down
4 changes: 2 additions & 2 deletions lib/Client/Transports/TransportUDP.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ class TransportUDP {

protected $_sock = NULL;
protected $_host = NULL;
protected $_post = NULL;
protected $_port = NULL;
/**
* @var LoggerInterface
*/
protected $logger;

public function __construct(LoggerInterface $logger = null) {
public function __construct(?LoggerInterface $logger = null) {

$this->logger = $logger ?: new SystemLogger;
}
Expand Down
6 changes: 3 additions & 3 deletions lib/vendor/Thrift/ClassLoader/ThriftClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
* under the License.
*
* ClassLoader to load Thrift library and definitions
* Inspired from UniversalClassLoader from Symfony 2
* Inspired from UniversalClassLoader from Symfony 2
*
* @package thrift.classloader
*/
Expand Down Expand Up @@ -146,7 +146,7 @@ public function findFile($class)
foreach ($this->namespaces as $ns => $dirs)
{
//Don't interfere with other autoloaders
if (0 !== strpos($namespace, $ns))
if (!str_starts_with($namespace, $ns))
{
continue;
}
Expand Down Expand Up @@ -184,7 +184,7 @@ public function findFile($class)
foreach ($this->definitions as $ns => $dirs)
{
//Don't interfere with other autoloaders
if (0 !== strpos($namespace, $ns))
if (!str_starts_with($namespace, $ns))
{
continue;
}
Expand Down
32 changes: 18 additions & 14 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
colors="true"
failOnWarning="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
failOnRisky="true"
backupGlobals="false"
>
<php>
<ini name="memory_limit" value="-1"/>
Expand All @@ -17,31 +21,31 @@
</testsuite>
</testsuites>

<!-- Setup a listener for fixtures -->
<listeners>
<listener class="JohnKary\PHPUnit\Listener\SpeedTrapListener">
<extensions>
<extension class="Ergebnis\PHPUnit\SlowTestDetector\Extension">
<arguments>
<array>
<element key="slowThreshold">
<element key="maximum-duration">
<integer>250</integer>
</element>
<element key="reportLength">
<element key="maximum-count">
<integer>50</integer>
</element>
</array>
</arguments>
</listener>
</listeners>
</extension>
</extensions>

<!-- Prevent coverage reports from looking in tests and vendors -->
<filter>
<blacklist>
<coverage>
<include>
<directory suffix=".php">./lib/</directory>
</include>
<exclude>
<directory suffix=".php">./vendor/</directory>
<directory suffix=".ctp">./vendor/</directory>

<directory suffix=".php">./test/</directory>
<directory suffix=".ctp">./test/</directory>
</blacklist>
</filter>
</exclude>
</coverage>

</phpunit>
9 changes: 7 additions & 2 deletions test/BaseLightStepTest.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<?php

use PHPUnit\Framework\TestCase;

/**
* Class BaseLightStepTest
* @author Josh Wickham
* @copyright &copy; 2016 Life360, Inc.
* @since 6/10/16
*/
abstract class BaseLightStepTest extends PHPUnit_Framework_TestCase
abstract class BaseLightStepTest extends TestCase
{
protected function createTestTracer($component_name, $access_token) {
$opts = [
Expand All @@ -24,7 +26,10 @@ protected function createTestTracer($component_name, $access_token) {
* @return mixed
*/
protected function peek($obj, $field) {
return PHPUnit_Framework_Assert::readAttribute($obj, $field);
$reflection = new ReflectionClass($obj);
$property = $reflection->getProperty($field);
$property->setAccessible(true);
return $property->getValue($obj);
}

}
9 changes: 6 additions & 3 deletions test/ClientTracerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@ class ClientTracerTest extends BaseLightStepTest
*/
public function testCorrectTransportSelected($key, $class)
{

$tracer = new ClientTracer(['transport' => $key]);

$this->assertInstanceOf($class, $this->readAttribute($tracer, '_transport'));
$reflection = new ReflectionClass($tracer);
$property = $reflection->getProperty('_transport');
$property->setAccessible(true);
$tracerTransport = $property->getValue($tracer);
$this->assertInstanceOf($class, $tracerTransport);
}

public function transports()
Expand Down Expand Up @@ -61,7 +64,7 @@ public function testSettingCustomTracerAttributes() {
$attributes = $this->peek($tracer, '_options')['attributes'];

$this->assertArrayHasKey('foo', $attributes);
$this->assertSame($attributes['foo'], 'bar');
$this->assertSame('bar', $attributes['foo']);
}

public function testAddingCustomAttributeDoesNotRemoveDefaultAttributes() {
Expand Down
3 changes: 3 additions & 0 deletions test/InitializationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ class InitializationTest extends BaseLightStepTest {
If data collection is started before the runtime is configuration is
completed, the runtime should buffer that data until the init call.
*/
/**
* @doesNotPerformAssertions
*/
public function testOutOfOrderInitializationDoesntFail() {
$opts = [
"debug_disable_flush" => "true"
Expand Down
12 changes: 12 additions & 0 deletions test/PayloadsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ public function method() {

class PayloadsTest extends BaseLightStepTest {

/**
* @doesNotPerformAssertions
*/
public function testDataTypes() {
$runtime = $this->createTestTracer("test_group", "1234567890");
$span = $runtime->startSpan('test_span');
Expand Down Expand Up @@ -54,6 +57,9 @@ function() { echo "This is an anonymous function!"; },
$span->finish();
}

/**
* @doesNotPerformAssertions
*/
public function testDataTypes2() {
$runtime = $this->createTestTracer("test_group", "1234567890");
$span = $runtime->startSpan('test_span');
Expand Down Expand Up @@ -99,6 +105,9 @@ function() { echo "This is an anonymous function!"; },
$span->finish();
}

/**
* @doesNotPerformAssertions
*/
public function testCircularReferences() {
$runtime = $this->createTestTracer("test_group", "1234567890");
$span = $runtime->startSpan('test_span');
Expand All @@ -121,6 +130,9 @@ protected function _wrapValue($value, $depth) {
return $arr;
}

/**
* @doesNotPerformAssertions
*/
public function testDeeplyNested() {
$runtime = $this->createTestTracer("test_group", "1234567890");
$span = $runtime->startSpan('test_span');
Expand Down
3 changes: 3 additions & 0 deletions test/RuntimeDisableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

class RuntimeDisableTest extends BaseLightStepTest {

/**
* @doesNotPerformAssertions
*/
public function testDisable() {
$runtime = LightStep::newTracer("test_group", "1234567890");
$runtime->disable();
Expand Down
3 changes: 3 additions & 0 deletions test/SpanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ public function testSpanJoinIds() {
$this->assertEquals(count($this->peek($span, "_joinIds")), 2);
}

/**
* @doesNotPerformAssertions
*/
public function testSpanLogging() {
$tracer = $this->createTestTracer("test_group", "1234567890");
$span = $tracer->startSpan("log_span");
Expand Down