Skip to content

Commit 79e704a

Browse files
committed
Merge branch 'jnrfred-fix-compatibility-issue'
2 parents 9c46ce8 + 584521a commit 79e704a

File tree

3 files changed

+26
-32
lines changed

3 files changed

+26
-32
lines changed

.travis.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,17 @@ php:
44
- 7.0
55
- 7.1
66
- 7.2
7+
- 7.3
8+
- 7.4
9+
- 8.0
10+
- 8.1
711

812
sudo: false
913

1014
env:
1115
- TEST=PHP_CodeSniffer
1216
- TEST=PHPUnit
1317

14-
matrix:
15-
exclude:
16-
- php: 5.6
17-
env: TEST=PHP_CodeSniffer
18-
- php: 7.0
19-
env: TEST=PHP_CodeSniffer
20-
- php: 7.1
21-
env: TEST=PHP_CodeSniffer
22-
2318
install:
2419
- composer install
2520

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@
1515
"psr-4": {"Matomo\\ReportingApi\\": "src/"}
1616
},
1717
"require": {
18-
"guzzlehttp/guzzle": "~6.0"
18+
"guzzlehttp/guzzle": "~7",
19+
"phpspec/prophecy-phpunit": "^2.0"
1920
},
2021
"require-dev": {
21-
"phpunit/phpunit": "^5.0|^6.0|^7.0",
22+
"phpunit/phpunit": "^5.0||^6.0||^7.0||^8.0||^9.0",
2223
"squizlabs/php_codesniffer": "^3.2"
2324
}
2425
}

tests/src/HttpClientTest.php

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
namespace Matomo\ReportingApi\tests;
44

5+
use Exception;
56
use GuzzleHttp\ClientInterface;
67
use GuzzleHttp\Psr7\Response;
7-
use PHPUnit\Framework\TestCase;
8+
use InvalidArgumentException;
89
use Matomo\ReportingApi\HttpClient;
910
use Matomo\ReportingApi\RequestFactoryInterface;
10-
use Prophecy\Argument;
11+
use PHPUnit\Framework\TestCase;
12+
use Prophecy\PhpUnit\ProphecyTrait;
1113
use Psr\Http\Message\RequestInterface;
1214
use Psr\Http\Message\ResponseInterface;
1315

@@ -19,6 +21,8 @@
1921
class HttpClientTest extends TestCase
2022
{
2123

24+
use ProphecyTrait;
25+
2226
/**
2327
* @param array $parameters
2428
*
@@ -111,11 +115,12 @@ public function testSetUrl($url)
111115
* @param string $invalid_url
112116
* An invalid URL.
113117
*
114-
* @expectedException \InvalidArgumentException
118+
*
115119
* @dataProvider invalidUrlProvider
116120
*/
117121
public function testInvalidUrl($invalid_url)
118122
{
123+
$this->expectException(InvalidArgumentException::class);
119124
$this->getHttpClient()->setUrl($invalid_url);
120125
}
121126

@@ -188,21 +193,11 @@ public function testGetMethod($method)
188193
*/
189194
public function testSetMethod($method)
190195
{
191-
// It is expected that the given HTTP method will be passed to the request factory.
192-
$request_factory = $this->prophesize(RequestFactoryInterface::class);
193-
$request_factory
194-
->getRequest($method, Argument::any())
195-
->willReturn($this->prophesize(RequestInterface::class)->reveal())
196-
->shouldBeCalled();
197-
198-
$http_client = $this->getHttpClient(null, $request_factory->reveal());
199-
$http_client->setUrl('http://example.com');
200-
$result = $http_client->setMethod($method);
201-
// Send the request so that we can check if the correct HTTP method is used.
202-
$http_client->sendRequest();
196+
$http_client = $this->getHttpClient();
197+
$http_client->setMethod($method);
203198

204-
// Check that the client is returned for chaining.
205-
$this->assertEquals($http_client, $result);
199+
// Check if correct HTTP method is returned by client
200+
$this->assertEquals($http_client->getMethod(), $method);
206201
}
207202

208203
/**
@@ -212,11 +207,13 @@ public function testSetMethod($method)
212207
* An unsupported or invalid HTTP method.
213208
*
214209
* @covers ::setMethod
215-
* @expectedException \InvalidArgumentException
210+
*
216211
* @dataProvider unsupportedHttpMethodsProvider
217212
*/
218213
public function testUnsupportedHttpMethods($invalid_method)
219214
{
215+
$this->expectException(InvalidArgumentException::class);
216+
220217
$http_client = $this->getHttpClient();
221218
$http_client->setMethod($invalid_method);
222219
}
@@ -270,10 +267,11 @@ public function unsupportedHttpMethodsProvider()
270267
* Tests that an exception is thrown when sending a request without specifying a URL.
271268
*
272269
* @covers ::sendRequest
273-
* @expectedException \Exception
270+
*
274271
*/
275272
public function testSendRequestWithoutUrl()
276273
{
274+
$this->expectException(Exception::class);
277275
$this->getHttpClient()
278276
->setRequestParameters(['foo' => 'bar'])
279277
->setMethod('GET')
@@ -338,7 +336,7 @@ public function sendRequestProvider()
338336
'module' => 'API',
339337
'method' => 'API.getMatomoVersion',
340338
],
341-
]
339+
],
342340
],
343341
[
344342
// The HTTP method to use.
@@ -358,7 +356,7 @@ public function sendRequestProvider()
358356
'module' => 'API',
359357
'method' => 'API.getMatomoVersion',
360358
],
361-
]
359+
],
362360
],
363361
];
364362
}

0 commit comments

Comments
 (0)