Skip to content

Conversation

@gotoeveryone
Copy link
Contributor

At the moment, Cake\Http\Client\Response::isOk() allow to status code between 200 and 202.
But Cake\TestSuite\IntegrationTestCase::assertResponseOk() allow to status code between 200 and 204.

For example, Status code 204 using to succeed response at DELETE method by API call.

Call to http://example.com with delete method.

  • Use Cake\Http\Client
// use Cake\Http\Client;
$http = new Client();

// Status code is `204`
$response = $http->delete('http://example.com', $data, $headers);
$body = $response->getBody();
$this->response = $this->response->withStatus($response->getStatusCode());

// `204` is false
if ($response->isOk()) {
    return 'OK';
}
return 'NG';
  • Use Cake\TestSuite\IntegrationTestCase
// TestCase
$this->enableCsrfToken();
$this->delete('http://example.com', $data);
$this->assertResponseOk(); // `204` is OK

@codecov-io
Copy link

codecov-io commented Dec 9, 2017

Codecov Report

Merging #11521 into master will increase coverage by 0.49%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #11521      +/-   ##
============================================
+ Coverage      92.9%   93.39%   +0.49%     
  Complexity    13028    13028              
============================================
  Files           436      436              
  Lines         32775    32777       +2     
============================================
+ Hits          30448    30611     +163     
+ Misses         2327     2166     -161
Impacted Files Coverage Δ Complexity Δ
src/Http/Client/Message.php 0% <ø> (ø) 4 <0> (ø) ⬇️
src/Http/Client/Response.php 93.08% <100%> (+0.08%) 55 <0> (ø) ⬇️
src/Cache/Engine/FileEngine.php 90.1% <0%> (+1.09%) 73% <0%> (ø) ⬇️
src/Database/QueryCompiler.php 99.09% <0%> (+1.81%) 46% <0%> (ø) ⬇️
src/Cache/CacheRegistry.php 100% <0%> (+4.16%) 11% <0%> (ø) ⬇️
src/Database/Expression/Comparison.php 100% <0%> (+4.76%) 35% <0%> (ø) ⬇️
src/Database/Expression/TupleComparison.php 100% <0%> (+4.91%) 26% <0%> (ø) ⬇️
src/Database/Statement/StatementDecorator.php 94.23% <0%> (+7.69%) 26% <0%> (ø) ⬇️
src/Database/Driver/Sqlite.php 96.29% <0%> (+18.51%) 12% <0%> (ø) ⬇️
src/Database/Statement/BufferedStatement.php 100% <0%> (+20.51%) 15% <0%> (ø) ⬇️
... and 4 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 829778d...9dbdfd5. Read the comment docs.

@markstory markstory added this to the 3.5.8 milestone Dec 9, 2017
@markstory markstory merged commit 3692f76 into cakephp:master Dec 9, 2017
@markstory
Copy link
Member

Thank you!

@markstory markstory added the http label Dec 9, 2017
@gotoeveryone gotoeveryone deleted the features/client-204 branch December 10, 2017 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants