Skip to content

Commit

Permalink
Merge pull request php-http#25 from php-http/subnamespace
Browse files Browse the repository at this point in the history
Move adapter into subnamespace
  • Loading branch information
sagikazarmark committed Dec 31, 2015
2 parents 50831e5 + 7fa7654 commit b2bfbe5
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 41 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@
},
"autoload": {
"psr-4": {
"Http\\Adapter\\": "src/"
"Http\\Adapter\\Guzzle6\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Http\\Adapter\\Tests\\": "tests/"
"Http\\Adapter\\Guzzle6\\Tests\\": "tests/"
}
},
"scripts": {
Expand Down
10 changes: 5 additions & 5 deletions src/Guzzle6HttpAdapter.php → src/Client.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

namespace Http\Adapter;
namespace Http\Adapter\Guzzle6;

use GuzzleHttp\Client;
use GuzzleHttp\Client as GuzzleClient;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
Expand All @@ -16,7 +16,7 @@
*
* @author David de Boer <[email protected]>
*/
class Guzzle6HttpAdapter implements HttpClient, HttpAsyncClient
class Client implements HttpClient, HttpAsyncClient
{
use HttpClientEmulator;

Expand All @@ -33,7 +33,7 @@ public function __construct(ClientInterface $client = null)
if (!$client) {
$handlerStack = new HandlerStack(\GuzzleHttp\choose_handler());
$handlerStack->push(Middleware::prepareBody(), 'prepare_body');
$client = new Client(['handler' => $handlerStack]);
$client = new GuzzleClient(['handler' => $handlerStack]);
}
$this->client = $client;
}
Expand All @@ -45,6 +45,6 @@ public function sendAsyncRequest(RequestInterface $request)
{
$promise = $this->client->sendAsync($request);

return new Guzzle6Promise($promise, $request);
return new Promise($promise, $request);
}
}
6 changes: 3 additions & 3 deletions src/Guzzle6Promise.php → src/Promise.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

namespace Http\Adapter;
namespace Http\Adapter\Guzzle6;

use GuzzleHttp\Exception as GuzzleExceptions;
use GuzzleHttp\Promise\PromiseInterface;
use Http\Client\Exception as HttplugException;
use Http\Promise\Promise;
use Http\Promise\Promise as HttpPromise;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

Expand All @@ -14,7 +14,7 @@
*
* @author Joel Wurtz <[email protected]>
*/
class Guzzle6Promise implements Promise
class Promise implements HttpPromise
{
/**
* @var PromiseInterface
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Http\Adapter\Tests;
namespace Http\Adapter\Guzzle6\Tests;

use GuzzleHttp\Handler\CurlHandler;

Expand All @@ -9,7 +9,7 @@
*
* @author GeLo <[email protected]>
*/
class Guzzle6CurlHttpAdapterTest extends Guzzle6HttpAdapterTest
class CurlHttpAdapterTest extends HttpAdapterTest
{
/**
* {@inheritdoc}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Http\Adapter\Tests;
namespace Http\Adapter\Guzzle6\Tests;

use GuzzleHttp\Handler\CurlHandler;

Expand All @@ -9,7 +9,7 @@
*
* @author Joel Wurtz <[email protected]>
*/
class Guzzle6CurlHttpAsyncAdapterTest extends Guzzle6HttpAsyncAdapterTest
class CurlHttpAsyncAdapterTest extends HttpAsyncAdapterTest
{
/**
* {@inheritdoc}
Expand Down
10 changes: 5 additions & 5 deletions tests/Guzzle6HttpAdapterTest.php → tests/HttpAdapterTest.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?php

namespace Http\Adapter\Tests;
namespace Http\Adapter\Guzzle6\Tests;

use GuzzleHttp\Client;
use Http\Adapter\Guzzle6HttpAdapter;
use GuzzleHttp\Client as GuzzleClient;
use Http\Adapter\Guzzle6\Client;
use Http\Client\Tests\HttpClientTest;

/**
* @author GeLo <[email protected]>
*/
abstract class Guzzle6HttpAdapterTest extends HttpClientTest
abstract class HttpAdapterTest extends HttpClientTest
{
/**
* {@inheritdoc}
*/
protected function createHttpAdapter()
{
return new Guzzle6HttpAdapter(new Client(['handler' => $this->createHandler()]));
return new Client(new GuzzleClient(['handler' => $this->createHandler()]));
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?php

namespace Http\Adapter\Tests;
namespace Http\Adapter\Guzzle6\Tests;

use GuzzleHttp\Client;
use Http\Adapter\Guzzle6HttpAdapter;
use GuzzleHttp\Client as GuzzleClient;
use Http\Adapter\Guzzle6\Client;
use Http\Client\Tests\HttpAsyncClientTest;

/**
* @author Joel Wurtz <[email protected]>
*/
abstract class Guzzle6HttpAsyncAdapterTest extends HttpAsyncClientTest
abstract class HttpAsyncAdapterTest extends HttpAsyncClientTest
{
/**
* {@inheritdoc}
*/
protected function createHttpAsyncClient()
{
return new Guzzle6HttpAdapter(new Client(['handler' => $this->createHandler()]));
return new Client(new GuzzleClient(['handler' => $this->createHandler()]));
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

namespace Http\Adapter\Tests;
namespace Http\Adapter\Guzzle6\Tests;

use GuzzleHttp\Handler\CurlMultiHandler;

/**
* @author GeLo <[email protected]>
*/
class Guzzle6MultiCurlHttpAdapterTest extends Guzzle6HttpAdapterTest
class MultiCurlHttpAdapterTest extends HttpAdapterTest
{
/**
* {@inheritdoc}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

namespace Http\Adapter\Tests;
namespace Http\Adapter\Guzzle6\Tests;

use GuzzleHttp\Handler\CurlMultiHandler;

/**
* @author Joel Wurtz <[email protected]>
*/
class Guzzle6MultiCurlHttpAsyncAdapterTest extends Guzzle6HttpAsyncAdapterTest
class MultiCurlHttpAsyncAdapterTest extends HttpAsyncAdapterTest
{
/**
* {@inheritdoc}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
<?php

namespace Http\Adapter\Tests;
namespace Http\Adapter\Guzzle6\Tests;

use GuzzleHttp\Exception as GuzzleExceptions;
use Http\Adapter\Guzzle6Promise;
use Http\Adapter\Guzzle6\Promise;

/**
* @author Tobias Nyholm <[email protected]>
*/
class Guzzle6PromiseExceptionTest extends \PHPUnit_Framework_TestCase
class PromiseExceptionTest extends \PHPUnit_Framework_TestCase
{
public function testGetException()
{
$request = $this->getMock('Psr\Http\Message\RequestInterface');
$response = $this->getMock('Psr\Http\Message\ResponseInterface');
$promise = $this->getMock('GuzzleHttp\Promise\PromiseInterface');

$adapter = new Guzzle6Promise($promise, $request);
$method = new \ReflectionMethod('Http\Adapter\Guzzle6Promise', 'handleException');
$adapter = new Promise($promise, $request);
$method = new \ReflectionMethod('Http\Adapter\Guzzle6\Promise', 'handleException');
$method->setAccessible(true);

$outputException = $method->invoke($adapter, new GuzzleExceptions\ConnectException('foo', $request), $request);
Expand Down
8 changes: 4 additions & 4 deletions tests/Guzzle6PromiseTest.php → tests/PromiseTest.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?php

namespace Http\Adapter\Tests;
namespace Http\Adapter\Guzzle6\Tests;

use GuzzleHttp\Exception as GuzzleExceptions;
use GuzzleHttp\Promise\RejectedPromise;
use Http\Adapter\Guzzle6Promise;
use Http\Adapter\Guzzle6\Promise;

/**
* @author Márk Sági-Kazár <[email protected]>
*/
class Guzzle6PromiseTest extends \PHPUnit_Framework_TestCase
class PromiseTest extends \PHPUnit_Framework_TestCase
{
/**
* @expectedException \Exception
Expand All @@ -19,7 +19,7 @@ public function testNonDomainExceptionIsHandled()
$request = $this->prophesize('Psr\Http\Message\RequestInterface');
$promise = new RejectedPromise(new \Exception());

$guzzlePromise = new Guzzle6Promise($promise, $request->reveal());
$guzzlePromise = new Promise($promise, $request->reveal());

$guzzlePromise->wait();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

namespace Http\Adapter\Tests;
namespace Http\Adapter\Guzzle6\Tests;

use GuzzleHttp\Handler\StreamHandler;

/**
* @author GeLo <[email protected]>
*/
class Guzzle6StreamHttpAdapterTest extends Guzzle6HttpAdapterTest
class StreamHttpAdapterTest extends HttpAdapterTest
{
/**
* {@inheritdoc}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?php

namespace Http\Adapter\Tests;
namespace Http\Adapter\Guzzle6\Tests;

use GuzzleHttp\Handler\StreamHandler;

/**
* @author Joel Wurtz <[email protected]>
*/
class Guzzle6StreamHttpAsyncAdapterTest extends Guzzle6HttpAsyncAdapterTest
class StreamHttpAsyncAdapterTest extends HttpAsyncAdapterTest
{
/**
* {@inheritdoc}
Expand Down

0 comments on commit b2bfbe5

Please sign in to comment.