Skip to content

Commit

Permalink
Fix Http\Client\Response::getStatusCode() should return int, but retu…
Browse files Browse the repository at this point in the history
…rn string currently.
  • Loading branch information
tenkoma committed Dec 21, 2016
1 parent 91974ae commit 6176a1e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Http/Client/Response.php
Expand Up @@ -195,7 +195,7 @@ protected function _parseHeaders($headers)
if (substr($value, 0, 5) === 'HTTP/') {
preg_match('/HTTP\/([\d.]+) ([0-9]+)(.*)/i', $value, $matches);
$this->protocol = $matches[1];
$this->code = $matches[2];
$this->code = (int)$matches[2];
$this->reasonPhrase = trim($matches[3]);
continue;
}
Expand Down
12 changes: 6 additions & 6 deletions tests/TestCase/Network/Http/ResponseTest.php
Expand Up @@ -36,7 +36,7 @@ public function testHeaderParsingPsr7()
$response = new Response($headers, 'winner!');

$this->assertEquals('1.0', $response->getProtocolVersion());
$this->assertEquals(200, $response->getStatusCode());
$this->assertSame(200, $response->getStatusCode());
$this->assertEquals('OK', $response->getReasonPhrase());
$this->assertEquals(
'text/html;charset="UTF-8"',
Expand All @@ -63,7 +63,7 @@ public function testHeaderParsing()
];
$response = new Response($headers, 'ok');

$this->assertEquals(200, $response->statusCode());
$this->assertSame(200, $response->statusCode());
$this->assertEquals('1.0', $response->version());
$this->assertEquals(
'text/html;charset="UTF-8"',
Expand All @@ -86,7 +86,7 @@ public function testHeaderParsing()
$response = new Response($headers, 'ok');

$this->assertEquals('1.0', $response->version());
$this->assertEquals(200, $response->statusCode());
$this->assertSame(200, $response->statusCode());
}

/**
Expand Down Expand Up @@ -342,10 +342,10 @@ public function testStatusCode()
'Content-Type: text/html'
];
$response = new Response($headers, '');
$this->assertEquals(404, $response->statusCode());
$this->assertEquals(404, $response->getStatusCode());
$this->assertSame(404, $response->statusCode());
$this->assertSame(404, $response->getStatusCode());

$this->assertEquals(404, $response->code);
$this->assertSame(404, $response->code);
$this->assertTrue(isset($response->code));
}

Expand Down

0 comments on commit 6176a1e

Please sign in to comment.