Skip to content

Commit 560c845

Browse files
committed
Updated Guzzle version from 3.7.* to 6.*
1 parent 4bb045c commit 560c845

File tree

9 files changed

+31
-28
lines changed

9 files changed

+31
-28
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ master
77
* Added alternative `symfony/console` versions (`~3.0` and `~4.0`).
88
* Removed PHP versions < `5.6`.
99
* Replace `guzzle/guzzle` by `guzzlehttp/guzzle`.
10+
* Updated Guzzle version from 3.7.* to 6.*.

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
],
1414
"require": {
1515
"php": "^5.6 || ^7.1",
16-
"guzzlehttp/guzzle": "~3.7",
16+
"guzzlehttp/guzzle": "~6.0",
1717
"symfony/console": "~2.5|~3.0|~4.0"
1818
},
1919
"require-dev":{

src/Mremi/Flowdock/Api/Push/BaseMessage.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Mremi\Flowdock\Api\Push;
1313

14-
use Guzzle\Http\Message\Response;
14+
use Psr\Http\Message\ResponseInterface;
1515

1616
/**
1717
* Base push message class
@@ -31,7 +31,7 @@ abstract class BaseMessage implements BaseMessageInterface
3131
protected $tags = array();
3232

3333
/**
34-
* @var Response
34+
* @var ResponseInterface
3535
*/
3636
protected $response;
3737

@@ -106,7 +106,7 @@ public function getTags()
106106
/**
107107
* {@inheritdoc}
108108
*/
109-
public function setResponse(Response $response)
109+
public function setResponse(ResponseInterface $response)
110110
{
111111
$this->response = $response;
112112

src/Mremi/Flowdock/Api/Push/BaseMessageInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Mremi\Flowdock\Api\Push;
1313

14-
use Guzzle\Http\Message\Response;
14+
use Psr\Http\Message\ResponseInterface;
1515

1616
/**
1717
* Base push message interface
@@ -78,16 +78,16 @@ public function getTags();
7878
/**
7979
* Sets the Flowdock response
8080
*
81-
* @param Response $response
81+
* @param ResponseInterface $response
8282
*
8383
* @return static
8484
*/
85-
public function setResponse(Response $response);
85+
public function setResponse(ResponseInterface $response);
8686

8787
/**
8888
* Gets the Flowdock response
8989
*
90-
* @return Response
90+
* @return ResponseInterface
9191
*/
9292
public function getResponse();
9393

src/Mremi/Flowdock/Api/Push/Push.php

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Mremi\Flowdock\Api\Push;
1313

14-
use Guzzle\Http\Client;
14+
use GuzzleHttp\Client;
1515

1616
/**
1717
* Push class
@@ -67,13 +67,14 @@ protected function sendMessage(BaseMessageInterface $message, $baseUrl, array $o
6767
{
6868
$client = $this->createClient(sprintf('%s/%s', $baseUrl, $this->flowApiToken));
6969

70-
$request = $client->post(null, array(
71-
'Content-Type' => 'application/json'
72-
), json_encode(
73-
$message->getData()
74-
), $options);
70+
$response = $client->post(null, array_merge(
71+
$options, [
72+
'headers' => ['Content-Type' => 'application/json'],
73+
'json' => $message->getData()
74+
]
75+
));
7576

76-
$message->setResponse($request->send());
77+
$message->setResponse($response);
7778

7879
return !$message->hasResponseErrors();
7980
}

tests/Mremi/Flowdock/Tests/Api/Push/BaseMessageTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Mremi\Flowdock\Tests\Api\Push;
1313

14-
use Guzzle\Http\Message\Response;
14+
use GuzzleHttp\Psr7\Response;
1515

1616
use Mremi\Flowdock\Api\Push\BaseMessageInterface;
1717

@@ -90,7 +90,7 @@ public function testAddTags()
9090
*/
9191
public function testValidResponse()
9292
{
93-
$this->message->setResponse(new Response(200, null, '{"dummy": "ok"}'));
93+
$this->message->setResponse(new Response(200, [], '{"dummy": "ok"}'));
9494

9595
$this->assertEquals(array('dummy' => 'ok'), $this->message->getResponseBody());
9696

@@ -106,7 +106,7 @@ public function testValidResponse()
106106
*/
107107
public function testInvalidResponse()
108108
{
109-
$this->message->setResponse(new Response(400, null, '{"message": "Validation error", "errors": {"content": ["can\'t be blank"]}}'));
109+
$this->message->setResponse(new Response(400, [], '{"message": "Validation error", "errors": {"content": ["can\'t be blank"]}}'));
110110

111111
$this->assertEquals(array('message' => 'Validation error', 'errors' => array('content' => array('can\'t be blank'))), $this->message->getResponseBody());
112112

tests/Mremi/Flowdock/Tests/Api/Push/ChatMessageTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Mremi\Flowdock\Tests\Api\Push;
1313

14-
use Guzzle\Http\Message\Response;
14+
use GuzzleHttp\Psr7\Response;
1515

1616
use Mremi\Flowdock\Api\Push\ChatMessage;
1717

tests/Mremi/Flowdock/Tests/Api/Push/PushTest.php

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Mremi\Flowdock\Tests\Api\Push;
1313

14-
use Guzzle\Http\Message\Response;
14+
use GuzzleHttp\Psr7\Response;
1515

1616
use Mremi\Flowdock\Api\Push\BaseMessageInterface;
1717
use Mremi\Flowdock\Api\Push\ChatMessage;
@@ -85,15 +85,16 @@ public function testSendMessage(BaseMessageInterface $message, $baseUrl, array $
8585
'Content-Type' => 'application/json; charset=utf-8',
8686
), '{"message": "Validation error", "errors": {"content": ["can\'t be blank"]}}');
8787

88-
$request = $this->getMock('Guzzle\Http\Message\RequestInterface');
89-
$request->expects($this->exactly(2))->method('send')->will($this->onConsecutiveCalls($responseOk, $responseKo));
90-
91-
$client = $this->getMock('Guzzle\Http\ClientInterface');
88+
$clientOptions = $options;
89+
$clientOptions['headers'] = array('Content-Type' => 'application/json');
90+
$clientOptions['json'] = $message->getData();
91+
92+
$client = $this->getMock('GuzzleHttp\Client');
9293
$client
9394
->expects($this->exactly(2))
94-
->method('post')
95-
->with($this->equalTo(null), $this->equalTo(array('Content-Type' => 'application/json')), $this->equalTo(json_encode($message->getData())), $this->equalTo($options))
96-
->will($this->returnValue($request));
95+
->method('__call')
96+
->with($this->equalTo('post'), $this->equalTo([null, $clientOptions]))
97+
->willReturnOnConsecutiveCalls($responseOk, $responseKo);
9798

9899
$push = $this->getMockBuilder('Mremi\Flowdock\Api\Push\Push')
99100
->setConstructorArgs(array('flow_api_token'))

tests/Mremi/Flowdock/Tests/Api/Push/TeamInboxMessageTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Mremi\Flowdock\Tests\Api\Push;
1313

14-
use Guzzle\Http\Message\Response;
14+
use GuzzleHttp\Psr7\Response;
1515

1616
use Mremi\Flowdock\Api\Push\TeamInboxMessage;
1717

0 commit comments

Comments
 (0)