Skip to content

Commit

Permalink
Fixes test (#146)
Browse files Browse the repository at this point in the history
* tests: fixes RequestHeader test to prove RequestHeaders::put overrides existing value.

* docs: adds some explanation about retrieving the first value in the RequestHeaders::get.
  • Loading branch information
jcchavezs authored May 18, 2020
1 parent e69a395 commit 4e49ac5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/Zipkin/Propagation/RequestHeaders.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ final class RequestHeaders implements Getter, Setter
public function get($carrier, $key)
{
$lKey = strtolower($key);
// We return the first value becase we relay on the fact that we
// always override the header value when put method is called.
return $carrier->hasHeader($lKey) ? $carrier->getHeader($lKey)[0] : null;
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Propagation/RequestHeadersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public function testPutWritesTheExpectedValue()

public function testPutOverridesWithTheExpectedValue()
{
$request = new Request('GET', '/');
$requestHeaders = new RequestHeaders([self::TEST_KEY => 'foobar']);
$request = new Request('GET', '/', [self::TEST_KEY => 'foobar']);
$requestHeaders = new RequestHeaders();
$requestHeaders->put($request, self::TEST_KEY, self::TEST_VALUE);
$value = $requestHeaders->get($request, self::TEST_KEY);
$this->assertEquals(self::TEST_VALUE, $value);
Expand Down

0 comments on commit 4e49ac5

Please sign in to comment.