Skip to content

Commit a7d5a69

Browse files
committed
Drop support for PHP 5.3 and 5.4
1 parent d722f0a commit a7d5a69

File tree

9 files changed

+31
-53
lines changed

9 files changed

+31
-53
lines changed

.travis.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
language: php
22

33
php:
4-
- 5.3
5-
- 5.4
64
- 5.5
75
- 5.6
86
- 7.0
97

108
before_script:
119
- echo 'date.timezone = "UTC"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
12-
- curl -sS https://getcomposer.org/installer | php
13-
- php composer.phar install --dev -o -n
10+
- composer install -o -n
1411
- vendor/bin/phpunit --version
1512
- mkdir -p build/logs
1613

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@
55
"homepage": "http://github.com/scriptotek/sru-client",
66
"keywords": ["sru"],
77
"require": {
8-
"danmichaelo/quitesimplexmlelement": ">=0.4.2",
9-
"guzzle/guzzle": "~3.8"
8+
"php" : "^5.5 || ^7.0",
9+
"guzzlehttp/guzzle": "~6.0",
10+
"danmichaelo/quitesimplexmlelement": ">=0.4.2"
1011
},
1112
"require-dev": {
12-
"phpunit/phpunit": "4.0.*",
13+
"phpunit/phpunit": "^4.8|^5.5",
1314
"satooshi/php-coveralls": "1.*",
14-
"sami/sami": "1.4.*",
15-
"mockery/mockery": "~0.9.4"
15+
"sami/sami": "^3.3",
16+
"mockery/mockery": "^0.9"
1617
},
1718
"license": "MIT",
1819
"authors": [
@@ -30,6 +31,5 @@
3031
"psr-4": {
3132
"Scriptotek\\Sru\\": "tests/"
3233
}
33-
},
34-
"minimum-stability": "dev"
34+
}
3535
}

src/Client.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php namespace Scriptotek\Sru;
22

3-
use \Guzzle\Http\Client as HttpClient;
3+
use GuzzleHttp\Client as HttpClient;
44

55
/**
66
* SRU client
@@ -140,8 +140,8 @@ public function search($cql, $start = 1, $count = 10, $extraParams = array())
140140
$url = $this->urlTo($cql, $start, $count, $extraParams);
141141
$options = $this->getHttpOptions();
142142

143-
$res = $this->httpClient->get($url, $options)->send();
144-
$body = $res->getBody(true);
143+
$response = $this->httpClient->get($url, $options);
144+
$body = (string) $response->getBody();
145145

146146
return new SearchRetrieveResponse($body, $this);
147147
}
@@ -187,8 +187,8 @@ public function explain()
187187
));
188188
$options = $this->getHttpOptions();
189189

190-
$res = $this->httpClient->get($url, $options)->send();
191-
$body = $res->getBody(true);
190+
$response = $this->httpClient->get($url, $options);
191+
$body = (string) $response->getBody();
192192

193193
return new ExplainResponse($body, $this);
194194
}

src/Records.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ private function fetchMore()
7070
$url = $this->client->urlTo($this->cql, $this->position, $this->count, $this->extraParams);
7171
$options = $this->client->getHttpOptions();
7272

73-
$res = $this->httpClient->get($url, $options)->send();
74-
$body = $res->getBody(true);
73+
$response = $this->httpClient->get($url, $options);
74+
$body = (string) $response->getBody();
7575
$this->lastResponse = new SearchRetrieveResponse($body);
7676
$this->data = $this->lastResponse->records;
7777

src/Response.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ protected function initializeFromText($text)
127127
$this->rawResponse = $text;
128128

129129
// Throws Danmichaelo\QuiteSimpleXMLElement\InvalidXMLException on invalid xml
130-
$this->response = QuiteSimpleXMLElement::make($text, [
130+
$this->response = QuiteSimpleXMLElement::make($text, array(
131131
'srw' => 'http://www.loc.gov/zing/srw/',
132132
'exp' => 'http://explain.z3950.org/dtd/2.0/',
133133
'd' => 'http://www.loc.gov/zing/srw/diagnostic/',
134-
]);
134+
));
135135

136136
$this->version = $this->response->text('/srw:*/srw:version');
137137

src/SearchRetrieveResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class SearchRetrieveResponse extends Response implements ResponseInterface
77
{
88
/** @var Record[] Array of records */
9-
public $records = [];
9+
public $records = array();
1010

1111
/** @var int Total number of records in the result set */
1212
public $numberOfRecords = 0;

tests/ClientTest.php

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php namespace Scriptotek\Sru;
22

3-
use Guzzle\Http\Message\Response as HttpResponse;
3+
use GuzzleHttp\Psr7\Response as HttpResponse;
44
use Mockery as m;
55

66
class ClientTest extends TestCase
@@ -50,16 +50,11 @@ public function testSearchWithAuth()
5050
{
5151
$credentials = array('secretuser', 'secretpass');
5252

53-
$request = m::mock();
54-
$request->shouldReceive('send')
55-
->once()
56-
->andReturn(new HttpResponse(200, array(), $this->simple_response));
57-
5853
$http = m::mock();
5954
$http->shouldReceive('get')
6055
->with(m::any(), m::subset(array('auth' => $credentials)))
6156
->once()
62-
->andReturn($request);
57+
->andReturn(new HttpResponse(200, array(), $this->simple_response));
6358

6459
$options = array(
6560
'credentials' => $credentials
@@ -74,10 +69,10 @@ public function testNext()
7469
{
7570
$cql = 'dc.title="Joda jada isjda"';
7671

77-
$request = m::mock();
78-
$request->shouldReceive('send')
72+
$http = m::mock();
73+
$http->shouldReceive('get')
7974
->once()
80-
->andReturn(new HttpResponse(200, null, '<?xml version="1.0" encoding="UTF-8" ?>
75+
->andReturn(new HttpResponse(200, array(), '<?xml version="1.0" encoding="UTF-8" ?>
8176
<srw:searchRetrieveResponse
8277
xmlns:srw="http://www.loc.gov/zing/srw/"
8378
xmlns:xcql="http://www.loc.gov/zing/cql/xcql/"
@@ -113,18 +108,13 @@ public function testNext()
113108
</srw:searchRetrieveResponse>
114109
'));
115110

116-
$http = m::mock();
117-
$http->shouldReceive('get')
118-
->once()
119-
->andReturn($request);
120-
121111
$sru = new Client($this->url, null, $http);
122112
$response = $sru->search($cql);
123113
$this->assertCount(2, $response->records);
124114

125-
$request->shouldReceive('send')
115+
$http->shouldReceive('get')
126116
->once()
127-
->andReturn(new HttpResponse(200, null, '<?xml version="1.0" encoding="UTF-8" ?>
117+
->andReturn(new HttpResponse(200, array(), '<?xml version="1.0" encoding="UTF-8" ?>
128118
<srw:searchRetrieveResponse
129119
xmlns:srw="http://www.loc.gov/zing/srw/"
130120
xmlns:xcql="http://www.loc.gov/zing/cql/xcql/"

tests/RecordTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class RecordTest extends TestCase
55
public function testMake() {
66
$record = Record::make(29, 'Hello world');
77

8-
$this->assertInstanceOf(Record::class, $record);
8+
$this->assertInstanceOf('Scriptotek\Sru\Record', $record);
99
$this->assertEquals(29, $record->position);
1010
}
1111
}

tests/TestCase.php

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php namespace Scriptotek\Sru;
22

3-
use Guzzle\Http\Message\Response as HttpResponse;
3+
use GuzzleHttp\Psr7\Response as HttpResponse;
44
use Mockery as m;
55

66
class TestCase extends \PHPUnit_Framework_TestCase
@@ -102,15 +102,10 @@ public function makeDummyResponse($numberOfRecords = 10, $options = array())
102102
*/
103103
protected function httpMockSingleResponse($response)
104104
{
105-
$request = m::mock();
106-
$request->shouldReceive('send')
107-
->once()
108-
->andReturn(new HttpResponse(200, array(), $response));
109-
110105
$http = m::mock();
111106
$http->shouldReceive('get')
112107
->once()
113-
->andReturn($request);
108+
->andReturn(new HttpResponse(200, array(), $response));
114109

115110
return $http;
116111
}
@@ -120,15 +115,11 @@ protected function httpMockSingleResponse($response)
120115
*/
121116
protected function httpMockListResponse($responses)
122117
{
123-
$request = m::mock();
124-
$request->shouldReceive('send')
125-
->andReturnValues(array_map(function ($r) {
126-
return new HttpResponse(200, null, $r);
127-
}, $responses));
128-
129118
$http = m::mock();
130119
$http->shouldReceive('get')
131-
->andReturn($request);
120+
->andReturnValues(array_map(function ($r) {
121+
return new HttpResponse(200, array(), $r);
122+
}, $responses));
132123

133124
return $http;
134125
}

0 commit comments

Comments
 (0)