Skip to content

Commit

Permalink
Merge pull request #154 from xavierleune/feature/tests-matrix
Browse files Browse the repository at this point in the history
Update matrix with lowest & highest deps + PHP 8.0 & 8.1
  • Loading branch information
Kevinrob authored Jan 10, 2022
2 parents c699f46 + 3b11516 commit 9b63aa3
Show file tree
Hide file tree
Showing 18 changed files with 48 additions and 45 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
php-versions: ['5.6', '7.0', '7.1', '7.2', '7.3', '7.4']
php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1']
dependencies:
- "lowest"
- "highest"
steps:
- uses: actions/checkout@v2

- name: Install PHP
uses: shivammathur/setup-php@v2
with:
Expand All @@ -20,8 +23,10 @@ jobs:
- name: Validate composer.json and composer.lock
run: composer validate

- name: Install dependencies
run: composer install --prefer-dist --no-progress
- name: "Composer install ${{ matrix.dependencies }} dependencies"
uses: "ramsey/composer-install@v1"
with:
dependency-versions: "${{ matrix.dependencies }}"

- name: Run test suite
run: composer run-script test
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
}
],
"require": {
"php": ">=5.5.0",
"php": ">=7.2.0",
"guzzlehttp/guzzle": "^6.0 || ^7.0",
"guzzlehttp/psr7": "^1.7.0 || ^2.0.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.36 || ^5.0",
"doctrine/cache": "^1.0",
"phpunit/phpunit": "^8.5.15 || ^9.5",
"doctrine/cache": "^1.10",
"league/flysystem": "^1.0",
"psr/cache": "^1.0",
"cache/array-adapter": "^0.4 || ^0.5 || ^1.0",
Expand All @@ -39,7 +39,7 @@
},
"suggest": {
"guzzlehttp/guzzle": "For using this library. It was created for Guzzle6 (but you can use it with any PSR-7 HTTP client).",
"doctrine/cache": "This library has a lot of ready-to-use cache storage (to be used with Kevinrob\\GuzzleCache\\Storage\\DoctrineCacheStorage).",
"doctrine/cache": "This library has a lot of ready-to-use cache storage (to be used with Kevinrob\\GuzzleCache\\Storage\\DoctrineCacheStorage). Use only versions >=1.4.0 < 2.0.0",
"league/flysystem": "To be used with Kevinrob\\GuzzleCache\\Storage\\FlysystemStorage",
"psr/cache": "To be used with Kevinrob\\GuzzleCache\\Storage\\Psr6CacheStorage",
"psr/simple-cache": "To be used with Kevinrob\\GuzzleCache\\Storage\\Psr16CacheStorage",
Expand Down
30 changes: 13 additions & 17 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,31 +1,27 @@
<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.1/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.5/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="./vendor/autoload.php"
>
bootstrap="./vendor/autoload.php">
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
<report>
<clover outputFile="coverage.xml"/>
</report>
</coverage>
<php>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0" />
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=0"/>
</php>

<testsuites>
<testsuite name="Project Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>

<logging>
<log type="coverage-clover" target="coverage.xml"/>
</logging>

<logging/>
<listeners>
<listener class="\Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>

</phpunit>
9 changes: 6 additions & 3 deletions src/KeyValueHttpHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public function isEmpty()
* @return mixed Can return any type.
* @since 5.0.0
*/
#[\ReturnTypeWillChange]
public function current()
{
return current($this->values);
Expand All @@ -87,7 +88,7 @@ public function current()
* @return void Any returned value is ignored.
* @since 5.0.0
*/
public function next()
public function next(): void
{
next($this->values);
}
Expand All @@ -97,7 +98,9 @@ public function next()
* @link http://php.net/manual/en/iterator.key.php
* @return mixed scalar on success, or null on failure.
* @since 5.0.0
*
*/
#[\ReturnTypeWillChange]
public function key()
{
return key($this->values);
Expand All @@ -110,7 +113,7 @@ public function key()
* Returns true on success or false on failure.
* @since 5.0.0
*/
public function valid()
public function valid(): bool
{
return key($this->values) !== null;
}
Expand All @@ -121,7 +124,7 @@ public function valid()
* @return void Any returned value is ignored.
* @since 5.0.0
*/
public function rewind()
public function rewind(): void
{
reset($this->values);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class BaseTest extends TestCase
*/
protected $client;

protected function setUp()
protected function setUp(): void
{
// Create default HandlerStack
$stack = HandlerStack::create(function (RequestInterface $request, array $options) {
Expand Down
5 changes: 3 additions & 2 deletions tests/CacheEntryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
namespace Kevinrob\GuzzleCache\Tests;

use Kevinrob\GuzzleCache\CacheEntry;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;

/**
* @group time-sensitive
*/
class CacheEntryTest extends \PHPUnit_Framework_TestCase
class CacheEntryTest extends TestCase
{
/**
* @var RequestInterface
Expand All @@ -23,7 +24,7 @@ class CacheEntryTest extends \PHPUnit_Framework_TestCase

private $responseHeaders = [];

protected function setUp()
protected function setUp(): void
{
parent::setUp();
$this->request = $this->getMockBuilder(RequestInterface::class)->getMock();
Expand Down
2 changes: 1 addition & 1 deletion tests/DelegatingCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class DelegatingCacheTest extends TestCase
*/
protected $stack;

protected function setUp()
protected function setUp(): void
{
// Create default HandlerStack
$this->stack = HandlerStack::create(function (RequestInterface $request, array $options) {
Expand Down
2 changes: 1 addition & 1 deletion tests/GreedyCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class GreedyCacheTest extends TestCase
*/
private $client;

protected function setUp()
protected function setUp(): void
{
$stack = HandlerStack::create(function (RequestInterface $request, array $options) {
switch ($request->getUri()->getPath()) {
Expand Down
2 changes: 1 addition & 1 deletion tests/HeaderExpireTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class HeaderExpireTest extends TestCase
*/
protected $sendError = false;

protected function setUp()
protected function setUp(): void
{
// Create default HandlerStack
$stack = HandlerStack::create(function (RequestInterface $request, array $options) {
Expand Down
2 changes: 1 addition & 1 deletion tests/InvalidateCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class InvalidateCacheTest extends TestCase
*/
protected $client;

protected function setUp()
protected function setUp(): void
{
// Create default HandlerStack
$stack = HandlerStack::create(function () {
Expand Down
2 changes: 0 additions & 2 deletions tests/NullCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

class NullCacheTest extends TestCase
{

public function testCacheIsNeverHit()
{
$stack = HandlerStack::create(new MockHandler([
Expand All @@ -33,5 +32,4 @@ public function testCacheIsNeverHit()

$this->assertEquals(CacheMiddleware::HEADER_CACHE_MISS, $response->getHeaderLine(CacheMiddleware::HEADER_CACHE_INFO));
}

}
2 changes: 1 addition & 1 deletion tests/PublicCacheTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class PublicCacheTest extends TestCase
*/
protected $client;

protected function setUp()
protected function setUp(): void
{
// Create default HandlerStack
$stack = HandlerStack::create(function (RequestInterface $request, array $options) {
Expand Down
4 changes: 2 additions & 2 deletions tests/RequestCacheControlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class RequestCacheControlTest extends TestCase
*/
protected $client;

protected function setUp()
protected function setUp(): void
{
// Create default HandlerStack
$stack = HandlerStack::create(function (RequestInterface $request, array $options) {
Expand Down Expand Up @@ -111,7 +111,7 @@ public function testOnlyIfCachedHeader()
$response->getHeaderLine(CacheMiddleware::HEADER_CACHE_INFO)
);

$this->setExpectedException('GuzzleHttp\Exception\ServerException', '504');
$this->expectException('GuzzleHttp\Exception\ServerException', '504');
$this->client->get('http://test.com/only-if-cached', [
'headers' => [
'Cache-Control' => 'only-if-cached',
Expand Down
2 changes: 1 addition & 1 deletion tests/ResponseAgeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ResponseAgeTest extends TestCase
*/
protected $client;

protected function setUp()
protected function setUp(): void
{
// Create default HandlerStack
$stack = HandlerStack::create(function (RequestInterface $request, array $options) {
Expand Down
2 changes: 1 addition & 1 deletion tests/ResponseCacheControlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ResponseCacheControlTest extends TestCase
*/
protected $client;

protected function setUp()
protected function setUp(): void
{
// Create default HandlerStack
$stack = HandlerStack::create(function (RequestInterface $request, array $options) {
Expand Down
2 changes: 1 addition & 1 deletion tests/ResponseVaryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ResponseVaryTest extends TestCase
*/
protected $client;

protected function setUp()
protected function setUp(): void
{
// Create default HandlerStack
$stack = HandlerStack::create(function (RequestInterface $request, array $options) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Strategy/GreedyCacheStrategyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class GreedyCacheStrategyTest extends TestCase
*/
protected $client;

protected function setUp()
protected function setUp(): void
{
// Create default HandlerStack
$stack = HandlerStack::create(function (RequestInterface $request, array $options) {
Expand Down
2 changes: 1 addition & 1 deletion tests/ValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class ValidationTest extends TestCase
*/
protected $cache;

protected function setUp()
protected function setUp(): void
{
// Create default HandlerStack
$stack = HandlerStack::create(function (RequestInterface $request, array $options) {
Expand Down

0 comments on commit 9b63aa3

Please sign in to comment.