Skip to content

Commit

Permalink
Rewind request body - tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mrceperka authored and chadicus committed Nov 22, 2017
1 parent 9e26cfc commit a465120
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/RequestBridgeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,4 +153,25 @@ public function toOAuth2WithAuthorization()

$this->assertSame('Bearer abc123', $oauth2Request->headers('AUTHORIZATION'));
}

/**
* Verify that steam contents of a passed request is preserved (read and rewound).
*
* @test
* @covers ::toOAuth2
*
* @return void
*/
public function toOAuth2BodyContentsOfRequestPreserved()
{
$uri = 'https://example.com/foos';

$psr7Request = new ServerRequest([], [], $uri, 'POST', fopen(__DIR__ . '/_data/foo', 'r'));

$oauth2Request = RequestBridge::toOAuth2($psr7Request);

$this->assertSame('foo', $psr7Request->getBody()->getContents());
$this->assertSame('foo', $oauth2Request->getContent());
}

}
1 change: 1 addition & 0 deletions tests/_data/foo
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
foo

0 comments on commit a465120

Please sign in to comment.