Skip to content

Commit

Permalink
Merge pull request #16 from keepsuit/drop-laravel-9
Browse files Browse the repository at this point in the history
Drop laravel 9
  • Loading branch information
cappuc committed Feb 14, 2024
2 parents 92853f3 + b69ecb2 commit 18bead8
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 58 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ jobs:
fail-fast: false
matrix:
php: [ 8.1, 8.2, 8.3 ]
laravel: [ ^9.0, ^10.0 ]
laravel: [ ^10.0, ^11.0 ]
stability: [ prefer-stable, prefer-lowest ]
exclude:
- php: 8.1
laravel: ^11.0

name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }}

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
.php_cs
.php_cs.cache
.phpunit.result.cache
.phpunit.cache
build
composer.lock
coverage
Expand Down
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
],
"require": {
"php": "^8.1",
"illuminate/contracts": "^9.0 || ^10.0",
"illuminate/support": "^9.0 || ^10.0",
"open-telemetry/exporter-otlp": "^1.0",
"illuminate/contracts": "^10.0 || ^11.0",
"illuminate/support": "^10.0 || ^11.0",
"open-telemetry/context": "^1.0.1",
"open-telemetry/sdk": "^1.0",
"open-telemetry/exporter-otlp": "^1.0",
"open-telemetry/sdk": "^1.0.1",
"open-telemetry/sem-conv": "^1.23",
"spatie/laravel-package-tools": "^1.16",
"thecodingmachine/safe": "^2.0"
Expand All @@ -32,13 +32,13 @@
"larastan/larastan": "^2.7",
"laravel/pint": "^1.2",
"nesbot/carbon": "^2.69 || ^3.0",
"nunomaduro/collision": "^6.0 || ^7.0",
"nunomaduro/collision": "^7.0 || ^8.0",
"open-telemetry/exporter-zipkin": "^1.0",
"open-telemetry/extension-propagator-b3": "^1.0",
"open-telemetry/transport-grpc": "^1.0",
"orchestra/testbench": "^7.0 || ^8.0",
"pestphp/pest": "^1.23",
"pestphp/pest-plugin-laravel": "^1.4",
"orchestra/testbench": "^8.0 || ^9.0",
"pestphp/pest": "^2.0",
"pestphp/pest-plugin-laravel": "^2.0",
"php-http/guzzle7-adapter": "^1.0",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.10.51",
Expand Down Expand Up @@ -87,6 +87,6 @@
]
}
},
"minimum-stability": "stable",
"minimum-stability": "dev",
"prefer-stable": true
}
29 changes: 7 additions & 22 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,32 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
executionOrder="random"
failOnWarning="true"
failOnRisky="true"
failOnEmptyTestSuite="true"
beStrictAboutOutputDuringTests="true"
verbose="true"
>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" backupGlobals="false" bootstrap="vendor/autoload.php" colors="true" processIsolation="false" stopOnFailure="false" executionOrder="random" failOnWarning="true"
failOnRisky="true" failOnEmptyTestSuite="true" beStrictAboutOutputDuringTests="true" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<testsuites>
<testsuite name="Keepsuit Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>
<coverage>
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
Expand All @@ -39,4 +19,9 @@
<php>
<env name="APP_KEY" value="base64:Otue13cqTvN3tEEu1F5C25ku031q5HktoEk2AnOZEgg="/>
</php>
<source>
<include>
<directory suffix=".php">./src</directory>
</include>
</source>
</phpunit>
43 changes: 17 additions & 26 deletions tests/Instrumentation/HttpClientInstrumentationTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php

use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Server\Server;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\Http;
Expand All @@ -9,17 +8,9 @@
use OpenTelemetry\API\Trace\SpanKind;
use OpenTelemetry\API\Trace\StatusCode;

beforeEach(function () {
Server::start();
});

afterEach(function () {
Server::stop();
});

it('injects propagation headers to Http client request', function () {
Server::enqueue([
new Response(200, ['Content-Length' => 0]),
$http = Http::fake([
'*' => Http::response('', 200, ['Content-Length' => 0]),
]);

$root = Tracer::newSpan('root')->start();
Expand All @@ -36,16 +27,16 @@

$httpSpan = Arr::get($spans, count($spans) - 2);

$request = Server::received()[0];
$request = Http::recorded()->first()[0];
assert($request instanceof \Illuminate\Http\Client\Request);

expect($request)
->hasHeader('traceparent')->toBeTrue()
->getHeader('traceparent')->toBe([sprintf('00-%s-%s-01', $traceId, $httpSpan->getSpanId())]);
->header('traceparent')->toBe([sprintf('00-%s-%s-01', $traceId, $httpSpan->getSpanId())]);
});

it('create http client span', function () {
Server::enqueue([
new Response(200, ['Content-Length' => 0]),
Http::fake([
'*' => Http::response('', 200, ['Content-Length' => 0]),
]);

Http::withTrace()->get(Server::$url);
Expand All @@ -70,8 +61,8 @@
});

it('set span status to error on 4xx and 5xx status code', function () {
Server::enqueue([
new Response(500, ['Content-Length' => 0]),
Http::fake([
'*' => Http::response('', 500, ['Content-Length' => 0]),
]);

Http::withTrace()->get(Server::$url);
Expand All @@ -94,8 +85,8 @@
],
]);

Server::enqueue([
new Response(200, ['Content-Length' => 0]),
Http::fake([
'*' => Http::response('', 200, ['Content-Length' => 0]),
]);

Http::withHeaders([
Expand All @@ -119,8 +110,8 @@
],
]);

Server::enqueue([
new Response(200, ['Content-Length' => 0, 'Content-Type' => 'text/html; charset=UTF-8']),
Http::fake([
'*' => Http::response('', 200, ['Content-Length' => 0, 'Content-Type' => 'text/html; charset=UTF-8']),
]);

Http::withTrace()->get(Server::$url);
Expand All @@ -144,8 +135,8 @@
],
]);

Server::enqueue([
new Response(200, ['Content-Length' => 0]),
Http::fake([
'*' => Http::response('', 200, ['Content-Length' => 0]),
]);

Http::withHeaders(['x-foo' => 'bar'])->withTrace()->get(Server::$url);
Expand All @@ -167,8 +158,8 @@
],
]);

Server::enqueue([
new Response(200, ['Content-Length' => 0, 'Set-Cookie' => 'cookie']),
Http::fake([
'*' => Http::response('', 200, ['Content-Length' => 0, 'Set-Cookie' => 'cookie']),
]);

Http::withHeaders([
Expand Down

0 comments on commit 18bead8

Please sign in to comment.