Skip to content

Commit 5ec6567

Browse files
authored
Merge pull request #83 from ackintosh/drop-php71-php72
Drop PHP7.1, 7.2 and Add PHP 8.0
2 parents 697bce3 + 1359509 commit 5ec6567

16 files changed

+78
-67
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,9 @@ jobs:
3131
strategy:
3232
matrix:
3333
php-version:
34-
- "7.1"
35-
- "7.2"
3634
- "7.3"
3735
- "7.4"
38-
# We'll enable "8.0" after that dropping PHP 7.1 support and bump up the PHPUnit version.
39-
# - "8.0"
36+
- "8.0"
4037
steps:
4138
- uses: actions/checkout@v2
4239

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Ganesha is PHP implementation of [Circuit Breaker pattern](http://martinfowler.c
66

77
![ganesha](https://ackintosh.github.io/assets/images/ganesha.png)
88

9-
[![Latest Stable Version](https://img.shields.io/packagist/v/ackintosh/ganesha.svg?style=flat-square)](https://packagist.org/packages/ackintosh/ganesha) [![Tests](https://github.com/ackintosh/ganesha/workflows/Tests/badge.svg)](https://github.com/ackintosh/ganesha/actions) [![Coverage Status](https://coveralls.io/repos/github/ackintosh/ganesha/badge.svg?branch=master)](https://coveralls.io/github/ackintosh/ganesha?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ackintosh/ganesha/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ackintosh/ganesha/?branch=master) [![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.1-8892BF.svg?style=flat-square)](https://php.net/)
9+
[![Latest Stable Version](https://img.shields.io/packagist/v/ackintosh/ganesha.svg?style=flat-square)](https://packagist.org/packages/ackintosh/ganesha) [![Tests](https://github.com/ackintosh/ganesha/workflows/Tests/badge.svg)](https://github.com/ackintosh/ganesha/actions) [![Coverage Status](https://coveralls.io/repos/github/ackintosh/ganesha/badge.svg?branch=master)](https://coveralls.io/github/ackintosh/ganesha?branch=master) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ackintosh/ganesha/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ackintosh/ganesha/?branch=master) [![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.3-8892BF.svg?style=flat-square)](https://php.net/)
1010

1111
</div>
1212

@@ -667,7 +667,7 @@ $ docker-compose run --rm -w /tmp/ganesha -u ganesha client vendor/bin/phpunit
667667

668668
## [Requirements](#table-of-contents)
669669

670-
- Ganesha supports PHP 7.1 or higher.
670+
- Ganesha supports PHP 7.3 or higher.
671671
- An extension or client library which is used by [the storage adapter](https://github.com/ackintosh/ganesha#adapters) you've choice will be required. Please check the [Adapters](https://github.com/ackintosh/ganesha#adapters) section for details.
672672

673673
## [Author](#table-of-contents)

composer.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,14 @@
1010
"email": "[email protected]"
1111
}
1212
],
13+
"repositories": [
14+
{
15+
"type": "git",
16+
"url": "https://github.com/kornrunner/phpunit-testlistener-vcr"
17+
}
18+
],
1319
"require": {
14-
"php": ">=7.1.0",
20+
"php": ">=7.3.0",
1521
"psr/http-message": "~1.0"
1622
},
1723
"suggest": {
@@ -22,11 +28,11 @@
2228
"ext-mongodb": "Allows the usage of MongoDBAdapter"
2329
},
2430
"require-dev": {
25-
"phpunit/phpunit": "^7.5.19",
31+
"phpunit/phpunit": "^9.5.4",
2632
"symfony/http-client": "^4.3|^5.0",
2733
"symfony/yaml": "^3.0|^4.0|^5.0",
2834
"php-vcr/php-vcr": "^1.4.5",
29-
"php-vcr/phpunit-testlistener-vcr": "~3.2.1",
35+
"php-vcr/phpunit-testlistener-vcr": "dev-php8 as 3.2.2",
3036
"php-coveralls/php-coveralls": "~2.0",
3137
"predis/predis": "^1.1",
3238
"guzzlehttp/guzzle": "~6.5",

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '2'
22
services:
33
server:
4-
image: php:7.2-apache
4+
image: php:7.4-apache
55
container_name: server
66
volumes:
77
- ./examples:/var/www/html

phpunit.xml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit bootstrap="tests/bootstrap.php" colors="true">
2+
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="tests/bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
3+
<coverage processUncoveredFiles="true">
4+
<include>
5+
<directory suffix=".php">./src</directory>
6+
</include>
7+
<report>
8+
<clover outputFile="build/logs/clover.xml"/>
9+
<text outputFile="php://stdout" showUncoveredFiles="false"/>
10+
</report>
11+
</coverage>
312
<testsuites>
413
<testsuite name="PHPUnit">
514
<directory>./tests/*</directory>
615
</testsuite>
716
</testsuites>
8-
<logging>
9-
<log type="coverage-clover" target="build/logs/clover.xml"/>
10-
<log type="coverage-text" target="php://stdout" showUncoveredFiles="false" />
11-
</logging>
12-
<filter>
13-
<whitelist processUncoveredFilesFromWhitelist="true">
14-
<directory suffix=".php">./src</directory>
15-
</whitelist>
16-
</filter>
17+
<logging/>
1718
<listeners>
18-
<listener class="VCR\PHPUnit\TestListener\VCRTestListener" file="vendor/php-vcr/phpunit-testlistener-vcr/src/VCRTestListener.php" />
19+
<listener class="VCR\PHPUnit\TestListener\VCRTestListener" file="vendor/php-vcr/phpunit-testlistener-vcr/src/VCRTestListener.php"/>
1920
</listeners>
2021
</phpunit>

tests/Ackintosh/Ganesha/ConfigurationTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,32 @@ public function dontOverrideTheSpecifiedParameter()
2727

2828
/**
2929
* @test
30-
* @expectedException \InvalidArgumentException
31-
* @expectedExceptionMessage DateTime should be an instance of AdapterInterface
3230
*/
3331
public function validateAdapter()
3432
{
33+
$this->expectExceptionMessage("DateTime should be an instance of AdapterInterface");
34+
$this->expectException(\InvalidArgumentException::class);
3535
Configuration::validate([Configuration::ADAPTER => new \DateTime]);
3636
}
3737

3838
/**
3939
* @test
40-
* @expectedException \InvalidArgumentException
41-
* @expectedExceptionMessage DateTime should be an instance of StorageKeysInterface
4240
*/
4341
public function validateStorageKey()
4442
{
43+
$this->expectExceptionMessage("DateTime should be an instance of StorageKeysInterface");
44+
$this->expectException(\InvalidArgumentException::class);
4545
Configuration::validate([Configuration::STORAGE_KEYS => new \DateTime()]);
4646
}
4747

4848
/**
4949
* @test
5050
* @dataProvider validateIntegerProvider
51-
* @expectedException \InvalidArgumentException
52-
* @expectedExceptionMessageRegExp /^[a-zA-Z]+ should be an positive integer$/
5351
*/
5452
public function validateInteger(string $key)
5553
{
54+
$this->expectExceptionMessageMatches("/^[a-zA-Z]+ should be an positive integer$/");
55+
$this->expectException(\InvalidArgumentException::class);
5656
Configuration::validate([$key => 0]);
5757
}
5858

@@ -69,11 +69,11 @@ public function validateIntegerProvider()
6969

7070
/**
7171
* @test
72-
* @expectedException \InvalidArgumentException
73-
* @expectedExceptionMessage failureRateThreshold should be equal or less than 100
7472
*/
7573
public function validateFailureRateThreshold()
7674
{
75+
$this->expectExceptionMessage("failureRateThreshold should be equal or less than 100");
76+
$this->expectException(\InvalidArgumentException::class);
7777
Configuration::validate([Configuration::FAILURE_RATE_THRESHOLD => 101]);
7878
}
7979
}

tests/Ackintosh/Ganesha/GuzzleMiddlewareTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22
namespace Ackintosh\Ganesha;
33

4+
use Ackintosh\Ganesha\Exception\RejectedException;
45
use Ackintosh\Ganesha\Storage\Adapter\Memcached;
56
use Ackintosh\Ganesha\Storage\Adapter\Redis;
67
use GuzzleHttp\Client;
@@ -17,7 +18,7 @@ class GuzzleMiddlewareTest extends TestCase
1718
*/
1819
private $adapter;
1920

20-
protected function setUp()
21+
protected function setUp(): void
2122
{
2223
if (!\extension_loaded('redis')) {
2324
self::markTestSkipped('No ext-redis present');
@@ -127,10 +128,11 @@ public function recordsFailureOnRequestTimedOut()
127128

128129
/**
129130
* @test
130-
* @expectedException \Ackintosh\Ganesha\Exception\RejectedException
131131
*/
132132
public function reject()
133133
{
134+
$this->expectException(RejectedException::class);
135+
134136
// Build Ganesha which has count strategy with memcached adapter
135137
$m = new \Memcached();
136138
$m->addServer(

tests/Ackintosh/Ganesha/Storage/Adapter/AbstractRedisTest.php

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ abstract class AbstractRedisTest extends TestCase
2828
*/
2929
private $context;
3030

31-
protected function setUp()
31+
protected function setUp(): void
3232
{
3333
parent::setUp();
3434

@@ -94,11 +94,11 @@ public function incrementAndLoad()
9494

9595
/**
9696
* @test
97-
* @expectedException \Ackintosh\Ganesha\Exception\StorageException
98-
* @expectedExceptionMessageRegExp /\AFailed to remove expired elements/
9997
*/
10098
public function incrementThrowsExceptionWhenFailedToRunzRemRangeByScore()
10199
{
100+
$this->expectExceptionMessageMatches("/\AFailed to remove expired elements/");
101+
$this->expectException(StorageException::class);
102102
$mock = $this->getMockBuilder(\Redis::class)->getMock();
103103
$mock->method('zRemRangeByScore')
104104
->willReturn(false);
@@ -108,11 +108,11 @@ public function incrementThrowsExceptionWhenFailedToRunzRemRangeByScore()
108108

109109
/**
110110
* @test
111-
* @expectedException \Ackintosh\Ganesha\Exception\StorageException
112-
* @expectedExceptionMessageRegExp /\AFailed to execute zAdd command/
113111
*/
114112
public function incrementThrowsExceptionWhenFailedToRunzAdd()
115113
{
114+
$this->expectExceptionMessageMatches("/\AFailed to execute zAdd command/");
115+
$this->expectException(StorageException::class);
116116
$mock = $this->getMockBuilder(\Redis::class)->getMock();
117117
$mock->method('zAdd')
118118
->willReturn(false);
@@ -122,11 +122,11 @@ public function incrementThrowsExceptionWhenFailedToRunzAdd()
122122

123123
/**
124124
* @test
125-
* @expectedException \Ackintosh\Ganesha\Exception\StorageException
126-
* @expectedExceptionMessage exception test
127125
*/
128126
public function incrementThrowsException()
129127
{
128+
$this->expectExceptionMessage('exception test');
129+
$this->expectException(StorageException::class);
130130
$mock = $this->getMockBuilder(\Redis::class)->getMock();
131131
$mock->method('zAdd')
132132
->willThrowException(new \RedisException('exception test'));
@@ -136,11 +136,11 @@ public function incrementThrowsException()
136136

137137
/**
138138
* @test
139-
* @expectedException \Ackintosh\Ganesha\Exception\StorageException
140-
* @expectedExceptionMessageRegExp /\AFailed to remove expired elements/
141139
*/
142140
public function loadThrowsExceptionWhenFailedToRunzRemRangeByScore()
143141
{
142+
$this->expectExceptionMessageMatches("/\AFailed to remove expired elements/");
143+
$this->expectException(StorageException::class);
144144
$mock = $this->getMockBuilder(\Redis::class)->getMock();
145145
$mock->method('zRemRangeByScore')
146146
->willReturn(false);
@@ -150,11 +150,11 @@ public function loadThrowsExceptionWhenFailedToRunzRemRangeByScore()
150150

151151
/**
152152
* @test
153-
* @expectedException \Ackintosh\Ganesha\Exception\StorageException
154-
* @expectedExceptionMessageRegExp /\AFailed to execute zCard command/
155153
*/
156154
public function loadThrowsExceptionWhenFailedToRunzCard()
157155
{
156+
$this->expectExceptionMessageMatches("/\AFailed to execute zCard command/");
157+
$this->expectException(StorageException::class);
158158
$mock = $this->getMockBuilder(\Redis::class)->getMock();
159159
$mock->method('zCard')
160160
->willReturn(false);
@@ -164,11 +164,11 @@ public function loadThrowsExceptionWhenFailedToRunzCard()
164164

165165
/**
166166
* @test
167-
* @expectedException \Ackintosh\Ganesha\Exception\StorageException
168-
* @expectedExceptionMessage exception test
169167
*/
170168
public function loadThrowsException()
171169
{
170+
$this->expectExceptionMessage('exception test');
171+
$this->expectException(StorageException::class);
172172
$mock = $this->getMockBuilder(\Redis::class)->getMock();
173173
$mock->method('zCard')
174174
->willThrowException(new \RedisException('exception test'));
@@ -215,11 +215,11 @@ public function loadLastFailureTimeReturnsNullIfNoData()
215215

216216
/**
217217
* @test
218-
* @expectedException \Ackintosh\Ganesha\Exception\StorageException
219-
* @expectedExceptionMessage exception test
220218
*/
221219
public function loadLastFailureTimeThrowsException()
222220
{
221+
$this->expectExceptionMessage('exception test');
222+
$this->expectException(StorageException::class);
223223
$mock = $this->getMockBuilder(\Redis::class)->getMock();
224224
$mock->method('zRange')
225225
->willThrowException(new \RedisException('exception test'));
@@ -246,11 +246,11 @@ public function saveAndLoadStatus()
246246

247247
/**
248248
* @test
249-
* @expectedException \Ackintosh\Ganesha\Exception\StorageException
250-
* @expectedExceptionMessageRegExp /\AFailed to save status/
251249
*/
252250
public function saveStatusThrowsExceptionWhenFailedToRunset()
253251
{
252+
$this->expectExceptionMessageMatches("/\AFailed to save status/");
253+
$this->expectException(StorageException::class);
254254
$mock = $this->getMockBuilder(\Redis::class)->getMock();
255255
$mock->method('set')
256256
->willReturn(false);
@@ -260,11 +260,13 @@ public function saveStatusThrowsExceptionWhenFailedToRunset()
260260

261261
/**
262262
* @test
263-
* @expectedException \Ackintosh\Ganesha\Exception\StorageException
264-
* @expectedExceptionMessage exception test
263+
*
264+
*
265265
*/
266266
public function saveStatusThrowsException()
267267
{
268+
$this->expectExceptionMessage('exception test');
269+
$this->expectException(StorageException::class);
268270
$mock = $this->getMockBuilder(\Redis::class)->getMock();
269271
$mock->method('set')
270272
->willThrowException(new \RedisException('exception test'));
@@ -274,11 +276,11 @@ public function saveStatusThrowsException()
274276

275277
/**
276278
* @test
277-
* @expectedException \Ackintosh\Ganesha\Exception\StorageException
278-
* @expectedExceptionMessage exception test
279279
*/
280280
public function loadStatusThrowsException()
281281
{
282+
$this->expectExceptionMessage('exception test');
283+
$this->expectException(\Ackintosh\Ganesha\Exception\StorageException::class);
282284
$mock = $this->getMockBuilder(\Redis::class)->getMock();
283285
$mock->method('get')
284286
->willThrowException(new \RedisException('exception test'));

tests/Ackintosh/Ganesha/Storage/Adapter/ApcuStoreTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*/
1010
class ApcuStoreTest extends TestCase
1111
{
12-
protected function tearDown()
12+
protected function tearDown(): void
1313
{
1414
apcu_clear_cache();
1515
parent::tearDown();

tests/Ackintosh/Ganesha/Storage/Adapter/ApcuTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ApcuTest extends TestCase
1616
{
1717
private const EXPECT_KEY_REGEX = '/^\\^ .+( s| f| r| \\$| \\/)$/';
1818

19-
protected function tearDown()
19+
protected function tearDown(): void
2020
{
2121
apcu_clear_cache();
2222
parent::tearDown();

0 commit comments

Comments
 (0)