Skip to content

Commit

Permalink
Merge pull request #83 from ackintosh/drop-php71-php72
Browse files Browse the repository at this point in the history
Drop PHP7.1, 7.2 and Add PHP 8.0
  • Loading branch information
ackintosh committed Jun 19, 2021
2 parents 697bce3 + 1359509 commit 5ec6567
Show file tree
Hide file tree
Showing 16 changed files with 78 additions and 67 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,9 @@ jobs:
strategy:
matrix:
php-version:
- "7.1"
- "7.2"
- "7.3"
- "7.4"
# We'll enable "8.0" after that dropping PHP 7.1 support and bump up the PHPUnit version.
# - "8.0"
- "8.0"
steps:
- uses: actions/checkout@v2

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Ganesha is PHP implementation of [Circuit Breaker pattern](http://martinfowler.c

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

[![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/)
[![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/)

</div>

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

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

- Ganesha supports PHP 7.1 or higher.
- Ganesha supports PHP 7.3 or higher.
- 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.

## [Author](#table-of-contents)
Expand Down
12 changes: 9 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@
"email": "sora.akatsuki@gmail.com"
}
],
"repositories": [
{
"type": "git",
"url": "https://github.com/kornrunner/phpunit-testlistener-vcr"
}
],
"require": {
"php": ">=7.1.0",
"php": ">=7.3.0",
"psr/http-message": "~1.0"
},
"suggest": {
Expand All @@ -22,11 +28,11 @@
"ext-mongodb": "Allows the usage of MongoDBAdapter"
},
"require-dev": {
"phpunit/phpunit": "^7.5.19",
"phpunit/phpunit": "^9.5.4",
"symfony/http-client": "^4.3|^5.0",
"symfony/yaml": "^3.0|^4.0|^5.0",
"php-vcr/php-vcr": "^1.4.5",
"php-vcr/phpunit-testlistener-vcr": "~3.2.1",
"php-vcr/phpunit-testlistener-vcr": "dev-php8 as 3.2.2",
"php-coveralls/php-coveralls": "~2.0",
"predis/predis": "^1.1",
"guzzlehttp/guzzle": "~6.5",
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
version: '2'
services:
server:
image: php:7.2-apache
image: php:7.4-apache
container_name: server
volumes:
- ./examples:/var/www/html
Expand Down
23 changes: 12 additions & 11 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="tests/bootstrap.php" colors="true">
<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">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
<report>
<clover outputFile="build/logs/clover.xml"/>
<text outputFile="php://stdout" showUncoveredFiles="false"/>
</report>
</coverage>
<testsuites>
<testsuite name="PHPUnit">
<directory>./tests/*</directory>
</testsuite>
</testsuites>
<logging>
<log type="coverage-clover" target="build/logs/clover.xml"/>
<log type="coverage-text" target="php://stdout" showUncoveredFiles="false" />
</logging>
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
<logging/>
<listeners>
<listener class="VCR\PHPUnit\TestListener\VCRTestListener" file="vendor/php-vcr/phpunit-testlistener-vcr/src/VCRTestListener.php" />
<listener class="VCR\PHPUnit\TestListener\VCRTestListener" file="vendor/php-vcr/phpunit-testlistener-vcr/src/VCRTestListener.php"/>
</listeners>
</phpunit>
16 changes: 8 additions & 8 deletions tests/Ackintosh/Ganesha/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,32 @@ public function dontOverrideTheSpecifiedParameter()

/**
* @test
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage DateTime should be an instance of AdapterInterface
*/
public function validateAdapter()
{
$this->expectExceptionMessage("DateTime should be an instance of AdapterInterface");
$this->expectException(\InvalidArgumentException::class);
Configuration::validate([Configuration::ADAPTER => new \DateTime]);
}

/**
* @test
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage DateTime should be an instance of StorageKeysInterface
*/
public function validateStorageKey()
{
$this->expectExceptionMessage("DateTime should be an instance of StorageKeysInterface");
$this->expectException(\InvalidArgumentException::class);
Configuration::validate([Configuration::STORAGE_KEYS => new \DateTime()]);
}

/**
* @test
* @dataProvider validateIntegerProvider
* @expectedException \InvalidArgumentException
* @expectedExceptionMessageRegExp /^[a-zA-Z]+ should be an positive integer$/
*/
public function validateInteger(string $key)
{
$this->expectExceptionMessageMatches("/^[a-zA-Z]+ should be an positive integer$/");
$this->expectException(\InvalidArgumentException::class);
Configuration::validate([$key => 0]);
}

Expand All @@ -69,11 +69,11 @@ public function validateIntegerProvider()

/**
* @test
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage failureRateThreshold should be equal or less than 100
*/
public function validateFailureRateThreshold()
{
$this->expectExceptionMessage("failureRateThreshold should be equal or less than 100");
$this->expectException(\InvalidArgumentException::class);
Configuration::validate([Configuration::FAILURE_RATE_THRESHOLD => 101]);
}
}
Expand Down
6 changes: 4 additions & 2 deletions tests/Ackintosh/Ganesha/GuzzleMiddlewareTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
namespace Ackintosh\Ganesha;

use Ackintosh\Ganesha\Exception\RejectedException;
use Ackintosh\Ganesha\Storage\Adapter\Memcached;
use Ackintosh\Ganesha\Storage\Adapter\Redis;
use GuzzleHttp\Client;
Expand All @@ -17,7 +18,7 @@ class GuzzleMiddlewareTest extends TestCase
*/
private $adapter;

protected function setUp()
protected function setUp(): void
{
if (!\extension_loaded('redis')) {
self::markTestSkipped('No ext-redis present');
Expand Down Expand Up @@ -127,10 +128,11 @@ public function recordsFailureOnRequestTimedOut()

/**
* @test
* @expectedException \Ackintosh\Ganesha\Exception\RejectedException
*/
public function reject()
{
$this->expectException(RejectedException::class);

// Build Ganesha which has count strategy with memcached adapter
$m = new \Memcached();
$m->addServer(
Expand Down
44 changes: 23 additions & 21 deletions tests/Ackintosh/Ganesha/Storage/Adapter/AbstractRedisTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ abstract class AbstractRedisTest extends TestCase
*/
private $context;

protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down Expand Up @@ -94,11 +94,11 @@ public function incrementAndLoad()

/**
* @test
* @expectedException \Ackintosh\Ganesha\Exception\StorageException
* @expectedExceptionMessageRegExp /\AFailed to remove expired elements/
*/
public function incrementThrowsExceptionWhenFailedToRunzRemRangeByScore()
{
$this->expectExceptionMessageMatches("/\AFailed to remove expired elements/");
$this->expectException(StorageException::class);
$mock = $this->getMockBuilder(\Redis::class)->getMock();
$mock->method('zRemRangeByScore')
->willReturn(false);
Expand All @@ -108,11 +108,11 @@ public function incrementThrowsExceptionWhenFailedToRunzRemRangeByScore()

/**
* @test
* @expectedException \Ackintosh\Ganesha\Exception\StorageException
* @expectedExceptionMessageRegExp /\AFailed to execute zAdd command/
*/
public function incrementThrowsExceptionWhenFailedToRunzAdd()
{
$this->expectExceptionMessageMatches("/\AFailed to execute zAdd command/");
$this->expectException(StorageException::class);
$mock = $this->getMockBuilder(\Redis::class)->getMock();
$mock->method('zAdd')
->willReturn(false);
Expand All @@ -122,11 +122,11 @@ public function incrementThrowsExceptionWhenFailedToRunzAdd()

/**
* @test
* @expectedException \Ackintosh\Ganesha\Exception\StorageException
* @expectedExceptionMessage exception test
*/
public function incrementThrowsException()
{
$this->expectExceptionMessage('exception test');
$this->expectException(StorageException::class);
$mock = $this->getMockBuilder(\Redis::class)->getMock();
$mock->method('zAdd')
->willThrowException(new \RedisException('exception test'));
Expand All @@ -136,11 +136,11 @@ public function incrementThrowsException()

/**
* @test
* @expectedException \Ackintosh\Ganesha\Exception\StorageException
* @expectedExceptionMessageRegExp /\AFailed to remove expired elements/
*/
public function loadThrowsExceptionWhenFailedToRunzRemRangeByScore()
{
$this->expectExceptionMessageMatches("/\AFailed to remove expired elements/");
$this->expectException(StorageException::class);
$mock = $this->getMockBuilder(\Redis::class)->getMock();
$mock->method('zRemRangeByScore')
->willReturn(false);
Expand All @@ -150,11 +150,11 @@ public function loadThrowsExceptionWhenFailedToRunzRemRangeByScore()

/**
* @test
* @expectedException \Ackintosh\Ganesha\Exception\StorageException
* @expectedExceptionMessageRegExp /\AFailed to execute zCard command/
*/
public function loadThrowsExceptionWhenFailedToRunzCard()
{
$this->expectExceptionMessageMatches("/\AFailed to execute zCard command/");
$this->expectException(StorageException::class);
$mock = $this->getMockBuilder(\Redis::class)->getMock();
$mock->method('zCard')
->willReturn(false);
Expand All @@ -164,11 +164,11 @@ public function loadThrowsExceptionWhenFailedToRunzCard()

/**
* @test
* @expectedException \Ackintosh\Ganesha\Exception\StorageException
* @expectedExceptionMessage exception test
*/
public function loadThrowsException()
{
$this->expectExceptionMessage('exception test');
$this->expectException(StorageException::class);
$mock = $this->getMockBuilder(\Redis::class)->getMock();
$mock->method('zCard')
->willThrowException(new \RedisException('exception test'));
Expand Down Expand Up @@ -215,11 +215,11 @@ public function loadLastFailureTimeReturnsNullIfNoData()

/**
* @test
* @expectedException \Ackintosh\Ganesha\Exception\StorageException
* @expectedExceptionMessage exception test
*/
public function loadLastFailureTimeThrowsException()
{
$this->expectExceptionMessage('exception test');
$this->expectException(StorageException::class);
$mock = $this->getMockBuilder(\Redis::class)->getMock();
$mock->method('zRange')
->willThrowException(new \RedisException('exception test'));
Expand All @@ -246,11 +246,11 @@ public function saveAndLoadStatus()

/**
* @test
* @expectedException \Ackintosh\Ganesha\Exception\StorageException
* @expectedExceptionMessageRegExp /\AFailed to save status/
*/
public function saveStatusThrowsExceptionWhenFailedToRunset()
{
$this->expectExceptionMessageMatches("/\AFailed to save status/");
$this->expectException(StorageException::class);
$mock = $this->getMockBuilder(\Redis::class)->getMock();
$mock->method('set')
->willReturn(false);
Expand All @@ -260,11 +260,13 @@ public function saveStatusThrowsExceptionWhenFailedToRunset()

/**
* @test
* @expectedException \Ackintosh\Ganesha\Exception\StorageException
* @expectedExceptionMessage exception test
*
*
*/
public function saveStatusThrowsException()
{
$this->expectExceptionMessage('exception test');
$this->expectException(StorageException::class);
$mock = $this->getMockBuilder(\Redis::class)->getMock();
$mock->method('set')
->willThrowException(new \RedisException('exception test'));
Expand All @@ -274,11 +276,11 @@ public function saveStatusThrowsException()

/**
* @test
* @expectedException \Ackintosh\Ganesha\Exception\StorageException
* @expectedExceptionMessage exception test
*/
public function loadStatusThrowsException()
{
$this->expectExceptionMessage('exception test');
$this->expectException(\Ackintosh\Ganesha\Exception\StorageException::class);
$mock = $this->getMockBuilder(\Redis::class)->getMock();
$mock->method('get')
->willThrowException(new \RedisException('exception test'));
Expand Down
2 changes: 1 addition & 1 deletion tests/Ackintosh/Ganesha/Storage/Adapter/ApcuStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*/
class ApcuStoreTest extends TestCase
{
protected function tearDown()
protected function tearDown(): void
{
apcu_clear_cache();
parent::tearDown();
Expand Down
2 changes: 1 addition & 1 deletion tests/Ackintosh/Ganesha/Storage/Adapter/ApcuTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ApcuTest extends TestCase
{
private const EXPECT_KEY_REGEX = '/^\\^ .+( s| f| r| \\$| \\/)$/';

protected function tearDown()
protected function tearDown(): void
{
apcu_clear_cache();
parent::tearDown();
Expand Down
4 changes: 2 additions & 2 deletions tests/Ackintosh/Ganesha/Storage/Adapter/MemcachedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MemcachedTest extends TestCase
*/
private $service = 'testService';

protected function setUp()
protected function setUp(): void
{
if (!extension_loaded('memcached')) {
self::markTestSkipped('No ext-memcached present');
Expand Down Expand Up @@ -362,7 +362,7 @@ public function resetThrowsExceptionWhenFailedToGetAllKeys()
$adapter = new Memcached($m);

$this->expectException(\RuntimeException::class);
$this->expectExceptionMessageRegExp('/^failed to get memcached keys/');
$this->expectExceptionMessageMatches('/^failed to get memcached keys/');
$adapter->reset();
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Ackintosh/Ganesha/Storage/Adapter/MongoDBTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class MongoDBTest extends TestCase
/**
* @throws \Exception
*/
protected function setUp()
protected function setUp(): void
{
parent::setUp();

Expand Down
Loading

0 comments on commit 5ec6567

Please sign in to comment.