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

New upstream version 1.0.0

parent dc494cdc
No related branches found
No related tags found
No related merge requests found
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
spec/ export-ignore
tests/ export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.php_cs export-ignore
.scrutinizer.yml export-ignore
.styleci.yml export-ignore
.travis.yml export-ignore
CONTRIBUTING export-ignore
phpspec.yml.ci export-ignore
phpspec.yml.dist export-ignore
phpunit.xml.dist export-ignore
build/
vendor/
composer.lock
phpspec.yml
phpunit.xml
<?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"
enabled:
- short_array_syntax
language: php
sudo: false
cache:
directories:
- $HOME/.composer/cache
php:
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
env:
global:
- TEST_COMMAND="composer test"
branches:
except:
- /^analysis-.*$/
matrix:
fast_finish: true
include:
- php: 5.4
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" COVERAGE=true TEST_COMMAND="composer test-ci"
before_install:
- travis_retry composer self-update
install:
- travis_retry composer update ${COMPOSER_FLAGS} --prefer-source --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
Please see http://docs.php-http.org/en/latest/development/contributing.html
suites:
tools_suite:
namespace: Http\Promise
psr4_prefix: Http\Promise
formatter.name: pretty
extensions:
- PhpSpec\Extension\CodeCoverageExtension
code_coverage:
format: clover
output: build/coverage.xml
suites:
tools_suite:
namespace: Http\Promise
psr4_prefix: Http\Promise
formatter.name: pretty
<?php
namespace spec\Http\Promise;
use Http\Promise\Promise;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class FulfilledPromiseSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith('result');
}
function it_is_initializable()
{
$this->shouldHaveType('Http\Promise\FulfilledPromise');
}
function it_is_a_promise()
{
$this->shouldImplement('Http\Promise\Promise');
}
function it_returns_a_fulfilled_promise()
{
$promise = $this->then(function ($result) {
return $result;
});
$promise->shouldHaveType('Http\Promise\Promise');
$promise->shouldHaveType('Http\Promise\FulfilledPromise');
$promise->getState()->shouldReturn(Promise::FULFILLED);
$promise->wait()->shouldReturn('result');
}
function it_returns_a_rejected_promise()
{
$exception = new \Exception();
$promise = $this->then(function () use ($exception) {
throw $exception;
});
$promise->shouldHaveType('Http\Promise\Promise');
$promise->shouldHaveType('Http\Promise\RejectedPromise');
$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_result()
{
$this->wait()->shouldReturn('result');
}
function it_does_not_unwrap_a_value()
{
$this->wait(false)->shouldNotReturn('result');
}
}
<?php
namespace spec\Http\Promise;
use Http\Promise\Promise;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
class RejectedPromiseSpec extends ObjectBehavior
{
function let()
{
$this->beConstructedWith(new \Exception());
}
function it_is_initializable()
{
$this->shouldHaveType('Http\Promise\RejectedPromise');
}
function it_is_a_promise()
{
$this->shouldImplement('Http\Promise\Promise');
}
function it_returns_a_fulfilled_promise()
{
$exception = new \Exception();
$this->beConstructedWith($exception);
$promise = $this->then(null, function (\Exception $exceptionReceived) use($exception) {
return 'result';
});
$promise->shouldHaveType('Http\Promise\Promise');
$promise->shouldHaveType('Http\Promise\FulfilledPromise');
$promise->getState()->shouldReturn(Promise::FULFILLED);
$promise->wait()->shouldReturn('result');
}
function it_returns_a_rejected_promise()
{
$exception = new \Exception();
$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\Promise\RejectedPromise');
$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 \Exception();
$this->beConstructedWith($exception);
$this->shouldThrow($exception)->duringWait();
}
function it_does_not_unwrap_a_value()
{
$this->shouldNotThrow('Exception')->duringWait(false);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment