Skip to content

Commit f6503da

Browse files
committed
Merge pull request #40 from php-http/terminology
Terminology
2 parents 6a9bdad + 603d083 commit f6503da

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+1885
-390
lines changed

.gitattributes

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
spec/ export-ignore
12
.editorconfig export-ignore
23
.gitattributes export-ignore
34
.gitignore export-ignore
5+
.scrutinizer.yml export-ignore
6+
.travis.yml export-ignore
47
CONTRIBUTING.md export-ignore
8+
phpspec.yml.ci export-ignore
9+
phpspec.yml.dist export-ignore

.scrutinizer.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
filter:
2+
paths: [src/*]
3+
checks:
4+
php:
5+
code_rating: true
6+
duplication: true
7+
tools:
8+
external_code_coverage: true
9+
php_code_sniffer:
10+
config:
11+
standard: "PSR2"

.travis.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
language: php
2+
3+
sudo: false
4+
5+
php:
6+
- 5.4
7+
- 5.5
8+
- 5.6
9+
- 7.0
10+
- hhvm
11+
12+
env:
13+
global:
14+
- TEST_COMMAND="composer test"
15+
16+
matrix:
17+
allow_failures:
18+
- php: 7.0
19+
fast_finish: true
20+
include:
21+
- php: 5.4
22+
env:
23+
- COMPOSER_FLAGS="--prefer-stable --prefer-lowest"
24+
- COVERAGE=true
25+
- TEST_COMMAND="composer test-ci"
26+
27+
before_install:
28+
- travis_retry composer self-update
29+
30+
install:
31+
- travis_retry composer update ${COMPOSER_FLAGS} --prefer-source --no-interaction
32+
33+
script:
34+
- $TEST_COMMAND
35+
36+
after_success:
37+
- if [[ "$COVERAGE" = true ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi
38+
- if [[ "$COVERAGE" = true ]]; then php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml; fi

README.md

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,47 @@
1-
# HTTP Adapter
1+
# HTTP Client
22

3-
[![Latest Version](https://img.shields.io/github/release/php-http/adapter.svg?style=flat-square)](https://github.com/php-http/adapter/releases)
3+
[![Latest Version](https://img.shields.io/github/release/php-http/client.svg?style=flat-square)](https://github.com/php-http/client/releases)
44
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)
5-
[![Total Downloads](https://img.shields.io/packagist/dt/php-http/adapter.svg?style=flat-square)](https://packagist.org/packages/php-http/adapter)
5+
[![Build Status](https://img.shields.io/travis/php-http/client.svg?style=flat-square)](https://travis-ci.org/php-http/client)
6+
[![Code Coverage](https://img.shields.io/scrutinizer/coverage/g/php-http/client.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/client)
7+
[![Quality Score](https://img.shields.io/scrutinizer/g/php-http/client.svg?style=flat-square)](https://scrutinizer-ci.com/g/php-http/client)
8+
[![Total Downloads](https://img.shields.io/packagist/dt/php-http/client.svg?style=flat-square)](https://packagist.org/packages/php-http/client)
69

710
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/php-http/adapter?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
811

9-
**HTTP Adapter interfaces.**
12+
**HTTP Client interfaces.**
1013

1114

1215
## Install
1316

1417
Via Composer
1518

1619
``` bash
17-
$ composer require php-http/adapter
20+
$ composer require php-http/client
1821
```
1922

2023

2124
## Usage
2225

23-
This is the contract package for HTTP Adapter. It should be used when implementing a custom HTTP Adapter or to rely on a stable version of interfaces.
26+
This is the contract package for HTTP Client interfacess. PSR-7 does not contain Client interfaces which is fine. However there is still need for HTTP Client interoperability.
2427

25-
There is also a virtual package which is versioned together with this contract package: [php-http/adapter-implementation](https://packagist.org/providers/php-http/adapter-implementation).
28+
These interfaces are mostly used to create adapter packages around existing HTTP Client implementations.
29+
30+
There is also a virtual package which is versioned together with this contract package: [php-http/client-implementation](https://packagist.org/providers/php-http/client-implementation).
2631

2732

2833
## Documentation
2934

3035
Please see the [official documentation](http://php-http.readthedocs.org/en/latest/).
3136

3237

38+
## Testing
39+
40+
``` bash
41+
$ composer test
42+
```
43+
44+
3345
## Contributing
3446

3547
Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

composer.json

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"name": "php-http/adapter",
3-
"description": "HTTP Adapter interfaces",
2+
"name": "php-http/client",
3+
"description": "HTTP Client interfaces",
44
"license": "MIT",
5-
"keywords": ["http", "adapter"],
5+
"keywords": ["http", "client"],
66
"homepage": "http://php-http.org",
77
"authors": [
88
{
@@ -18,11 +18,19 @@
1818
"php": ">=5.4",
1919
"psr/http-message": "^1.0"
2020
},
21+
"require-dev": {
22+
"phpspec/phpspec": "^2.2",
23+
"henrikbjorn/phpspec-code-coverage" : "^1.0"
24+
},
2125
"autoload": {
2226
"psr-4": {
23-
"Http\\Adapter\\": "src/"
27+
"Http\\Client\\": "src/"
2428
}
2529
},
30+
"scripts": {
31+
"test": "vendor/bin/phpspec run",
32+
"test-ci": "vendor/bin/phpspec run -c phpspec.yml.ci"
33+
},
2634
"extra": {
2735
"branch-alias": {
2836
"dev-master": "0.2-dev"

phpspec.yml.ci

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
suites:
2+
client_suite:
3+
namespace: Http\Client
4+
psr4_prefix: Http\Client
5+
formatter.name: pretty
6+
extensions:
7+
- PhpSpec\Extension\CodeCoverageExtension
8+
code_coverage:
9+
format: clover
10+
output: build/coverage.xml

phpspec.yml.dist

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
suites:
2+
client_suite:
3+
namespace: Http\Client
4+
psr4_prefix: Http\Client
5+
formatter.name: pretty

spec/BatchResultSpec.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
namespace spec\Http\Client;
4+
5+
use Psr\Http\Message\RequestInterface;
6+
use Psr\Http\Message\ResponseInterface;
7+
use PhpSpec\ObjectBehavior;
8+
9+
class BatchResultSpec extends ObjectBehavior
10+
{
11+
function it_is_initializable()
12+
{
13+
$this->shouldHaveType('Http\Client\BatchResult');
14+
}
15+
16+
function it_is_immutable(RequestInterface $request, ResponseInterface $response)
17+
{
18+
$new = $this->addResponse($request, $response);
19+
20+
$this->getResponses()->shouldReturn([]);
21+
$new->shouldHaveType('Http\Client\BatchResult');
22+
$new->getResponses()->shouldReturn([$response]);
23+
}
24+
25+
function it_has_a_responses(RequestInterface $request, ResponseInterface $response)
26+
{
27+
$new = $this->addResponse($request, $response);
28+
29+
$this->hasResponses()->shouldReturn(false);
30+
$this->getResponses()->shouldReturn([]);
31+
$new->hasResponses()->shouldReturn(true);
32+
$new->getResponses()->shouldReturn([$response]);
33+
}
34+
35+
function it_has_a_response_for_a_request(RequestInterface $request, ResponseInterface $response)
36+
{
37+
$new = $this->addResponse($request, $response);
38+
39+
$this->shouldThrow('Http\Client\Exception\UnexpectedValueException')->duringGetResponseFor($request);
40+
$this->hasResponseFor($request)->shouldReturn(false);
41+
$new->getResponseFor($request)->shouldReturn($response);
42+
$new->hasResponseFor($request)->shouldReturn(true);
43+
}
44+
}

spec/Body/CombinedMultipartSpec.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
namespace spec\Http\Client\Body;
4+
5+
use PhpSpec\ObjectBehavior;
6+
7+
class CombinedMultipartSpec extends ObjectBehavior
8+
{
9+
protected $file;
10+
11+
function let()
12+
{
13+
$this->file = tempnam(sys_get_temp_dir(), 'multipart');
14+
15+
$this->beConstructedWith(['data' => 1], ['file' => $this->file], 'boundary');
16+
}
17+
18+
function it_is_initializable()
19+
{
20+
$this->shouldHaveType('Http\Client\Body\CombinedMultipart');
21+
}
22+
23+
function it_is_body()
24+
{
25+
$this->shouldImplement('Http\Client\Body');
26+
}
27+
28+
function it_is_multipart()
29+
{
30+
$this->shouldHaveType('Http\Client\Body\Multipart');
31+
}
32+
33+
function it_has_content_header()
34+
{
35+
$this->getContentHeaders()->shouldReturn(['Content-Type' => 'multipart/form-data; boundary=boundary']);
36+
}
37+
38+
function it_is_streamable()
39+
{
40+
$body = sprintf("--boundary\r\nContent-Disposition: form-data; name=\"data\"\r\n\r\n1\r\n--boundary\r\nContent-Disposition: form-data; name=\"file\"; filename=\"%s\"\r\n\r\n\r\n", basename($this->file));
41+
42+
$this->toStreamable()->shouldReturn($body);
43+
}
44+
}

spec/Body/FilesSpec.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
namespace spec\Http\Client\Body;
4+
5+
use PhpSpec\ObjectBehavior;
6+
7+
class FilesSpec extends ObjectBehavior
8+
{
9+
protected $file;
10+
11+
function let()
12+
{
13+
$this->file = tempnam(sys_get_temp_dir(), 'multipart');
14+
15+
$this->beConstructedWith(['file' => $this->file], 'boundary');
16+
}
17+
18+
function it_is_initializable()
19+
{
20+
$this->shouldHaveType('Http\Client\Body\Files');
21+
}
22+
23+
function it_is_body()
24+
{
25+
$this->shouldImplement('Http\Client\Body');
26+
}
27+
28+
function it_is_multipart()
29+
{
30+
$this->shouldHaveType('Http\Client\Body\Multipart');
31+
}
32+
33+
function it_has_content_header()
34+
{
35+
$this->getContentHeaders()->shouldReturn(['Content-Type' => 'multipart/form-data; boundary=boundary']);
36+
}
37+
38+
function it_is_streamable()
39+
{
40+
$body = sprintf("--boundary\r\nContent-Disposition: form-data; name=\"file\"; filename=\"%s\"\r\n\r\n\r\n", basename($this->file));
41+
42+
$this->toStreamable()->shouldReturn($body);
43+
}
44+
}

spec/Body/MultipartDataSpec.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace spec\Http\Client\Body;
4+
5+
use PhpSpec\ObjectBehavior;
6+
7+
class MultipartDataSpec extends ObjectBehavior
8+
{
9+
function let()
10+
{
11+
$this->beConstructedWith(['data' => 1], 'boundary');
12+
}
13+
14+
function it_is_initializable()
15+
{
16+
$this->shouldHaveType('Http\Client\Body\MultipartData');
17+
}
18+
19+
function it_is_body()
20+
{
21+
$this->shouldImplement('Http\Client\Body');
22+
}
23+
24+
function it_is_multipart()
25+
{
26+
$this->shouldHaveType('Http\Client\Body\Multipart');
27+
}
28+
29+
function it_has_content_header()
30+
{
31+
$this->getContentHeaders()->shouldReturn(['Content-Type' => 'multipart/form-data; boundary=boundary']);
32+
}
33+
34+
function it_is_streamable()
35+
{
36+
$body = "--boundary\r\nContent-Disposition: form-data; name=\"data\"\r\n\r\n1\r\n";
37+
38+
$this->toStreamable()->shouldReturn($body);
39+
}
40+
}

spec/Body/UrlencodedDataSpec.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace spec\Http\Client\Body;
4+
5+
use PhpSpec\ObjectBehavior;
6+
7+
class UrlencodedDataSpec extends ObjectBehavior
8+
{
9+
function let()
10+
{
11+
$this->beConstructedWith(['data1' => 1, 'data2' => 2]);
12+
}
13+
14+
function it_is_initializable()
15+
{
16+
$this->shouldHaveType('Http\Client\Body\UrlencodedData');
17+
}
18+
19+
function it_is_body()
20+
{
21+
$this->shouldImplement('Http\Client\Body');
22+
}
23+
24+
function it_has_content_header()
25+
{
26+
$this->getContentHeaders()->shouldReturn(['Content-Type' => 'application/x-www-form-urlencoded']);
27+
}
28+
29+
function it_is_streamable()
30+
{
31+
$this->toStreamable()->shouldReturn('data1=1&data2=2');
32+
}
33+
}

0 commit comments

Comments
 (0)