Skip to content

Commit 7493eb0

Browse files
committed
Merge pull request #2 from php-http/rename
Renames package to discovery
2 parents 667fc6b + ed01862 commit 7493eb0

15 files changed

+198
-198
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,33 @@
1-
# HTTP Guesser
1+
# HTTP Discovery
22

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

11-
**Guesses adapters and message factories.**
11+
**Finds installed adapters and message factories.**
1212

1313

1414
## Install
1515

1616
Via Composer
1717

1818
``` bash
19-
$ composer require php-http/guesser
19+
$ composer require php-http/discovery
2020
```
2121

2222

2323
## Usage
2424

25-
Guesser is a static container to easy auto initialization of objects.
25+
Static containers to ease the auto initialization of objects.
2626

27-
Currently the following guessers are in the package:
27+
Currently the following discovery strategies are available:
2828

29-
- Adapter
30-
- Message Factory
29+
- Http Adapter discovery
30+
- Message Factory discovery
3131

3232

3333
## Testing

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"name": "php-http/guesser",
3-
"description": "Guesses adapters and message factories",
2+
"name": "php-http/discovery",
3+
"description": "Finds installed adapters and message factories",
44
"license": "MIT",
5-
"keywords": ["http", "guesser", "adapter", "message", "factory"],
5+
"keywords": ["http", "discovery", "adapter", "message", "factory"],
66
"homepage": "http://php-http.org",
77
"authors": [
88
{
@@ -30,7 +30,7 @@
3030
},
3131
"autoload": {
3232
"psr-4": {
33-
"Http\\Guesser\\": "src/"
33+
"Http\\Discovery\\": "src/"
3434
}
3535
},
3636
"extra": {

phpspec.yml.ci

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
suites:
2-
guesser_suite:
3-
namespace: Http\Guesser
4-
psr4_prefix: Http\Guesser
2+
discovery_suite:
3+
namespace: Http\Discovery
4+
psr4_prefix: Http\Discovery
55
extensions:
66
- PhpSpec\Extension\CodeCoverageExtension
77
formatter.name: pretty

phpspec.yml.dist

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
suites:
2-
guesser_suite:
3-
namespace: Http\Guesser
4-
psr4_prefix: Http\Guesser
2+
discovery_suite:
3+
namespace: Http\Discovery
4+
psr4_prefix: Http\Discovery
55
formatter.name: pretty

spec/HttpAdapterDiscoverySpec.php

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
3+
namespace spec\Http\Discovery;
4+
5+
use PhpSpec\ObjectBehavior;
6+
7+
class HttpAdapterDiscoverySpec extends ObjectBehavior
8+
{
9+
function it_is_initializable()
10+
{
11+
$this->shouldHaveType('Http\Discovery\HttpAdapterDiscovery');
12+
}
13+
14+
function it_registers_a_factory()
15+
{
16+
$this->reset();
17+
18+
$this->register('guzzle6', 'spec\Http\Discovery\AnotherGuzzle6HttpAdapter');
19+
20+
$this->find()->shouldHaveType('spec\Http\Discovery\AnotherGuzzle6HttpAdapter');
21+
}
22+
23+
function it_resets_cache_when_a_factory_is_registered()
24+
{
25+
$this->reset();
26+
27+
$firstMatch = $this->find();
28+
29+
$this->register('guzzle6', 'spec\Http\Discovery\AnotherGuzzle6HttpAdapter');
30+
31+
$this->find()->shouldNotBe($firstMatch);
32+
}
33+
34+
function it_caches_a_found_adapter()
35+
{
36+
$this->reset();
37+
38+
$firstMatch = $this->find()->shouldHaveType('spec\Http\Discovery\Guzzle6HttpAdapter');
39+
40+
$this->find()->shouldReturn($firstMatch);
41+
}
42+
43+
function it_finds_guzzle6_then_guzzle5_by_default()
44+
{
45+
$this->reset();
46+
47+
$this->find()->shouldHaveType('spec\Http\Discovery\Guzzle6HttpAdapter');
48+
49+
$this->register('guzzle6', 'invalid', '');
50+
51+
$this->find()->shouldHaveType('spec\Http\Discovery\Guzzle5HttpAdapter');
52+
}
53+
54+
function it_throws_an_exception_when_no_adapter_is_found()
55+
{
56+
$this->reset();
57+
58+
$this->register('guzzle6', 'invalid', '');
59+
$this->register('guzzle5', 'invalid', '');
60+
61+
$this->shouldThrow('Http\Discovery\NotFoundException')->duringFind();
62+
}
63+
64+
function reset()
65+
{
66+
$this->register('guzzle5', 'spec\Http\Discovery\Guzzle5HttpAdapter');
67+
$this->register('guzzle6', 'spec\Http\Discovery\Guzzle6HttpAdapter');
68+
}
69+
}
70+
71+
class Guzzle5HttpAdapter {}
72+
class Guzzle6HttpAdapter {}
73+
class AnotherGuzzle6HttpAdapter {}

spec/HttpAdapterGuesserSpec.php

Lines changed: 0 additions & 73 deletions
This file was deleted.

spec/MessageFactory/DiactorosFactorySpec.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace spec\Http\Guesser\MessageFactory;
3+
namespace spec\Http\Discovery\MessageFactory;
44

55
use Psr\Http\Message\StreamInterface;
66
use PhpSpec\Exception\Example\SkippingException;
@@ -17,7 +17,7 @@ function let()
1717

1818
function it_is_initializable()
1919
{
20-
$this->shouldHaveType('Http\Guesser\MessageFactory\DiactorosFactory');
20+
$this->shouldHaveType('Http\Discovery\MessageFactory\DiactorosFactory');
2121
}
2222

2323
function it_is_a_message_factory()

spec/MessageFactory/GuzzleFactorySpec.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace spec\Http\Guesser\MessageFactory;
3+
namespace spec\Http\Discovery\MessageFactory;
44

55
use Psr\Http\Message\StreamInterface;
66
use PhpSpec\ObjectBehavior;
@@ -9,7 +9,7 @@ class GuzzleFactorySpec extends ObjectBehavior
99
{
1010
function it_is_initializable()
1111
{
12-
$this->shouldHaveType('Http\Guesser\MessageFactory\GuzzleFactory');
12+
$this->shouldHaveType('Http\Discovery\MessageFactory\GuzzleFactory');
1313
}
1414

1515
function it_is_a_message_factory()

spec/MessageFactoryDiscoverySpec.php

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<?php
2+
3+
namespace spec\Http\Discovery;
4+
5+
use PhpSpec\ObjectBehavior;
6+
7+
class MessageFactoryDiscoverySpec extends ObjectBehavior
8+
{
9+
function it_is_initializable()
10+
{
11+
$this->shouldHaveType('Http\Discovery\MessageFactoryDiscovery');
12+
}
13+
14+
function it_registers_a_factory()
15+
{
16+
$this->reset();
17+
18+
$this->register('guzzle', 'spec\Http\Discovery\TestClass', 'spec\Http\Discovery\Factory');
19+
20+
$this->find()->shouldHaveType('spec\Http\Discovery\Factory');
21+
}
22+
23+
function it_resets_cache_when_a_factory_is_registered()
24+
{
25+
$this->reset();
26+
27+
$firstGuess = $this->find();
28+
29+
$this->register('guzzle', 'spec\Http\Discovery\TestClass', 'spec\Http\Discovery\Factory');
30+
31+
$this->find()->shouldNotBe($firstGuess);
32+
}
33+
34+
function it_caches_a_found_message_factory()
35+
{
36+
$this->reset();
37+
38+
$firstGuess = $this->find()->shouldHaveType('Http\Discovery\MessageFactory\GuzzleFactory');
39+
40+
$this->find()->shouldReturn($firstGuess);
41+
}
42+
43+
function it_finds_guzzle_then_zend_by_default()
44+
{
45+
$this->reset();
46+
47+
$this->find()->shouldHaveType('Http\Discovery\MessageFactory\GuzzleFactory');
48+
49+
$this->register('guzzle', 'invalid', '');
50+
51+
if (class_exists('Zend\Diactoros\Request')) {
52+
$this->find()->shouldHaveType('Http\Discovery\MessageFactory\DiactorosFactory');
53+
}
54+
}
55+
56+
function it_throws_an_exception_when_no_message_factory_is_found()
57+
{
58+
$this->reset();
59+
60+
$this->register('guzzle', 'invalid', '');
61+
$this->register('diactoros', 'invalid', '');
62+
63+
$this->shouldThrow('Http\Discovery\NotFoundException')->duringFind();
64+
}
65+
66+
function reset()
67+
{
68+
$this->register('guzzle', 'GuzzleHttp\Psr7\Request', 'Http\Discovery\MessageFactory\GuzzleFactory');
69+
$this->register('diactoros', 'Zend\Diactoros\Request', 'Http\Discovery\MessageFactory\DiactorosFactory');
70+
}
71+
}
72+
73+
class TestClass {}
74+
class Factory {}

0 commit comments

Comments
 (0)