Skip to content

Commit

Permalink
tests: adds support for the rout e in the HTTP response.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcchavezs committed Oct 21, 2020
1 parent 5aba817 commit b831c7d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
24 changes: 22 additions & 2 deletions tests/Unit/Instrumentation/Http/Server/BaseResponseTest.php
Expand Up @@ -15,7 +15,8 @@ abstract class BaseResponseTest extends TestCase
* - Zipkin\Instrumentation\Http\Server\Response the response being.
* - mixed the delegated response.
* - Zipkin\Instrumentation\Http\Server\Request the request originating
* originating the response.
* the response.
* - string the route
*/
abstract public static function createResponse(
int $statusCode,
Expand All @@ -25,6 +26,15 @@ abstract public static function createResponse(
string $route = null
): array;

/**
* supportsRoute tells if the request implementation supports storing the
* route or not.
*/
protected static function supportsRoute(): bool
{
return false;
}

/**
* @return (Request|null)[][] the
*/
Expand All @@ -38,9 +48,19 @@ public function testResponseIsCreatedSuccessfully(?Request $request): void
/**
* @var Response $response
*/
list($response, $delegateResponse) = static::createResponse(202, [], null, $request);
list($response, $delegateResponse, $_, $route) = static::createResponse(
202, // status code
[], // headers
null, // body
$request, // request
'/users/{user_id}' //route
);

$this->assertEquals(202, $response->getStatusCode());
$this->assertSame($request, $response->getRequest());
$this->assertSame($delegateResponse, $response->unwrap());
if (self::supportsRoute()) {
$this->assertSame('/users/{user_id}', $route);
}
}
}
Expand Up @@ -25,7 +25,7 @@ public static function createResponse(
): array {
$delegateResponse = new Response($statusCode);
$response = new Psr15Response($delegateResponse, $request);
return [$response, $delegateResponse, $request];
return [$response, $delegateResponse, $request, null];
}

/**
Expand Down

0 comments on commit b831c7d

Please sign in to comment.