Skip to content

Commit

Permalink
Fix assertion in ServerTests
Browse files Browse the repository at this point in the history
  • Loading branch information
legionth authored and WyriHaximus committed Feb 7, 2017
1 parent 8d6272a commit 2dfe98e
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions tests/ServerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

namespace React\Tests\Http;

use React\Http\RequestHeaderParser;
use React\Http\Server;
use React\Http\Response;
use React\Http\Request;

class ServerTest extends TestCase
{
Expand All @@ -26,17 +27,14 @@ public function testRequestEvent()
$io = new ServerStub();

$i = 0;
$requestAssertion = null;
$responseAssertion = null;

$server = new Server($io);
$server->on('request', function ($request, $response) use (&$i) {
$server->on('request', function (Request $request, Response $response) use (&$i, &$requestAssertion, &$responseAssertion) {
$i++;

$this->assertInstanceOf('React\Http\Request', $request);
$this->assertSame('/', $request->getPath());
$this->assertSame('GET', $request->getMethod());
$this->assertSame('127.0.0.1', $request->remoteAddress);

$this->assertInstanceOf('React\Http\Response', $response);
$requestAssertion = $request;
$responseAssertion = $response;
});

$conn = new ConnectionStub();
Expand All @@ -46,14 +44,20 @@ public function testRequestEvent()
$conn->emit('data', array($data));

$this->assertSame(1, $i);
$this->assertInstanceOf('React\Http\Request', $requestAssertion);
$this->assertSame('/', $requestAssertion->getPath());
$this->assertSame('GET', $requestAssertion->getMethod());
$this->assertSame('127.0.0.1', $requestAssertion->remoteAddress);

$this->assertInstanceOf('React\Http\Response', $responseAssertion);
}

public function testResponseContainsPoweredByHeader()
{
$io = new ServerStub();

$server = new Server($io);
$server->on('request', function ($request, $response) {
$server->on('request', function (Request $request, Response $response) {
$response->writeHead();
$response->end();
});
Expand Down

0 comments on commit 2dfe98e

Please sign in to comment.