Skip to content

Commit

Permalink
Merge pull request #34 from webparking/php8
Browse files Browse the repository at this point in the history
Added support for PHP8
  • Loading branch information
KinaneD authored Sep 28, 2021
2 parents 56df25a + d64b905 commit 798615e
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 58 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ composer.lock
Thumbs.db
/phpunit.xml
*.iml
.phpunit.result.cache
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
}
],
"require": {
"php": "^7.1.3",
"php": "^7.1.3|^8.0.0",
"illuminate/bus": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0",
"illuminate/console": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0",
"illuminate/contracts": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0",
Expand All @@ -27,7 +27,7 @@
"illuminate/queue": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0",
"illuminate/routing": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0",
"illuminate/support": "~5.5.0|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0",
"openzipkin/zipkin": "~2.0.2",
"openzipkin/zipkin": "~2.0.2|3.0.x-dev",
"psr/http-message": "~1.0",
"ramsey/uuid": "~3.0|~4.0"
},
Expand All @@ -36,7 +36,7 @@
"guzzlehttp/psr7": "~1.0",
"mockery/mockery": "~1.0",
"php-amqplib/php-amqplib": "~2.8",
"phpunit/phpunit": "~7.0",
"phpunit/phpunit": "~7.0|~8.0",
"vinelab/http": "~1.5",
"lucid-arch/laravel-foundation": "^7.0|^8.0",
"lucidarch/lucid": "^1.0"
Expand Down
12 changes: 8 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
version: '3.7'

services:
# Docker Image: https://hub.docker.com/r/vinelab/nginx-php
app:
image: vinelab/nginx-php:7.4
workspace:
tty: true
build:
context: resources/docker/workspace
args:
PUID: "${PUID:-1000}"
PGID: "${PGID:-1000}"
volumes:
- ./:/code:cached
- ./:/var/www/html
29 changes: 29 additions & 0 deletions resources/docker/workspace/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
FROM php:8.0-cli-alpine

ARG PUID=1000
ARG PGID=1000

RUN apk add --no-cache --virtual .build-deps \
# for extensions
$PHPIZE_DEPS \
&& \
apk add --no-cache \
bash \
# for composer
unzip \
&& \
docker-php-ext-install \
# for php-amqplib
bcmath \
&& \
apk del .build-deps

COPY --from=composer /usr/bin/composer /usr/bin/composer

# Add a non-root user to prevent files being created with root permissions on host machine.
RUN addgroup -g ${PGID} user && \
adduser -u ${PUID} -G user -D user

WORKDIR /var/www/html

USER user
5 changes: 2 additions & 3 deletions tests/Zipkin/InteractsWithZipkin.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,11 @@ protected function createTracer(

/**
* @param array $spans
* @return array
*/
protected function shiftSpan(array &$spans): array
protected function shiftSpan(array &$spans): Span
{
/** @var Span $span */
$span = array_shift($spans);
return $span->toArray();
return $span;
}
}
28 changes: 14 additions & 14 deletions tests/Zipkin/QueueJobSubscriberTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,20 @@ public function test_job_processed()
$reporter->shouldHaveReceived('report')->with(Mockery::on(function ($spans) {
$span = $this->shiftSpan($spans);

$parentId = Arr::get($span, 'id');
$parentId = $span->getSpanId();

$span = $this->shiftSpan($spans);

$this->assertEquals($parentId, Arr::get($span, 'parentId'));
$this->assertEquals('ExampleJob', Arr::get($span, 'name'));
$this->assertEquals('sync', Arr::get($span, 'tags.connection_name'));
$this->assertEquals('default', Arr::get($span, 'tags.queue_name'));
$this->assertEquals($parentId, $span->getParentId());
$this->assertEquals('ExampleJob', $span->getName());
$this->assertEquals('sync', Arr::get($span->getTags(), 'connection_name'));
$this->assertEquals('default', Arr::get($span->getTags(), 'queue_name'));
$this->assertEquals([
'primitive' => 'Example Payload',
'fluent' => [
'name' => 'John Doe',
],
], json_decode(Arr::get($span, 'tags.job_input'), true));
], json_decode(Arr::get($span->getTags(), 'job_input'), true));

return true;
}));
Expand Down Expand Up @@ -112,22 +112,22 @@ public function test_job_failed()
$reporter->shouldHaveReceived('report')->with(Mockery::on(function ($spans) {
$span = $this->shiftSpan($spans);

$parentId = Arr::get($span, 'id');
$parentId = $span->getSpanId();

$span = $this->shiftSpan($spans);

$this->assertEquals($parentId, Arr::get($span, 'parentId'));
$this->assertEquals('ExampleJob', Arr::get($span, 'name'));
$this->assertEquals('sync', Arr::get($span, 'tags.connection_name'));
$this->assertEquals('default', Arr::get($span, 'tags.queue_name'));
$this->assertEquals($parentId, $span->getParentId());
$this->assertEquals('ExampleJob', $span->getName());
$this->assertEquals('sync', Arr::get($span->getTags(), 'connection_name'));
$this->assertEquals('default', Arr::get($span->getTags(), 'queue_name'));
$this->assertEquals([
'primitive' => 'Example Payload',
'fluent' => [
'name' => 'John Doe',
],
], json_decode(Arr::get($span, 'tags.job_input'), true));
$this->assertEquals('true', Arr::get($span, 'tags.error'));
$this->assertEquals('whatever', Arr::get($span, 'tags.error_message'));
], json_decode(Arr::get($span->getTags(), 'job_input'), true));
$this->assertEquals('true', Arr::get($span->getTags(), 'error'));
$this->assertEquals('whatever', Arr::get($span->getTags(), 'error_message'));

return true;
}));
Expand Down
6 changes: 3 additions & 3 deletions tests/Zipkin/TraceCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ public function trace_console_command()
$reporter->shouldHaveReceived('report')->with(Mockery::on(function ($spans) {
$span = $this->shiftSpan($spans);

$this->assertEquals('artisan example', Arr::get($span, 'name'));
$this->assertEquals('cli', Arr::get($span, 'tags.type'));
$this->assertContains('phpunit', Arr::get($span, 'tags.argv'));
$this->assertEquals('artisan example', $span->getName());
$this->assertEquals('cli', Arr::get($span->getTags(), 'type'));
$this->assertStringContainsString('phpunit', Arr::get($span->getTags(), 'argv'));

return true;
}));
Expand Down
28 changes: 14 additions & 14 deletions tests/Zipkin/TraceRequestsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@ public function trace_http_requests()
$reporter->shouldHaveReceived('report')->with(Mockery::on(function ($spans) {
$span = $this->shiftSpan($spans);

$this->assertRegExp('/^POST \/?shipments\/{id}$/', Arr::get($span, 'name'));
$this->assertEquals('http', Arr::get($span, 'tags.type'));
$this->assertEquals('POST', Arr::get($span, 'tags.request_method'));
$this->assertEquals('shipments/3242', Arr::get($span, 'tags.request_path'));
$this->assertEquals('/shipments/3242?token=secret', Arr::get($span, 'tags.request_uri'));
$this->assertContains('application/json', Arr::get($span, 'tags.request_headers'));
$this->assertContains('This value is hidden because it contains sensitive info', Arr::get($span, 'tags.request_headers'));
$this->assertContains('Catherine Dupuy', Arr::get($span, 'tags.request_input'));
$this->assertNotContains('PASSWORD', Arr::get($span, 'tags.request_input'));
$this->assertEquals('127.0.0.1', Arr::get($span, 'tags.request_ip'));

$this->assertContains('422', Arr::get($span, 'tags.response_status'));
$this->assertContains('application/json', Arr::get($span, 'tags.response_headers'));
$this->assertContains('Unprocessable Entity', Arr::get($span, 'tags.response_content'));
$this->assertRegExp('/^POST \/?shipments\/{id}$/', $span->getName());
$this->assertEquals('http', Arr::get($span->getTags(), 'type'));
$this->assertEquals('POST', Arr::get($span->getTags(), 'request_method'));
$this->assertEquals('shipments/3242', Arr::get($span->getTags(), 'request_path'));
$this->assertEquals('/shipments/3242?token=secret', Arr::get($span->getTags(), 'request_uri'));
$this->assertStringContainsString('application/json', Arr::get($span->getTags(), 'request_headers'));
$this->assertStringContainsString('This value is hidden because it contains sensitive info', Arr::get($span->getTags(), 'request_headers'));
$this->assertStringContainsString('Catherine Dupuy', Arr::get($span->getTags(), 'request_input'));
$this->assertStringNotContainsString('PASSWORD', Arr::get($span->getTags(), 'request_input'));
$this->assertEquals('127.0.0.1', Arr::get($span->getTags(), 'request_ip'));

$this->assertStringContainsString('422', Arr::get($span->getTags(), 'response_status'));
$this->assertStringContainsString('application/json', Arr::get($span->getTags(), 'response_headers'));
$this->assertStringContainsString('Unprocessable Entity', Arr::get($span->getTags(), 'response_content'));

return true;
}));
Expand Down
34 changes: 17 additions & 17 deletions tests/Zipkin/TracerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ public function configure_reporter()
$reporter->shouldHaveReceived('report')->with(Mockery::on(function ($spans) {
$span = $this->shiftSpan($spans);

$this->assertEquals('orders', Arr::get($span, 'localEndpoint.serviceName'));
$this->assertEquals('192.88.105.145', Arr::get($span, 'localEndpoint.ipv4'));
$this->assertEquals('9444', Arr::get($span, 'localEndpoint.port'));
$this->assertEquals(16, strlen(Arr::get($span, 'traceId')));
$this->assertEquals('orders', $span->getLocalEndpoint()->getServiceName());
$this->assertEquals('192.88.105.145', $span->getLocalEndpoint()->getIpv4());
$this->assertEquals('9444', $span->getLocalEndpoint()->getPort());
$this->assertEquals(16, strlen($span->getTraceId()));

return true;
}));
Expand All @@ -53,7 +53,7 @@ public function configure_reporter_using_hostname()

$reporter->shouldHaveReceived('report')->with(Mockery::on(function ($spans) {
$span = $this->shiftSpan($spans);
$this->assertEquals('127.0.0.1', Arr::get($span, 'localEndpoint.ipv4'));
$this->assertEquals('127.0.0.1', $span->getLocalEndpoint()->getIpv4());
return true;
}));
}
Expand All @@ -69,7 +69,7 @@ public function configure_reporter_using_ipv6_address()

$reporter->shouldHaveReceived('report')->with(Mockery::on(function ($spans) {
$span = $this->shiftSpan($spans);
$this->assertEquals('dec6:dcca:47dc:7c89:5a7c:8d6f:c9b3:96d0', Arr::get($span, 'localEndpoint.ipv6'));
$this->assertEquals('dec6:dcca:47dc:7c89:5a7c:8d6f:c9b3:96d0', $span->getLocalEndpoint()->getIpv6());
return true;
}));
}
Expand All @@ -85,7 +85,7 @@ public function configure_reporter_using_128bit_trace_ids()

$reporter->shouldHaveReceived('report')->with(Mockery::on(function ($spans) {
$span = $this->shiftSpan($spans);
$this->assertEquals(32, strlen(Arr::get($span, 'traceId')));
$this->assertEquals(32, strlen($span->getTraceId()));
return true;
}));
}
Expand All @@ -109,11 +109,11 @@ public function customize_spans()
$reporter->shouldHaveReceived('report')->with(
Mockery::on(function ($spans) use ($startTimestamp, $finishTimestamp) {
$span = $this->shiftSpan($spans);
$this->assertEquals('Create Order', Arr::get($span, 'name'));
$this->assertEquals($finishTimestamp - $startTimestamp, Arr::get($span, 'duration'));
$this->assertEquals('api/orders', Arr::get($span, 'tags.request_path'));
$this->assertEquals('Create Payment', Arr::get($span, 'annotations.0.value'));
$this->assertEquals('Update Order Status', Arr::get($span, 'annotations.1.value'));
$this->assertEquals('Create Order', $span->getName());
$this->assertEquals($finishTimestamp - $startTimestamp, $span->getDuration());
$this->assertEquals('api/orders', Arr::get($span->getTags(), 'request_path'));
$this->assertEquals('Create Payment', Arr::get($span->getAnnotations(), '0.value'));
$this->assertEquals('Update Order Status', Arr::get($span->getAnnotations(), '1.value'));
return true;
})
);
Expand All @@ -129,7 +129,7 @@ public function control_span_duration()
$tracer->flush();

$reporter->shouldHaveReceived('report')->with(Mockery::on(function ($spans) {
$duration = Arr::get($this->shiftSpan($spans), 'duration');
$duration = $this->shiftSpan($spans)->getDuration();
$this->assertTrue($duration > 0);
return true;
}));
Expand All @@ -151,9 +151,9 @@ public function control_span_relationships()
$reporter->shouldHaveReceived('report')->with(Mockery::on(function ($spans) {
$span = $this->shiftSpan($spans);

$this->assertRegExp($this->getRegexpForUUID(), Arr::get($span, 'tags.uuid'));
$this->assertNotNull(Arr::get($span, 'id'));
$this->assertNull(Arr::get($span, 'parentId'));
$this->assertRegExp($this->getRegexpForUUID(), Arr::get($span->getTags(), 'uuid'));
$this->assertNotNull($span->getSpanId());
$this->assertNull($span->getParentId());

$spanId = Arr::get($span, 'id');
$span = $this->shiftSpan($spans);
Expand All @@ -180,7 +180,7 @@ public function set_max_tag_len()

$this->assertEquals(
'Value exceeds the maximum allowed length of 10 bytes',
Arr::get($span, 'tags.response_content')
Arr::get($span->getTags(), 'response_content')
);

return true;
Expand Down

0 comments on commit 798615e

Please sign in to comment.