Skip to content

Commit 4c012c3

Browse files
authored
Merge pull request #127 from marmichalski/php81
feat: require php 8.1 & update phpunit to v10
2 parents 825e357 + fb3b960 commit 4c012c3

16 files changed

+64
-60
lines changed

.github/workflows/code-style.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
- name: Install PHP
1818
uses: shivammathur/setup-php@v2
1919
with:
20-
php-version: 8.0
20+
php-version: 8.1
2121
tools: composer
2222
# Specific versions of extensions available on PECL can be set up by suffixing the extension's name with the version.
2323
# https://github.com/shivammathur/setup-php?tab=readme-ov-file#heavy_plus_sign-php-extension-support
@@ -29,4 +29,4 @@ jobs:
2929
run: composer update
3030

3131
- name: Run php-cs-fixer
32-
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff .
32+
run: ./vendor/bin/php-cs-fixer fix --dry-run --diff .

.github/workflows/tests.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ jobs:
3232
fail-fast: false
3333
matrix:
3434
php-version:
35-
- "8.0"
3635
- "8.1"
3736
- "8.2"
3837
- "8.3"
@@ -65,7 +64,7 @@ jobs:
6564

6665
# https://github.com/php-coveralls/php-coveralls#github-actions
6766
- name: Upload coverage results to Coveralls
68-
if: ${{ matrix.php-version == '8.0' }}
67+
if: ${{ matrix.php-version == '8.1' }}
6968
env:
7069
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7170
run: |

README.md

+1-1
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%208.0-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%208.1-8892BF.svg?style=flat-square)](https://php.net/)
1010

1111
</div>
1212

composer.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313
"repositories": [
1414
{
1515
"type": "git",
16-
"url": "https://github.com/kornrunner/phpunit-testlistener-vcr"
16+
"url": "https://github.com/marmichalski/phpunit-testlistener-vcr"
1717
}
1818
],
1919
"require": {
20-
"php": ">=8.0",
20+
"php": "^8.1",
2121
"psr/http-message": "^1.0|^2.0"
2222
},
2323
"suggest": {
@@ -28,11 +28,11 @@
2828
"ext-mongodb": "Allows the usage of MongoDBAdapter"
2929
},
3030
"require-dev": {
31-
"phpunit/phpunit": "^9.5.10",
31+
"phpunit/phpunit": "^10.5.41",
3232
"symfony/http-client": "^5.3.12|^6.0",
3333
"symfony/yaml": "^3.0|^4.0|^5.0|^6.0",
34-
"php-vcr/php-vcr": "^1.4.5",
35-
"php-vcr/phpunit-testlistener-vcr": "dev-php8 as 3.2.2",
34+
"php-vcr/php-vcr": "dev-master#c0aeeba0f3804fcfdb9cd6b390b0cb3be250c070 as 1.9.0",
35+
"php-vcr/phpunit-testlistener-vcr": "dev-phpunit-evt-system",
3636
"php-coveralls/php-coveralls": "~2.5",
3737
"predis/predis": "^1.1",
3838
"guzzlehttp/guzzle": "^7.4.5",

docker-compose.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
version: '2'
22
services:
33
server:
4-
image: php:8.0-apache
4+
image: php:8.1-apache
55
container_name: server
66
volumes:
77
- ./examples:/var/www/html

examples/client/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM php:8.0-cli
1+
FROM php:8.1-cli
22

33
COPY install_composer.sh /tmp/
44

phpunit.xml

+15-8
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
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>
2+
<phpunit
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
5+
bootstrap="tests/bootstrap.php"
6+
colors="true"
7+
>
8+
<coverage>
79
<report>
810
<!-- https://github.com/php-coveralls/php-coveralls#phpunit -->
911
<clover outputFile="build/logs/clover.xml"/>
@@ -16,7 +18,12 @@
1618
</testsuite>
1719
</testsuites>
1820
<logging/>
19-
<listeners>
20-
<listener class="VCR\PHPUnit\TestListener\VCRTestListener" file="vendor/php-vcr/phpunit-testlistener-vcr/src/VCRTestListener.php"/>
21-
</listeners>
21+
<source>
22+
<include>
23+
<directory suffix=".php">./src</directory>
24+
</include>
25+
</source>
26+
<extensions>
27+
<bootstrap class="VCR\PHPUnit\TestListener\Extension\VCRExtension" />
28+
</extensions>
2229
</phpunit>

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use PHPUnit\Framework\MockObject\MockObject;
99
use PHPUnit\Framework\TestCase;
1010

11-
abstract class AbstractRedisTest extends TestCase
11+
abstract class AbstractRedisSpec extends TestCase
1212
{
1313
/**
1414
* @var int

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ protected function tearDown(): void
2222
*/
2323
public function test_dec()
2424
{
25-
$key = $this->getName();
25+
$key = $this->name();
2626
$store = new ApcuStore();
2727

2828
$this->assertSame(-1, $store->dec($key));
@@ -37,7 +37,7 @@ public function test_dec()
3737
*/
3838
public function test_delete()
3939
{
40-
$key = $this->getName();
40+
$key = $this->name();
4141
$value = __METHOD__;
4242
$store = new ApcuStore();
4343

@@ -52,7 +52,7 @@ public function test_delete()
5252
*/
5353
public function test_exists()
5454
{
55-
$key = $this->getName();
55+
$key = $this->name();
5656
$value = __METHOD__;
5757
$store = new ApcuStore();
5858

@@ -67,7 +67,7 @@ public function test_exists()
6767
*/
6868
public function test_fetch()
6969
{
70-
$key = $this->getName();
70+
$key = $this->name();
7171
$value = __METHOD__;
7272
$store = new ApcuStore();
7373

@@ -88,7 +88,7 @@ public function test_fetch()
8888
*/
8989
public function test_inc()
9090
{
91-
$key = $this->getName();
91+
$key = $this->name();
9292
$store = new ApcuStore();
9393

9494
$this->assertSame(1, $store->inc($key));
@@ -103,7 +103,7 @@ public function test_inc()
103103
*/
104104
public function test_store()
105105
{
106-
$key = $this->getName();
106+
$key = $this->name();
107107
$value = __METHOD__;
108108
$store = new ApcuStore();
109109

@@ -130,7 +130,7 @@ public function provide_getIterator()
130130
*/
131131
public function test_getIterator(?string $pattern, int $expectCount)
132132
{
133-
$name = $this->getName();
133+
$name = $this->name();
134134
$keys = array_map(
135135
function ($index) use ($name) {
136136
return sprintf('%s %d', $name, $index);

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,7 @@ private function getConfiguration(?StorageKeysInterface $storageKeys = null)
690690

691691
private function getStorageKeys()
692692
{
693-
$storageKeys = $this->getMockForAbstractClass(StorageKeysInterface::class);
693+
$storageKeys = $this->createMock(StorageKeysInterface::class);
694694
$storageKeys->method('prefix')->willReturn('ganesha_');
695695
$storageKeys->method('success')->willReturn('_success');
696696
$storageKeys->method('failure')->willReturn('_failure');
@@ -702,16 +702,16 @@ private function getStorageKeys()
702702

703703
private function getSuccessKey()
704704
{
705-
return sprintf('ganesha_%s_success', $this->getName());
705+
return sprintf('ganesha_%s_success', $this->name());
706706
}
707707

708708
private function getLastFailureTimeKey()
709709
{
710-
return sprintf('ganesha_%s_last_failure_time', $this->getName());
710+
return sprintf('ganesha_%s_last_failure_time', $this->name());
711711
}
712712

713713
private function getStatusKey()
714714
{
715-
return sprintf('ganesha_%s_status', $this->getName());
715+
return sprintf('ganesha_%s_status', $this->name());
716716
}
717717
}

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

+11-11
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function saveAndLoad()
9090
public function loadThrowsException()
9191
{
9292
$m = $this->getMockBuilder(\Memcached::class)
93-
->setMethods(['getResultCode'])
93+
->onlyMethods(['getResultCode'])
9494
->getMock();
9595
$m->expects($this->once())
9696
->method('getResultCode')
@@ -109,7 +109,7 @@ public function loadThrowsException()
109109
public function saveThrowsException()
110110
{
111111
$m = $this->getMockBuilder(\Memcached::class)
112-
->setMethods(['set'])
112+
->onlyMethods(['set'])
113113
->getMock();
114114
$m->expects($this->once())
115115
->method('set')
@@ -141,7 +141,7 @@ public function increment()
141141
public function incrementThrowsException()
142142
{
143143
$m = $this->getMockBuilder(\Memcached::class)
144-
->setMethods(['increment'])
144+
->onlyMethods(['increment'])
145145
->getMock();
146146
$m->expects($this->once())
147147
->method('increment')
@@ -179,7 +179,7 @@ public function decrement()
179179
public function decrementThrowsException()
180180
{
181181
$m = $this->getMockBuilder(\Memcached::class)
182-
->setMethods(['decrement'])
182+
->onlyMethods(['decrement'])
183183
->getMock();
184184
$m->expects($this->once())
185185
->method('decrement')
@@ -210,7 +210,7 @@ public function saveAndLoadLastFailureTime()
210210
public function saveLastFailureTimeThrowsException()
211211
{
212212
$m = $this->getMockBuilder(\Memcached::class)
213-
->setMethods(['set'])
213+
->onlyMethods(['set'])
214214
->getMock();
215215
$m->expects($this->once())
216216
->method('set')
@@ -229,7 +229,7 @@ public function saveLastFailureTimeThrowsException()
229229
public function loadLastFailureTimeThrowsException()
230230
{
231231
$m = $this->getMockBuilder(\Memcached::class)
232-
->setMethods(['getResultCode'])
232+
->onlyMethods(['getResultCode'])
233233
->getMock();
234234
$m->expects($this->once())
235235
->method('getResultCode')
@@ -260,7 +260,7 @@ public function saveAndLoadStatus()
260260
public function saveStatusThrowsException()
261261
{
262262
$m = $this->getMockBuilder(\Memcached::class)
263-
->setMethods(['set'])
263+
->onlyMethods(['set'])
264264
->getMock();
265265
$m->expects($this->once())
266266
->method('set')
@@ -279,7 +279,7 @@ public function saveStatusThrowsException()
279279
public function loadStatusThrowsException()
280280
{
281281
$m = $this->getMockBuilder(\Memcached::class)
282-
->setMethods(['getResultCode'])
282+
->onlyMethods(['getResultCode'])
283283
->getMock();
284284
$m->expects($this->once())
285285
->method('getResultCode')
@@ -299,7 +299,7 @@ public function loadStatusThrowsException()
299299
public function resetWillDoNothingIfNoDataExists()
300300
{
301301
$m = $this->getMockBuilder(\Memcached::class)
302-
->setMethods(['getStats', 'getAllKeys', 'getResultCode'])
302+
->onlyMethods(['getStats', 'getAllKeys', 'getResultCode'])
303303
->getMock();
304304
$m->expects($this->once())
305305
->method('getStats')
@@ -325,7 +325,7 @@ public function resetWillDoNothingIfNoDataExists()
325325
public function resetThrowsExceptionWhenFailedToGetStats()
326326
{
327327
$m = $this->getMockBuilder(\Memcached::class)
328-
->setMethods(['getStats'])
328+
->onlyMethods(['getStats'])
329329
->getMock();
330330
$m->expects($this->once())
331331
->method('getStats')
@@ -346,7 +346,7 @@ public function resetThrowsExceptionWhenFailedToGetStats()
346346
public function resetThrowsExceptionWhenFailedToGetAllKeys()
347347
{
348348
$m = $this->getMockBuilder(\Memcached::class)
349-
->setMethods(['getStats', 'getAllKeys', 'getResultCode'])
349+
->onlyMethods(['getStats', 'getAllKeys', 'getResultCode'])
350350
->getMock();
351351
$m->expects($this->once())
352352
->method('getStats')

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Predis\Client;
66
use Predis\ClientInterface;
77

8-
class PredisRedisTest extends AbstractRedisTest
8+
class PredisRedisTest extends AbstractRedisSpec
99
{
1010
protected function getRedisConnection(): ClientInterface
1111
{

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
use RedisArray;
66

7-
class RedisArrayTest extends AbstractRedisTest
7+
class RedisArrayTest extends AbstractRedisSpec
88
{
99
/**
1010
* @return RedisArray

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Ackintosh\Ganesha\Storage\Adapter;
44

5-
class RedisRedisTest extends AbstractRedisTest
5+
class RedisRedisTest extends AbstractRedisSpec
66
{
77
/**
88
* @return \Redis

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function zCardThrowsExceptionIfFailed()
2424
$this->expectException(\Ackintosh\Ganesha\Exception\StorageException::class);
2525

2626
$mock = $this->getMockBuilder(\Redis::class)
27-
->setMethods(['zCard'])
27+
->onlyMethods(['zCard'])
2828
->getMock();
2929
$mock->expects($this->any())
3030
->method('zCard')

tests/Ackintosh/GaneshaTest.php

+11-13
Original file line numberDiff line numberDiff line change
@@ -66,26 +66,24 @@ public function recordsSuccessAndClose()
6666
/**
6767
* @test
6868
*/
69-
public function notifyTripped()
69+
public function tripsOnce()
7070
{
71-
$ganesha = $this->buildGanesha(
72-
2,
73-
10
74-
);
71+
$ganesha = $this->buildGanesha(2, 10);
7572

76-
$receiver = $this->getMockBuilder('\stdClass')
77-
->setMethods(['receive'])
78-
->getMock();
79-
$receiver->expects($this->once())
80-
->method('receive')
81-
->with(Ganesha::EVENT_TRIPPED, $this->service, '');
73+
$calledTimes = 0;
8274

83-
$ganesha->subscribe(function ($event, $service, $message) use ($receiver) {
84-
$receiver->receive($event, $service, $message);
75+
$ganesha->subscribe(function ($event, $service, $message) use (&$calledTimes) {
76+
$this->assertSame(Ganesha::EVENT_TRIPPED, $event);
77+
$this->assertSame($this->service, $service);
78+
$this->assertSame('', $message);
79+
80+
++$calledTimes;
8581
});
8682

8783
$ganesha->failure($this->service);
8884
$ganesha->failure($this->service);
85+
86+
$this->assertSame(1, $calledTimes);
8987
}
9088

9189

0 commit comments

Comments
 (0)