New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add to `203` and `204` allowed status code at `Cake\Http\Client\Response::isOk()` #11521

Merged
merged 1 commit into from Dec 9, 2017

Conversation

Projects
None yet
3 participants
@gotoeveryone
Contributor

gotoeveryone commented Dec 9, 2017

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

This comment has been minimized.

Show comment
Hide comment
@codecov-io

codecov-io 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.

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

5 checks passed

codecov/patch 100% of diff hit (target 92.9%)
Details
codecov/project 93.39% (+0.49%) compared to 829778d
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
stickler-ci No lint errors found.
@markstory

This comment has been minimized.

Show comment
Hide comment
@markstory

markstory Dec 9, 2017

Member

Thank you!

Member

markstory commented Dec 9, 2017

Thank you!

@markstory markstory added the http label Dec 9, 2017

@gotoeveryone gotoeveryone deleted the gotoeveryone:features/client-204 branch Dec 10, 2017

@dereuromark dereuromark referenced this pull request Dec 12, 2017

Closed

4.0 Client::isOk() vs Client::is2xx()? #11536

2 of 2 tasks complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment