Skip to content
Snippets Groups Projects
Commit ab8cc337 authored by David Prévot's avatar David Prévot
Browse files

New upstream version 2.0.0

parent b3842537
Branches
Tags upstream/2.0.0
No related merge requests found
Showing with 0 additions and 474 deletions
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
.editorconfig export-ignore
.gitattributes export-ignore
/.github/ export-ignore
.gitignore export-ignore
/.php_cs export-ignore
/.scrutinizer.yml export-ignore
/.styleci.yml export-ignore
/.travis.yml export-ignore
/behat.yml.dist export-ignore
/features/ export-ignore
/phpspec.ci.yml export-ignore
/phpspec.yml.dist export-ignore
/phpunit.xml.dist export-ignore
/spec/ export-ignore
/tests/ export-ignore
# Contributing
Please see our [contributing guide](http://docs.php-http.org/en/latest/development/contributing.html).
| Q | A
| ------------ | ---
| Bug? | no|yes
| New Feature? | no|yes
| Version | Specific version or SHA of a commit
#### Actual Behavior
What is the actual behavior?
#### Expected Behavior
What is the behavior you expect?
#### Steps to Reproduce
What are the steps to reproduce this bug? Please add code examples,
screenshots or links to GitHub repositories that reproduce the problem.
#### Possible Solutions
If you have already ideas how to solve the issue, add them here.
(remove this section if not needed)
| Q | A
| --------------- | ---
| Bug fix? | no|yes
| New feature? | no|yes
| BC breaks? | no|yes
| Deprecations? | no|yes
| Related tickets | fixes #X, partially #Y, mentioned in #Z
| Documentation | if this is a new feature, link to pull request in https://github.com/php-http/documentation that adds relevant documentation
| License | MIT
#### What's in this PR?
Explain what the changes in this PR do.
#### Why?
Which problem does the PR fix? (remove this section if you linked an issue above)
#### Example Usage
``` php
// If you added new features, show examples of how to use them here
// (remove this section if not a new feature)
$foo = new Foo();
// Now we can do
$foo->doSomething();
```
#### Checklist
- [ ] Updated CHANGELOG.md to describe BC breaks / deprecations | new feature | bugfix
- [ ] Documentation pull request created (if not simply a bugfix)
#### To Do
- [ ] If the PR is not complete but you want to discuss the approach, list what remains to be done here
/behat.yml
/build/
/composer.lock
/phpspec.yml
/phpunit.xml
/vendor/
<?php
/*
* In order to make it work, fabpot/php-cs-fixer and sllh/php-cs-fixer-styleci-bridge must be installed globally
* with composer.
*
* @link https://github.com/Soullivaneuh/php-cs-fixer-styleci-bridge
* @link https://github.com/FriendsOfPHP/PHP-CS-Fixer
*/
use SLLH\StyleCIBridge\ConfigBridge;
return ConfigBridge::create();
filter:
paths: [src/*]
checks:
php:
code_rating: true
duplication: true
tools:
external_code_coverage: true
preset: symfony
finder:
exclude:
- "spec"
path:
- "src"
- "tests"
enabled:
- short_array_syntax
disabled:
- phpdoc_annotation_without_dot # This is still buggy: https://github.com/symfony/symfony/pull/19198
language: php
sudo: false
cache:
directories:
- $HOME/.composer/cache/files
php:
- 7.0
- 7.1
- 7.2
- 7.3
env:
global:
- TEST_COMMAND="composer test"
branches:
except:
- /^analysis-.*$/
matrix:
fast_finish: true
include:
- php: 7.0
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" COVERAGE=true TEST_COMMAND="composer test-ci"
before_install:
- if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi
install:
- travis_retry composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction
script:
- $TEST_COMMAND
after_success:
- if [[ $COVERAGE = true ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi
- if [[ $COVERAGE = true ]]; then php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml; fi
suites:
client_suite:
namespace: Http\Client
psr4_prefix: Http\Client
formatter.name: pretty
extensions:
- PhpSpec\Extension\CodeCoverageExtension
code_coverage:
format: clover
output: build/coverage.xml
suites:
client_suite:
namespace: Http\Client
psr4_prefix: Http\Client
formatter.name: pretty
<?php
namespace spec\Http\Client\Exception;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
use PhpSpec\ObjectBehavior;
class HttpExceptionSpec extends ObjectBehavior
{
function let(RequestInterface $request, ResponseInterface $response)
{
$this->beConstructedWith('message', $request, $response);
}
function it_is_initializable()
{
$this->shouldHaveType('Http\Client\Exception\HttpException');
}
function it_is_a_request_exception()
{
$this->shouldHaveType('Http\Client\Exception\RequestException');
}
function it_has_a_response(ResponseInterface $response)
{
$this->getResponse()->shouldReturn($response);
}
function it_creates_an_http_exception(RequestInterface $request, ResponseInterface $response)
{
$request->getRequestTarget()->willReturn('/uri');
$request->getMethod()->willReturn('GET');
$response->getStatusCode()->willReturn(100);
$response->getReasonPhrase()->willReturn('Continue');
$e = $this->create($request, $response);
$e->shouldHaveType('Http\Client\Exception\HttpException');
$e->getMessage()->shouldReturn('[url] /uri [http method] GET [status code] 100 [reason phrase] Continue');
}
}
<?php
namespace spec\Http\Client\Exception;
use Psr\Http\Message\RequestInterface;
use PhpSpec\ObjectBehavior;
class NetworkExceptionSpec extends ObjectBehavior
{
function let(RequestInterface $request)
{
$this->beConstructedWith('message', $request);
}
function it_is_initializable()
{
$this->shouldHaveType('Http\Client\Exception\NetworkException');
}
function it_is_a_request_exception()
{
$this->shouldHaveType('Http\Client\Exception\RequestException');
}
}
<?php
namespace spec\Http\Client\Exception;
use Http\Client\Exception\RequestException;
use Psr\Http\Message\RequestInterface;
use PhpSpec\ObjectBehavior;
class RequestExceptionSpec extends ObjectBehavior
{
function let(RequestInterface $request)
{
$this->beConstructedWith('message', $request);
}
function it_is_initializable()
{
$this->shouldHaveType('Http\Client\Exception\RequestException');
}
function it_is_a_transfer_exception()
{
$this->shouldHaveType('Http\Client\Exception\TransferException');
}
function it_has_a_request(RequestInterface $request)
{
$this->getRequest()->shouldReturn($request);
}
}
<?php
namespace spec\Http\Client\Exception;
use PhpSpec\ObjectBehavior;
class TransferExceptionSpec extends ObjectBehavior
{
function it_is_a_runtime_exception()
{
$this->shouldHaveType('RuntimeException');
}
function it_is_an_exception()
{
$this->shouldImplement('Http\Client\Exception');
}
}
<?php
namespace spec\Http\Client\Promise;
use Http\Client\Exception\TransferException;
use Http\Promise\Promise;
use PhpSpec\ObjectBehavior;
use Psr\Http\Message\ResponseInterface;
class HttpFulfilledPromiseSpec extends ObjectBehavior
{
function let(ResponseInterface $response)
{
$this->beConstructedWith($response);
}
function it_is_initializable()
{
$this->shouldHaveType('Http\Client\Promise\HttpFulfilledPromise');
}
function it_is_a_promise()
{
$this->shouldImplement('Http\Promise\Promise');
}
function it_returns_a_http_fulfilled_promise()
{
$promise = $this->then(function ($result) {
return $result;
});
$promise->shouldHaveType('Http\Promise\Promise');
$promise->shouldHaveType('Http\Client\Promise\HttpFulfilledPromise');
$promise->getState()->shouldReturn(Promise::FULFILLED);
$promise->wait()->shouldReturnAnInstanceOf('Psr\Http\Message\ResponseInterface');
}
function it_returns_a_http_rejected_promise()
{
$exception = new TransferException();
$promise = $this->then(function () use ($exception) {
throw $exception;
});
$promise->shouldHaveType('Http\Promise\Promise');
$promise->shouldHaveType('Http\Client\Promise\HttpRejectedPromise');
$promise->getState()->shouldReturn(Promise::REJECTED);
$promise->shouldThrow($exception)->duringWait();
}
function it_returns_itself_when_no_on_fulfilled_callback_is_passed()
{
$this->then()->shouldReturn($this);
}
function it_is_in_fulfilled_state()
{
$this->getState()->shouldReturn(Promise::FULFILLED);
}
function it_has_a_response()
{
$this->wait()->shouldReturnAnInstanceOf('Psr\Http\Message\ResponseInterface');
}
function it_does_not_unwrap_a_response()
{
$this->wait(false)->shouldNotReturnAnInstanceOf('Psr\Http\Message\ResponseInterface');
}
function it_throws_not_http_exception()
{
$this->shouldThrow('Exception')->duringThen(function () {
throw new \Exception();
}, null);
}
}
<?php
namespace spec\Http\Client\Promise;
use Http\Client\Exception;
use Http\Client\Exception\TransferException;
use Http\Promise\Promise;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
use Psr\Http\Message\ResponseInterface;
class HttpRejectedPromiseSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith(new TransferException());
}
function it_is_initializable()
{
$this->shouldHaveType('Http\Client\Promise\HttpRejectedPromise');
}
function it_is_a_promise()
{
$this->shouldImplement('Http\Promise\Promise');
}
function it_returns_a_fulfilled_promise(ResponseInterface $response)
{
$exception = new TransferException();
$this->beConstructedWith($exception);
$promise = $this->then(null, function (Exception $exceptionReceived) use($exception, $response) {
return $response->getWrappedObject();
});
$promise->shouldHaveType('Http\Promise\Promise');
$promise->shouldHaveType('Http\Client\Promise\HttpFulfilledPromise');
$promise->getState()->shouldReturn(Promise::FULFILLED);
$promise->wait()->shouldReturnAnInstanceOf('Psr\Http\Message\ResponseInterface');
}
function it_returns_a_rejected_promise()
{
$exception = new TransferException();
$this->beConstructedWith($exception);
$promise = $this->then(null, function (Exception $exceptionReceived) use($exception) {
if (Argument::is($exceptionReceived)->scoreArgument($exception)) {
throw $exception;
}
});
$promise->shouldHaveType('Http\Promise\Promise');
$promise->shouldHaveType('Http\Client\Promise\HttpRejectedPromise');
$promise->getState()->shouldReturn(Promise::REJECTED);
$promise->shouldThrow($exception)->duringWait();
}
function it_returns_itself_when_no_on_rejected_callback_is_passed()
{
$this->then()->shouldReturn($this);
}
function it_is_in_rejected_state()
{
$this->getState()->shouldReturn(Promise::REJECTED);
}
function it_returns_an_exception()
{
$exception = new TransferException();
$this->beConstructedWith($exception);
$this->shouldThrow($exception)->duringWait();
}
function it_does_not_unwrap_a_value()
{
$this->shouldNotThrow('Http\Client\Exception')->duringWait(false);
}
function it_throws_not_http_exception()
{
$this->shouldThrow('Exception')->duringThen(null, function () {
throw new \Exception();
});
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment