Skip to content

chore(deps): update php minors #115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 7, 2023
Merged
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
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@
"guzzlehttp/guzzle": "7.7.0",
"fluent/logger": "1.0.1",
"phpunit/phpunit": "10.2.3",
"vimeo/psalm": "5.12.0",
"vimeo/psalm": "5.13.1",
"dealerdirect/phpcodesniffer-composer-installer": "1.0.0",
"phpcompatibility/php-compatibility": "9.3.5",
"cyclonedx/cyclonedx-php-composer": "4.0.2",
"cyclonedx/cyclonedx-php-composer": "4.1.0",
"php-http/guzzle7-adapter": "1.0.0",
"sentry/sentry": "3.19.1"
"sentry/sentry": "3.20.1"
},
"config": {
"platform": {
Expand Down
72 changes: 36 additions & 36 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 7 additions & 6 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" bootstrap="./vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage includeUncoveredFiles="false">
<include>
<directory suffix=".php">./src/</directory>
</include>
</coverage>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" bootstrap="./vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage includeUncoveredFiles="false"/>
<testsuites>
<testsuite name="Kronos-Log">
<directory>./tests</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">./src/</directory>
</include>
</source>
</phpunit>
4 changes: 2 additions & 2 deletions src/Writer/Sentry.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

class Sentry extends AbstractWriter
{

/**
* @var ClientInterface
*/
Expand Down Expand Up @@ -65,10 +64,11 @@ private function captureException($level, $message, $context)
$this->sentryClient->captureException($exception, $sentryScope);
}

private function getSentryScope($level, $context): Scope
protected function getSentryScope($level, $context): Scope
{
$scope = new Scope();
$scope->setLevel($level);

if (count($context)) {
$scope->setExtras($context);
}
Expand Down
58 changes: 49 additions & 9 deletions tests/Writer/SentryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@

use Kronos\Log\Writer\Sentry;
use Kronos\Log\Logger;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Log\LogLevel;
use Sentry\ClientInterface;
use Sentry\Severity;
use Sentry\State\Scope;
use Sentry\Tracing\PropagationContext;
use Sentry\Tracing\SpanId;
use Sentry\Tracing\TraceId;

class SentryTest extends \PHPUnit\Framework\TestCase
class SentryTest extends TestCase
{

const A_MESSAGE = 'a message';
const INTERPOLATABLE_MESSAGE = 'message with {key}';
const INTERPOLATED_MESSAGE = 'message with value';
Expand All @@ -20,18 +24,14 @@ class SentryTest extends \PHPUnit\Framework\TestCase
const ANY_LEVEL = LogLevel::DEBUG;
const LOGGER_MESSAGE_KEY = 'loggerMessage';

private $sentryClient;

/**
* @var Sentry
*/
private $writer;
private ClientInterface&MockObject $sentryClient;
private Sentry|SentryWithScopeDecorator $writer;

public function setUp(): void
{
$this->sentryClient = $this->createMock(ClientInterface::class);

$this->writer = new Sentry($this->sentryClient);
$this->writer = new SentryWithScopeDecorator($this->sentryClient);
}

public function test_MessageAndContext_Log_SouldCallCaptureMessageWithInterpolatedMessage()
Expand Down Expand Up @@ -219,9 +219,49 @@ private function expectsCaptureExceptionToBeCalledWith($exception, $level, $para
if (count($params)) {
$scope->setExtras($params);
}

$propagationContext = PropagationContext::fromDefaults();
$propagationContext->setSpanId(new SpanId(SentryWithScopeDecorator::SPAN_ID));
$propagationContext->setTraceId(new TraceId(SentryWithScopeDecorator::TRACE_ID));

$scope->setPropagationContext($propagationContext);

$this->sentryClient
->expects($this->once())
->method('captureException')
->with($exception, $scope);
}
}

class SentryWithScopeDecorator extends Sentry
{
const SPAN_ID = "3d1bf6350d09fb80";
const TRACE_ID = "141bb800f59d073b7a075b1eed7d5372";

public function log($level, $message, array $context = [])
{
parent::log($level, $message, $context);
}

protected function getSentryScope($level, $context): Scope
{
$scope = new Scope();
$scope->setLevel($level);
$this->setPropagationContext($scope);

if (count($context)) {
$scope->setExtras($context);
}

return $scope;
}

private function setPropagationContext(Scope $scope): void
{
$propagationContext = PropagationContext::fromDefaults();
$propagationContext->setSpanId(new SpanId(self::SPAN_ID));
$propagationContext->setTraceId(new TraceId(self::TRACE_ID));

$scope->setPropagationContext($propagationContext);
}
}