Skip to content

Renames package to discovery #2

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

Merged
merged 1 commit into from
Jun 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
# HTTP Guesser
# HTTP Discovery

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

**Guesses adapters and message factories.**
**Finds installed adapters and message factories.**


## Install

Via Composer

``` bash
$ composer require php-http/guesser
$ composer require php-http/discovery
```


## Usage

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

Currently the following guessers are in the package:
Currently the following discovery strategies are available:

- Adapter
- Message Factory
- Http Adapter discovery
- Message Factory discovery


## Testing
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "php-http/guesser",
"description": "Guesses adapters and message factories",
"name": "php-http/discovery",
"description": "Finds installed adapters and message factories",
"license": "MIT",
"keywords": ["http", "guesser", "adapter", "message", "factory"],
"keywords": ["http", "discovery", "adapter", "message", "factory"],
"homepage": "http://php-http.org",
"authors": [
{
Expand Down Expand Up @@ -30,7 +30,7 @@
},
"autoload": {
"psr-4": {
"Http\\Guesser\\": "src/"
"Http\\Discovery\\": "src/"
}
},
"extra": {
Expand Down
6 changes: 3 additions & 3 deletions phpspec.yml.ci
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
suites:
guesser_suite:
namespace: Http\Guesser
psr4_prefix: Http\Guesser
discovery_suite:
namespace: Http\Discovery
psr4_prefix: Http\Discovery
extensions:
- PhpSpec\Extension\CodeCoverageExtension
formatter.name: pretty
Expand Down
6 changes: 3 additions & 3 deletions phpspec.yml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
suites:
guesser_suite:
namespace: Http\Guesser
psr4_prefix: Http\Guesser
discovery_suite:
namespace: Http\Discovery
psr4_prefix: Http\Discovery
formatter.name: pretty
73 changes: 73 additions & 0 deletions spec/HttpAdapterDiscoverySpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

namespace spec\Http\Discovery;

use PhpSpec\ObjectBehavior;

class HttpAdapterDiscoverySpec extends ObjectBehavior
{
function it_is_initializable()
{
$this->shouldHaveType('Http\Discovery\HttpAdapterDiscovery');
}

function it_registers_a_factory()
{
$this->reset();

$this->register('guzzle6', 'spec\Http\Discovery\AnotherGuzzle6HttpAdapter');

$this->find()->shouldHaveType('spec\Http\Discovery\AnotherGuzzle6HttpAdapter');
}

function it_resets_cache_when_a_factory_is_registered()
{
$this->reset();

$firstMatch = $this->find();

$this->register('guzzle6', 'spec\Http\Discovery\AnotherGuzzle6HttpAdapter');

$this->find()->shouldNotBe($firstMatch);
}

function it_caches_a_found_adapter()
{
$this->reset();

$firstMatch = $this->find()->shouldHaveType('spec\Http\Discovery\Guzzle6HttpAdapter');

$this->find()->shouldReturn($firstMatch);
}

function it_finds_guzzle6_then_guzzle5_by_default()
{
$this->reset();

$this->find()->shouldHaveType('spec\Http\Discovery\Guzzle6HttpAdapter');

$this->register('guzzle6', 'invalid', '');

$this->find()->shouldHaveType('spec\Http\Discovery\Guzzle5HttpAdapter');
}

function it_throws_an_exception_when_no_adapter_is_found()
{
$this->reset();

$this->register('guzzle6', 'invalid', '');
$this->register('guzzle5', 'invalid', '');

$this->shouldThrow('Http\Discovery\NotFoundException')->duringFind();
}

function reset()
{
$this->register('guzzle5', 'spec\Http\Discovery\Guzzle5HttpAdapter');
$this->register('guzzle6', 'spec\Http\Discovery\Guzzle6HttpAdapter');
}
}

class Guzzle5HttpAdapter {}
class Guzzle6HttpAdapter {}
class AnotherGuzzle6HttpAdapter {}
73 changes: 0 additions & 73 deletions spec/HttpAdapterGuesserSpec.php

This file was deleted.

4 changes: 2 additions & 2 deletions spec/MessageFactory/DiactorosFactorySpec.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace spec\Http\Guesser\MessageFactory;
namespace spec\Http\Discovery\MessageFactory;

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

function it_is_initializable()
{
$this->shouldHaveType('Http\Guesser\MessageFactory\DiactorosFactory');
$this->shouldHaveType('Http\Discovery\MessageFactory\DiactorosFactory');
}

function it_is_a_message_factory()
Expand Down
4 changes: 2 additions & 2 deletions spec/MessageFactory/GuzzleFactorySpec.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace spec\Http\Guesser\MessageFactory;
namespace spec\Http\Discovery\MessageFactory;

use Psr\Http\Message\StreamInterface;
use PhpSpec\ObjectBehavior;
Expand All @@ -9,7 +9,7 @@ class GuzzleFactorySpec extends ObjectBehavior
{
function it_is_initializable()
{
$this->shouldHaveType('Http\Guesser\MessageFactory\GuzzleFactory');
$this->shouldHaveType('Http\Discovery\MessageFactory\GuzzleFactory');
}

function it_is_a_message_factory()
Expand Down
74 changes: 74 additions & 0 deletions spec/MessageFactoryDiscoverySpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

namespace spec\Http\Discovery;

use PhpSpec\ObjectBehavior;

class MessageFactoryDiscoverySpec extends ObjectBehavior
{
function it_is_initializable()
{
$this->shouldHaveType('Http\Discovery\MessageFactoryDiscovery');
}

function it_registers_a_factory()
{
$this->reset();

$this->register('guzzle', 'spec\Http\Discovery\TestClass', 'spec\Http\Discovery\Factory');

$this->find()->shouldHaveType('spec\Http\Discovery\Factory');
}

function it_resets_cache_when_a_factory_is_registered()
{
$this->reset();

$firstGuess = $this->find();

$this->register('guzzle', 'spec\Http\Discovery\TestClass', 'spec\Http\Discovery\Factory');

$this->find()->shouldNotBe($firstGuess);
}

function it_caches_a_found_message_factory()
{
$this->reset();

$firstGuess = $this->find()->shouldHaveType('Http\Discovery\MessageFactory\GuzzleFactory');

$this->find()->shouldReturn($firstGuess);
}

function it_finds_guzzle_then_zend_by_default()
{
$this->reset();

$this->find()->shouldHaveType('Http\Discovery\MessageFactory\GuzzleFactory');

$this->register('guzzle', 'invalid', '');

if (class_exists('Zend\Diactoros\Request')) {
$this->find()->shouldHaveType('Http\Discovery\MessageFactory\DiactorosFactory');
}
}

function it_throws_an_exception_when_no_message_factory_is_found()
{
$this->reset();

$this->register('guzzle', 'invalid', '');
$this->register('diactoros', 'invalid', '');

$this->shouldThrow('Http\Discovery\NotFoundException')->duringFind();
}

function reset()
{
$this->register('guzzle', 'GuzzleHttp\Psr7\Request', 'Http\Discovery\MessageFactory\GuzzleFactory');
$this->register('diactoros', 'Zend\Diactoros\Request', 'Http\Discovery\MessageFactory\DiactorosFactory');
}
}

class TestClass {}
class Factory {}
Loading