Skip to content
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

Fix build if ext-memcached is missing #209

Merged
merged 1 commit into from
Jul 1, 2021
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
4 changes: 4 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ parameters:
# SpanCustomizer is definitively not null
message: '#Parameter \#3 \$ of callable callable\(.*, Zipkin\\Propagation\\TraceContext, Zipkin\\SpanCustomizer\): void expects Zipkin\\SpanCustomizer, Zipkin\\SpanCustomizerShield\|null given.#'
path: src/Zipkin/Tracer
excludePaths:
analyse:
- src/Zipkin/Reporters/Aggregation/MemcachedClient.php
- src/Zipkin/Reporters/Memcached.php
70 changes: 70 additions & 0 deletions tests/Unit/Reporters/MemcachedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public function invokeMethod(&$object, $methodName, array $parameters = [])

public function testReportError()
{
if (!class_exists('\Memcached')) {
$this->markTestSkipped('PHP ext-memcached is required.');
return;
}

$memcachedClient = $this->createMock(MemcachedClient::class);
$httpReporter = $this->createMock(Reporter::class);
$logger = $this->createMock(LoggerInterface::class);
Expand All @@ -50,6 +55,11 @@ public function testReportError()

public function testReportSuccessWithoutAggregatedSpans()
{
if (!class_exists('\Memcached')) {
$this->markTestSkipped('PHP ext-memcached is required.');
return;
}

$memcachedClient = $this->createMock(MemcachedClient::class);
$httpReporter = $this->createMock(Reporter::class);
$logger = $this->createMock(LoggerInterface::class);
Expand Down Expand Up @@ -78,6 +88,11 @@ public function testReportSuccessWithoutAggregatedSpans()

public function testReportSuccessWithSpans01()
{
if (!class_exists('\Memcached')) {
$this->markTestSkipped('PHP ext-memcached is required.');
return;
}

$memcachedClient = $this->createMock(MemcachedClient::class);
$httpReporter = $this->createMock(Reporter::class);
$logger = $this->createMock(LoggerInterface::class);
Expand Down Expand Up @@ -120,6 +135,11 @@ public function testReportSuccessWithSpans01()

public function testReportSuccessWithSpans02()
{
if (!class_exists('\Memcached')) {
$this->markTestSkipped('PHP ext-memcached is required.');
return;
}

$memcachedClient = $this->createMock(MemcachedClient::class);
$httpReporter = $this->createMock(Reporter::class);
$logger = $this->createMock(LoggerInterface::class);
Expand Down Expand Up @@ -159,6 +179,11 @@ public function testReportSuccessWithSpans02()

public function testFlushingOfOneSpanWithRetry()
{
if (!class_exists('\Memcached')) {
$this->markTestSkipped('PHP ext-memcached is required.');
return;
}

$memcachedClient = $this->createMock(MemcachedClient::class);
$httpReporter = $this->createMock(Reporter::class);
$memcached = new Memcached([], $httpReporter, $memcachedClient);
Expand Down Expand Up @@ -198,6 +223,11 @@ public function testFlushingOfOneSpanWithRetry()

public function testFlushingOfOneSpan()
{
if (!class_exists('\Memcached')) {
$this->markTestSkipped('PHP ext-memcached is required.');
return;
}

$memcachedClient = $this->createMock(MemcachedClient::class);
$httpReporter = $this->createMock(Reporter::class);
$memcached = new Memcached([], $httpReporter, $memcachedClient);
Expand Down Expand Up @@ -230,6 +260,11 @@ public function testFlushingOfOneSpan()

public function testFlushingOfZeroSpans()
{
if (!class_exists('\Memcached')) {
$this->markTestSkipped('PHP ext-memcached is required.');
return;
}

$memcachedClient = $this->createMock(MemcachedClient::class);
$httpReporter = $this->createMock(Reporter::class);
$memcached = new Memcached([], $httpReporter, $memcachedClient);
Expand All @@ -254,6 +289,11 @@ public function testFlushingOfZeroSpans()

public function testFlushingError()
{
if (!class_exists('\Memcached')) {
$this->markTestSkipped('PHP ext-memcached is required.');
return;
}

$memcachedClient = $this->createMock(MemcachedClient::class);
$httpReporter = $this->createMock(Reporter::class);
$logger = $this->createMock(LoggerInterface::class);
Expand All @@ -271,6 +311,11 @@ public function testFlushingError()

public function testDisabledPatchInterval()
{
if (!class_exists('\Memcached')) {
$this->markTestSkipped('PHP ext-memcached is required.');
return;
}

$memcachedClient = $this->createMock(MemcachedClient::class);
$httpReporter = $this->createMock(Reporter::class);
$memcached = new Memcached(['batch_interval' => -1], $httpReporter, $memcachedClient);
Expand All @@ -283,6 +328,11 @@ public function testDisabledPatchInterval()

public function testEnabledPatchInterval01()
{
if (!class_exists('\Memcached')) {
$this->markTestSkipped('PHP ext-memcached is required.');
return;
}

$memcachedClient = $this->createMock(MemcachedClient::class);
$httpReporter = $this->createMock(Reporter::class);
$memcached = new Memcached(['batch_interval' => 60], $httpReporter, $memcachedClient);
Expand All @@ -300,6 +350,11 @@ public function testEnabledPatchInterval01()

public function testEnabledPatchInterval02()
{
if (!class_exists('\Memcached')) {
$this->markTestSkipped('PHP ext-memcached is required.');
return;
}

$memcachedClient = $this->createMock(MemcachedClient::class);
$httpReporter = $this->createMock(Reporter::class);
$memcached = new Memcached(['batch_interval' => 60], $httpReporter, $memcachedClient);
Expand All @@ -320,6 +375,11 @@ public function testEnabledPatchInterval02()

public function testEnabledPatchInterval03()
{
if (!class_exists('\Memcached')) {
$this->markTestSkipped('Memcached extension is missing.');
return;
}

$memcachedClient = $this->createMock(MemcachedClient::class);
$httpReporter = $this->createMock(Reporter::class);
$memcached = new Memcached(['batch_interval' => 60], $httpReporter, $memcachedClient);
Expand All @@ -340,6 +400,11 @@ public function testEnabledPatchInterval03()

public function testResetBatchInterval()
{
if (!class_exists('\Memcached')) {
$this->markTestSkipped('PHP ext-memcached is required.');
return;
}

$memcachedClient = $this->createMock(MemcachedClient::class);
$httpReporter = $this->createMock(Reporter::class);
$memcached = new Memcached(['batch_interval' => -1], $httpReporter, $memcachedClient);
Expand All @@ -352,6 +417,11 @@ public function testResetBatchInterval()

public function testResetBatchIntervalError()
{
if (!class_exists('\Memcached')) {
$this->markTestSkipped('PHP ext-memcached is required.');
return;
}

$memcachedClient = $this->createMock(MemcachedClient::class);
$httpReporter = $this->createMock(Reporter::class);
$logger = $this->createMock(LoggerInterface::class);
Expand Down