Skip to content

Commit

Permalink
fix(http): fixes the unit test for PSR15 server instrumentation as it…
Browse files Browse the repository at this point in the history
… was running the wrong test. (#183)
  • Loading branch information
jcchavezs authored Oct 21, 2020
1 parent 2071e1d commit 666d214
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 29 deletions.
17 changes: 1 addition & 16 deletions src/Zipkin/Instrumentation/Http/Server/Psr15/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,12 @@ final class Response extends ServerResponse
*/
private $request;

/**
* @var string|null
*/
private $route;

public function __construct(
ResponseInterface $delegate,
?Request $request = null,
?string $route = null
?Request $request = null
) {
$this->delegate = $delegate;
$this->request = $request;
$this->route = $route;
}

/**
Expand All @@ -51,14 +44,6 @@ public function getStatusCode(): int
return $this->delegate->getStatusCode();
}

/**
* {@inheritdoc}
*/
public function getRoute(): ?string
{
return $this->route;
}

/**
* {@inheritdoc}
*/
Expand Down
5 changes: 2 additions & 3 deletions tests/Unit/Instrumentation/Http/Server/BaseResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ abstract public static function createResponse(
$headers = [],
$body = null,
?Request $request = null,
?string $route = null
string $route = null
): array;

/**
Expand All @@ -38,10 +38,9 @@ public function testResponseIsCreatedSuccessfully(?Request $request): void
/**
* @var Response $response
*/
list($response, $delegateResponse, $_, $route) = static::createResponse(202, [], null, $request, "/things");
list($response, $delegateResponse) = static::createResponse(202, [], null, $request);
$this->assertEquals(202, $response->getStatusCode());
$this->assertSame($request, $response->getRequest());
$this->assertSame($delegateResponse, $response->unwrap());
$this->assertSame($route, $response->getRoute());
}
}
4 changes: 2 additions & 2 deletions tests/Unit/Instrumentation/Http/Server/Psr15/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace ZipkinTests\Unit\Instrumentation\Http\Server\Psr15;

use Zipkin\Instrumentation\Http\Client\Psr18\Request;
use ZipkinTests\Unit\Instrumentation\Http\Client\BaseRequestTest;
use Zipkin\Instrumentation\Http\Server\Psr15\Request;
use ZipkinTests\Unit\Instrumentation\Http\Server\BaseRequestTest;
use GuzzleHttp\Psr7\Request as Psr7Request;

final class RequestTest extends BaseRequestTest
Expand Down
16 changes: 8 additions & 8 deletions tests/Unit/Instrumentation/Http/Server/Psr15/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

namespace ZipkinTests\Unit\Instrumentation\Http\Server\Psr15;

use Zipkin\Instrumentation\Http\Client\Request;
use Zipkin\Instrumentation\Http\Client\Psr18\Response as Psr18Response;
use Zipkin\Instrumentation\Http\Client\Psr18\Request as Psr18Request;
use ZipkinTests\Unit\Instrumentation\Http\Client\BaseResponseTest;
use Zipkin\Instrumentation\Http\Server\Request;
use Zipkin\Instrumentation\Http\Server\Psr15\Response as Psr15Response;
use Zipkin\Instrumentation\Http\Server\Psr15\Request as Psr15Request;
use ZipkinTests\Unit\Instrumentation\Http\Server\BaseResponseTest;
use GuzzleHttp\Psr7\Response;
use GuzzleHttp\Psr7\Request as Psr7Request;

Expand All @@ -21,11 +21,11 @@ public static function createResponse(
$headers = [],
$body = null,
?Request $request = null,
?string $route = null
string $route = null
): array {
$delegateResponse = new Response($statusCode);
$response = new Psr18Response($delegateResponse, $request);
return [$response, $delegateResponse, $request, $route];
$response = new Psr15Response($delegateResponse, $request);
return [$response, $delegateResponse, $request];
}

/**
Expand All @@ -35,7 +35,7 @@ public static function requestsProvider(): array
{
return [
[null],
[new Psr18Request(new Psr7Request('GET', 'http://test.com/path'))],
[new Psr15Request(new Psr7Request('GET', 'http://test.com/path'))],
];
}
}

0 comments on commit 666d214

Please sign in to comment.