Skip to content

Commit

Permalink
Merge pull request #18 from alexdebril/issue-14
Browse files Browse the repository at this point in the history
Dependencies upgrade
  • Loading branch information
alexdebril committed Jun 26, 2015
2 parents 8ecb43d + 6230bf3 commit a050da1
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 33 deletions.
4 changes: 1 addition & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
language: php

php:
- 5.4
- 5.5
- 5.6

Expand All @@ -11,5 +10,4 @@ before_script:
- composer require guzzlehttp/guzzle:${GUZZLE_VERSION}

env:
- GUZZLE_VERSION="~4.1"
- GUZZLE_VERSION="~5.1"
- GUZZLE_VERSION="~6.0"
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "debril/feed-io",
"description": "Reads and writes new feeds",
"description": "Reads and writes news feeds",
"keywords": ["rss", "atom", "feed", "news"],
"homepage": "https://github.com/alexdebril/feed-io",
"homepage": "http://debril.org/category/feed-io/",
"type": "library",
"license": "MIT",
"authors": [
Expand All @@ -12,16 +12,16 @@
}
],
"require": {
"php": ">=5.4.0",
"php": ">=5.5.0",
"psr/log": "~1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.1.0",
"guzzlehttp/guzzle": ">=4.1,<5.5",
"guzzlehttp/guzzle": "~6.0",
"monolog/monolog": "1.10.*@dev"
},
"suggest": {
"guzzlehttp/guzzle": ">=4.1,<5.5",
"guzzlehttp/guzzle": "HTTP communication",
"monolog/monolog": "Allows to handle logs"
},
"autoload": {
Expand Down
2 changes: 1 addition & 1 deletion src/FeedIo/Adapter/Guzzle/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function __construct(\GuzzleHttp\ClientInterface $guzzleClient)
public function getResponse($url, \DateTime $modifiedSince)
{
try {
return new Response($this->guzzleClient->get($url));
return new Response($this->guzzleClient->request('get', $url));
} catch (BadResponseException $e) {
switch ((int) $e->getResponse()->getStatusCode()) {
case 404:
Expand Down
24 changes: 12 additions & 12 deletions src/FeedIo/Adapter/Guzzle/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
namespace FeedIo\Adapter\Guzzle;

use FeedIo\Adapter\ResponseInterface;
use GuzzleHttp\Message\ResponseInterface as GuzzleResponseInterface;
use Psr\Http\Message\ResponseInterface as PsrResponseInterface;

/**
* Guzzle dependent HTTP Response
Expand All @@ -22,32 +22,32 @@ class Response implements ResponseInterface
const HTTP_LAST_MODIFIED = 'Last-Modified';

/**
* @var \GuzzleHttp\Message\ResponseInterface
* @var \Psr\Http\Message\ResponseInterface
*/
protected $guzzleResponse;
protected $psrResponse;

/**
* @param GuzzleResponseInterface $guzzleResponse
* @param \Psr\Http\Message\ResponseInterface
*/
public function __construct(GuzzleResponseInterface $guzzleResponse)
public function __construct(PsrResponseInterface $psrResponse)
{
$this->guzzleResponse = $guzzleResponse;
$this->psrResponse = $psrResponse;
}

/**
* @return string
* @return \Psr\Http\Message\StreamInterface
*/
public function getBody()
{
return $this->guzzleResponse->getBody();
return $this->psrResponse->getBody();
}

/**
* @return \DateTime|null
*/
public function getLastModified()
{
if ($this->guzzleResponse->hasHeader(static::HTTP_LAST_MODIFIED)) {
if ($this->psrResponse->hasHeader(static::HTTP_LAST_MODIFIED)) {
$lastModified = \DateTime::createFromFormat(\DateTime::RFC2822, $this->getHeader(static::HTTP_LAST_MODIFIED));

return false === $lastModified ? null : $lastModified;
Expand All @@ -61,15 +61,15 @@ public function getLastModified()
*/
public function getHeaders()
{
return $this->guzzleResponse->getHeaders();
return $this->psrResponse->getHeaders();
}

/**
* @param string $name
* @return array|string
* @return string[]
*/
public function getHeader($name)
{
return $this->guzzleResponse->getHeader($name);
return $this->psrResponse->getHeader($name);
}
}
5 changes: 1 addition & 4 deletions src/FeedIo/Feed/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,9 @@ public function getAllElements()
*/
public function listElements()
{
$out = array();
foreach ($this->elements as $element) {
$out[] = $element->getName();
yield $element->getName();
}

return $out;
}

/**
Expand Down
14 changes: 7 additions & 7 deletions tests/FeedIo/Adapter/Guzzle/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected function setUp()

public function testGetResponse()
{
$response = $this->object->getResponse('somewhere', new \DateTime());
$response = $this->object->getResponse('http://somewhere', new \DateTime());
$this->assertInstanceOf('\FeedIo\Adapter\ResponseInterface', $response);

$this->assertEquals($this->body, $response->getBody());
Expand Down Expand Up @@ -64,12 +64,12 @@ protected function getErroredClient($statusCode)
{
$exception = new BadResponseException(
'message',
new \GuzzleHttp\Message\Request('get', 'http://test'),
new \GuzzleHttp\Message\Response("{$statusCode}")
new \GuzzleHttp\Psr7\Request('get', 'http://test'),
new \GuzzleHttp\Psr7\Response("{$statusCode}")
);

$guzzleClient = $this->getMockForAbstractClass('\GuzzleHttp\ClientInterface');
$guzzleClient->expects($this->any())->method('get')->will($this->throwException($exception));
$guzzleClient->expects($this->any())->method('request')->will($this->throwException($exception));

return $guzzleClient;
}
Expand All @@ -79,14 +79,14 @@ protected function getErroredClient($statusCode)
*/
protected function getGuzzleClient()
{
$response = $this->getMockForAbstractClass('\GuzzleHttp\Message\ResponseInterface');
$response = $this->getMockForAbstractClass('\Psr\Http\Message\ResponseInterface');
$response->expects($this->any())->method('getBody')->will($this->returnValue($this->body));
$response->expects($this->any())->method('getHeader')->will($this->returnValue('Tue, 15 Nov 1994 12:45:26 GMT'));
$response->expects($this->any())->method('getHeaders')->will($this->returnValue(array()));
$response->expects($this->any())->method('hasHeader')->will($this->returnValue(true));

$client = $this->getMockForAbstractClass('\GuzzleHttp\ClientInterface');
$client->expects($this->any())->method('get')->will($this->returnValue($response));
$client = $this->getMock('\GuzzleHttp\Client');
$client->expects($this->any())->method('request')->will($this->returnValue($response));

return $client;
}
Expand Down
6 changes: 5 additions & 1 deletion tests/FeedIo/Feed/ItemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,11 @@ public function testListElements()

$this->object->addElement($element2);

$this->assertEquals(array('foo', 'bar'), $this->object->listElements());
$elements = array();
foreach($this->object->listElements() as $element) {
$elements[] = $element;
}
$this->assertEquals(array('foo', 'bar'), $elements);
}

public function testNewMedia()
Expand Down

0 comments on commit a050da1

Please sign in to comment.