Commit c353babe authored by Bas de Nooijer's avatar Bas de Nooijer Committed by GitHub

Merge pull request #480 from solariumphp/develop

Merge develop to master for new release
parents 06e957a9 e30bf0d5
...@@ -74,10 +74,10 @@ class Guzzle3 extends Configurable implements AdapterInterface ...@@ -74,10 +74,10 @@ class Guzzle3 extends Configurable implements AdapterInterface
$endpoint->getBaseUri() . $request->getUri(), $endpoint->getBaseUri() . $request->getUri(),
$this->getRequestHeaders($request), $this->getRequestHeaders($request),
$this->getRequestBody($request), $this->getRequestBody($request),
[ array(
'timeout' => $endpoint->getTimeout(), 'timeout' => $endpoint->getTimeout(),
'connecttimeout' => $endpoint->getTimeout(), 'connecttimeout' => $endpoint->getTimeout(),
] )
); );
// Try endpoint authentication first, fallback to request for backwards compatibility // Try endpoint authentication first, fallback to request for backwards compatibility
...@@ -96,7 +96,7 @@ class Guzzle3 extends Configurable implements AdapterInterface ...@@ -96,7 +96,7 @@ class Guzzle3 extends Configurable implements AdapterInterface
$guzzleResponse = $guzzleRequest->getResponse(); $guzzleResponse = $guzzleRequest->getResponse();
$responseHeaders = array_merge( $responseHeaders = array_merge(
["HTTP/1.1 {$guzzleResponse->getStatusCode()} {$guzzleResponse->getReasonPhrase()}"], array("HTTP/1.1 {$guzzleResponse->getStatusCode()} {$guzzleResponse->getReasonPhrase()}"),
$guzzleResponse->getHeaderLines() $guzzleResponse->getHeaderLines()
); );
...@@ -155,7 +155,7 @@ class Guzzle3 extends Configurable implements AdapterInterface ...@@ -155,7 +155,7 @@ class Guzzle3 extends Configurable implements AdapterInterface
*/ */
private function getRequestHeaders(Request $request) private function getRequestHeaders(Request $request)
{ {
$headers = []; $headers = array();
foreach ($request->getHeaders() as $headerLine) { foreach ($request->getHeaders() as $headerLine) {
list($header, $value) = explode(':', $headerLine); list($header, $value) = explode(':', $headerLine);
if ($header = trim($header)) { if ($header = trim($header)) {
......
...@@ -82,7 +82,7 @@ class Grouping implements ComponentParserInterface ...@@ -82,7 +82,7 @@ class Grouping implements ComponentParserInterface
$matches = (isset($result['matches'])) ? $result['matches'] : null; $matches = (isset($result['matches'])) ? $result['matches'] : null;
$groupCount = (isset($result['ngroups'])) ? $result['ngroups'] : null; $groupCount = (isset($result['ngroups'])) ? $result['ngroups'] : null;
if ($grouping->getFormat() === GroupingComponent::FORMAT_SIMPLE) { if ($grouping->getFormat() === GroupingComponent::FORMAT_SIMPLE) {
$valueGroups = [$this->extractValueGroup($valueResultClass, $documentClass, $result, $query)]; $valueGroups = array($this->extractValueGroup($valueResultClass, $documentClass, $result, $query));
$groups[$field] = new FieldGroup($matches, $groupCount, $valueGroups); $groups[$field] = new FieldGroup($matches, $groupCount, $valueGroups);
continue; continue;
} }
......
...@@ -91,11 +91,11 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase ...@@ -91,11 +91,11 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase
$this->assertSame('OK', $response->getStatusMessage()); $this->assertSame('OK', $response->getStatusMessage());
$this->assertSame('200', $response->getStatusCode()); $this->assertSame('200', $response->getStatusCode());
$this->assertSame( $this->assertSame(
[ array(
'HTTP/1.1 200 OK', 'HTTP/1.1 200 OK',
'Content-Type: application/json', 'Content-Type: application/json',
'X-PHPUnit: response value', 'X-PHPUnit: response value',
], ),
$response->getHeaders() $response->getHeaders()
); );
$this->assertSame($guzzleResponse->getBody(true), $response->getBody()); $this->assertSame($guzzleResponse->getBody(true), $response->getBody());
...@@ -138,11 +138,11 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase ...@@ -138,11 +138,11 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase
$this->assertSame('OK', $response->getStatusMessage()); $this->assertSame('OK', $response->getStatusMessage());
$this->assertSame('200', $response->getStatusCode()); $this->assertSame('200', $response->getStatusCode());
$this->assertSame( $this->assertSame(
[ array(
'HTTP/1.1 200 OK', 'HTTP/1.1 200 OK',
'Content-Type: application/json', 'Content-Type: application/json',
'X-PHPUnit: response value', 'X-PHPUnit: response value',
], ),
$response->getHeaders() $response->getHeaders()
); );
$this->assertSame($guzzleResponse->getBody(true), $response->getBody()); $this->assertSame($guzzleResponse->getBody(true), $response->getBody());
...@@ -187,11 +187,11 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase ...@@ -187,11 +187,11 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase
$this->assertSame('OK', $response->getStatusMessage()); $this->assertSame('OK', $response->getStatusMessage());
$this->assertSame('200', $response->getStatusCode()); $this->assertSame('200', $response->getStatusCode());
$this->assertSame( $this->assertSame(
[ array(
'HTTP/1.1 200 OK', 'HTTP/1.1 200 OK',
'Content-Type: application/json', 'Content-Type: application/json',
'X-PHPUnit: response value', 'X-PHPUnit: response value',
], ),
$response->getHeaders() $response->getHeaders()
); );
$this->assertSame($guzzleResponse->getBody(true), $response->getBody()); $this->assertSame($guzzleResponse->getBody(true), $response->getBody());
...@@ -239,11 +239,11 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase ...@@ -239,11 +239,11 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase
$this->assertSame('OK', $response->getStatusMessage()); $this->assertSame('OK', $response->getStatusMessage());
$this->assertSame('200', $response->getStatusCode()); $this->assertSame('200', $response->getStatusCode());
$this->assertSame( $this->assertSame(
[ array(
'HTTP/1.1 200 OK', 'HTTP/1.1 200 OK',
'Content-Type: application/json', 'Content-Type: application/json',
'X-PHPUnit: response value', 'X-PHPUnit: response value',
], ),
$response->getHeaders() $response->getHeaders()
); );
$this->assertSame($guzzleResponse->getBody(true), $response->getBody()); $this->assertSame($guzzleResponse->getBody(true), $response->getBody());
...@@ -280,9 +280,9 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase ...@@ -280,9 +280,9 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase
$request->setMethod(Request::METHOD_GET); $request->setMethod(Request::METHOD_GET);
$endpoint = new Endpoint( $endpoint = new Endpoint(
[ array(
'scheme' => 'silly', //invalid protocol 'scheme' => 'silly', //invalid protocol
] )
); );
$this->adapter->execute($request, $endpoint); $this->adapter->execute($request, $endpoint);
...@@ -296,12 +296,12 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase ...@@ -296,12 +296,12 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase
private function getValidResponse() private function getValidResponse()
{ {
$body = json_encode( $body = json_encode(
[ array(
'response' => [ 'response' => array(
'numFound' => 10, 'numFound' => 10,
'start' => 0, 'start' => 0,
'docs' => [ 'docs' => array(
[ array(
'id' => '58339e95d5200', 'id' => '58339e95d5200',
'author' => 'Gambardella, Matthew', 'author' => 'Gambardella, Matthew',
'title' => "XML Developer's Guide", 'title' => "XML Developer's Guide",
...@@ -309,13 +309,13 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase ...@@ -309,13 +309,13 @@ final class Guzzle3Test extends \PHPUnit_Framework_TestCase
'price' => 44.95, 'price' => 44.95,
'published' => 970372800, 'published' => 970372800,
'description' => 'An in-depth look at creating applications with XML.', 'description' => 'An in-depth look at creating applications with XML.',
], ),
], ),
], ),
] )
); );
$headers = ['Content-Type' => 'application/json', 'X-PHPUnit' => 'response value']; $headers = array('Content-Type' => 'application/json', 'X-PHPUnit' => 'response value');
return new Response(200, $headers, $body); return new Response(200, $headers, $body);
} }
} }
...@@ -75,15 +75,15 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase ...@@ -75,15 +75,15 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase
public function executeGet() public function executeGet()
{ {
$guzzleResponse = $this->getValidResponse(); $guzzleResponse = $this->getValidResponse();
$mockHandler = new MockHandler([$guzzleResponse]); $mockHandler = new MockHandler(array($guzzleResponse));
$container = []; $container = array();
$history = Middleware::history($container); $history = Middleware::history($container);
$stack = HandlerStack::create($mockHandler); $stack = HandlerStack::create($mockHandler);
$stack->push($history); $stack->push($history);
$adapter = new GuzzleAdapter(['handler' => $stack]); $adapter = new GuzzleAdapter(array('handler' => $stack));
$request = new Request(); $request = new Request();
$request->setMethod(Request::METHOD_GET); $request->setMethod(Request::METHOD_GET);
...@@ -96,11 +96,11 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase ...@@ -96,11 +96,11 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase
$this->assertSame('OK', $response->getStatusMessage()); $this->assertSame('OK', $response->getStatusMessage());
$this->assertSame('200', $response->getStatusCode()); $this->assertSame('200', $response->getStatusCode());
$this->assertSame( $this->assertSame(
[ array(
'HTTP/1.1 200 OK', 'HTTP/1.1 200 OK',
'Content-Type: application/json', 'Content-Type: application/json',
'X-PHPUnit: response value', 'X-PHPUnit: response value',
], ),
$response->getHeaders() $response->getHeaders()
); );
$this->assertSame((string)$guzzleResponse->getBody(), $response->getBody()); $this->assertSame((string)$guzzleResponse->getBody(), $response->getBody());
...@@ -121,15 +121,15 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase ...@@ -121,15 +121,15 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase
public function executePostWithFile() public function executePostWithFile()
{ {
$guzzleResponse = $this->getValidResponse(); $guzzleResponse = $this->getValidResponse();
$mockHandler = new MockHandler([$guzzleResponse]); $mockHandler = new MockHandler(array($guzzleResponse));
$container = []; $container = array();
$history = Middleware::history($container); $history = Middleware::history($container);
$stack = HandlerStack::create($mockHandler); $stack = HandlerStack::create($mockHandler);
$stack->push($history); $stack->push($history);
$adapter = new GuzzleAdapter(['handler' => $stack]); $adapter = new GuzzleAdapter(array('handler' => $stack));
$request = new Request(); $request = new Request();
$request->setMethod(Request::METHOD_POST); $request->setMethod(Request::METHOD_POST);
...@@ -143,11 +143,11 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase ...@@ -143,11 +143,11 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase
$this->assertSame('OK', $response->getStatusMessage()); $this->assertSame('OK', $response->getStatusMessage());
$this->assertSame('200', $response->getStatusCode()); $this->assertSame('200', $response->getStatusCode());
$this->assertSame( $this->assertSame(
[ array(
'HTTP/1.1 200 OK', 'HTTP/1.1 200 OK',
'Content-Type: application/json', 'Content-Type: application/json',
'X-PHPUnit: response value', 'X-PHPUnit: response value',
], ),
$response->getHeaders() $response->getHeaders()
); );
$this->assertSame((string)$guzzleResponse->getBody(), $response->getBody()); $this->assertSame((string)$guzzleResponse->getBody(), $response->getBody());
...@@ -169,15 +169,15 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase ...@@ -169,15 +169,15 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase
public function executePostWithRawBody() public function executePostWithRawBody()
{ {
$guzzleResponse = $this->getValidResponse(); $guzzleResponse = $this->getValidResponse();
$mockHandler = new MockHandler([$guzzleResponse]); $mockHandler = new MockHandler(array($guzzleResponse));
$container = []; $container = array();
$history = Middleware::history($container); $history = Middleware::history($container);
$stack = HandlerStack::create($mockHandler); $stack = HandlerStack::create($mockHandler);
$stack->push($history); $stack->push($history);
$adapter = new GuzzleAdapter(['handler' => $stack]); $adapter = new GuzzleAdapter(array('handler' => $stack));
$request = new Request(); $request = new Request();
$request->setMethod(Request::METHOD_POST); $request->setMethod(Request::METHOD_POST);
...@@ -192,11 +192,11 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase ...@@ -192,11 +192,11 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase
$this->assertSame('OK', $response->getStatusMessage()); $this->assertSame('OK', $response->getStatusMessage());
$this->assertSame('200', $response->getStatusCode()); $this->assertSame('200', $response->getStatusCode());
$this->assertSame( $this->assertSame(
[ array(
'HTTP/1.1 200 OK', 'HTTP/1.1 200 OK',
'Content-Type: application/json', 'Content-Type: application/json',
'X-PHPUnit: response value', 'X-PHPUnit: response value',
], ),
$response->getHeaders() $response->getHeaders()
); );
$this->assertSame((string)$guzzleResponse->getBody(), $response->getBody()); $this->assertSame((string)$guzzleResponse->getBody(), $response->getBody());
...@@ -219,15 +219,15 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase ...@@ -219,15 +219,15 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase
public function executeGetWithAuthentication() public function executeGetWithAuthentication()
{ {
$guzzleResponse = $this->getValidResponse(); $guzzleResponse = $this->getValidResponse();
$mockHandler = new MockHandler([$guzzleResponse]); $mockHandler = new MockHandler(array($guzzleResponse));
$container = []; $container = array();
$history = Middleware::history($container); $history = Middleware::history($container);
$stack = HandlerStack::create($mockHandler); $stack = HandlerStack::create($mockHandler);
$stack->push($history); $stack->push($history);
$adapter = new GuzzleAdapter(['handler' => $stack]); $adapter = new GuzzleAdapter(array('handler' => $stack));
$request = new Request(); $request = new Request();
$request->setMethod(Request::METHOD_GET); $request->setMethod(Request::METHOD_GET);
...@@ -241,11 +241,11 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase ...@@ -241,11 +241,11 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase
$this->assertSame('OK', $response->getStatusMessage()); $this->assertSame('OK', $response->getStatusMessage());
$this->assertSame('200', $response->getStatusCode()); $this->assertSame('200', $response->getStatusCode());
$this->assertSame( $this->assertSame(
[ array(
'HTTP/1.1 200 OK', 'HTTP/1.1 200 OK',
'Content-Type: application/json', 'Content-Type: application/json',
'X-PHPUnit: response value', 'X-PHPUnit: response value',
], ),
$response->getHeaders() $response->getHeaders()
); );
$this->assertSame((string)$guzzleResponse->getBody(), $response->getBody()); $this->assertSame((string)$guzzleResponse->getBody(), $response->getBody());
...@@ -277,9 +277,9 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase ...@@ -277,9 +277,9 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase
$request->setMethod(Request::METHOD_GET); $request->setMethod(Request::METHOD_GET);
$endpoint = new Endpoint( $endpoint = new Endpoint(
[ array(
'scheme' => 'silly', //invalid protocol 'scheme' => 'silly', //invalid protocol
] )
); );
$endpoint->setTimeout(10); $endpoint->setTimeout(10);
...@@ -294,12 +294,12 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase ...@@ -294,12 +294,12 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase
private function getValidResponse() private function getValidResponse()
{ {
$body = json_encode( $body = json_encode(
[ array(
'response' => [ 'response' => array(
'numFound' => 10, 'numFound' => 10,
'start' => 0, 'start' => 0,
'docs' => [ 'docs' => array(
[ array(
'id' => '58339e95d5200', 'id' => '58339e95d5200',
'author' => 'Gambardella, Matthew', 'author' => 'Gambardella, Matthew',
'title' => "XML Developer's Guide", 'title' => "XML Developer's Guide",
...@@ -307,13 +307,13 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase ...@@ -307,13 +307,13 @@ final class GuzzleAdapterTest extends \PHPUnit_Framework_TestCase
'price' => 44.95, 'price' => 44.95,
'published' => 970372800, 'published' => 970372800,
'description' => 'An in-depth look at creating applications with XML.', 'description' => 'An in-depth look at creating applications with XML.',
], ),
], ),
], ),
] )
); );
$headers = ['Content-Type' => 'application/json', 'X-PHPUnit' => 'response value']; $headers = array('Content-Type' => 'application/json', 'X-PHPUnit' => 'response value');
return new Response(200, $headers, $body); return new Response(200, $headers, $body);
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment