Skip to content

Commit

Permalink
Merge pull request #472 from FriendsOfSymfony/php-7.4
Browse files Browse the repository at this point in the history
test with php 7.4
  • Loading branch information
dbu committed Feb 5, 2020
2 parents 5abb500 + e25654e commit 1658d8a
Show file tree
Hide file tree
Showing 37 changed files with 328 additions and 178 deletions.
25 changes: 16 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,40 @@ cache:
env:
global:
- VARNISH_VERSION=5.1
- SYMFONY_PHPUNIT_VERSION=8
- SYMFONY_DEPRECATIONS_HELPER="max[self]=0"
- DEPENDENCIES="toflar/psr6-symfony-http-cache-store:^2.2.0"

matrix:
fast_finish: true
include:
# Minimum supported versions
- php: 5.6
env: VARNISH_VERSION=3.0 COMPOSER_FLAGS="--prefer-lowest" DEPENDENCIES=""
- php: 7.1
env: VARNISH_VERSION=3.0 SYMFONY_PHPUNIT_VERSION=5.7 COMPOSER_FLAGS="--prefer-lowest" DEPENDENCIES=""

- php: 5.6
- php: 7.1
env: SYMFONY_PHPUNIT_VERSION=7
- php: 7.2
- php: 7.3
- php: 7.4
env: DOCCHECK=true COVERAGE=true PHPUNIT_FLAGS="-v --coverage-text" VARNISH_MODULES_VERSION=0.12.1

# Test with Varnish 4
- php: 7.3
- php: 7.4
env: VARNISH_VERSION=4.1 VARNISH_MODULES_VERSION=0.9.1

# Test Symfony LTS versions
- php: 7.3
# Test PHPUnit versions
- php: 7.4
env: SYMFONY_PHPUNIT_VERSION=6

# Test SYMFONY LTS versions
- php: 7.4
env: DEPENDENCIES="symfony/lts:^3 toflar/psr6-symfony-http-cache-store:^2.2.0"
- php: 7.3
- php: 7.4
env: DEPENDENCIES="symfony/flex" SYMFONY_VERSION="^4"

# Latest commit to master
- php: 7.3
- php: 7.4
env: STABILITY="dev"

allow_failures:
Expand Down Expand Up @@ -73,7 +80,7 @@ before_script:

script:
- composer validate --strict --no-check-lock
- vendor/bin/phpunit $PHPUNIT_FLAGS
- vendor/bin/simple-phpunit $PHPUNIT_FLAGS
- if [[ "$DOCCHECK" = true ]]; then make -C doc SPHINXOPTS='-nW' html; fi
- if [[ "$DOCCHECK" = true ]]; then make -C doc spelling; fi

Expand Down
11 changes: 6 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ Changelog

See also the [GitHub releases page](https://github.com/FriendsOfSymfony/FOSHttpCache/releases).

2.8.1
2.9.0
-----

### General

* Removed PHP 7.0 compatibility
* Raised minimal PHP version to 7.1
* Test helper classes upgraded to support PHPUnit 7/8

### Symfony HttpCache

Expand Down Expand Up @@ -98,7 +99,7 @@ See also the [GitHub releases page](https://github.com/FriendsOfSymfony/FOSHttpC

* Added: `CleanupCacheTagsListener` to remove the cache tags header from the final
response that is sent to the client. Add this listener to your cache kernel.

### Cache Tagging

* Improved: The `ResponseTagger` does now remove duplicate tags.
Expand Down Expand Up @@ -256,7 +257,7 @@ See also the [GitHub releases page](https://github.com/FriendsOfSymfony/FOSHttpC

* Varnish configuration are now files that you can directly include from your
.vcl and call custom functions to avoid copy-pasting VCL code.
* Added support for and changed default to Varnish version 5.
* Added support for and changed default to Varnish version 5.
* Moved Varnish 4 and 5 configuration files from `resources/config/varnish-4/`
to `resources/config/varnish/`.
* Changed default Varnish version to 5.
Expand All @@ -280,7 +281,7 @@ See also the [GitHub releases page](https://github.com/FriendsOfSymfony/FOSHttpC
`AppCache extends EventDispatchingHttpInterface` with a
`use EventDispatchingHttpCache;` statement.
* The user context by default does not use a hardcoded hash for anonymous users
but does a hash lookup. You can still configure a hardcoded hash.
but does a hash lookup. You can still configure a hardcoded hash.

### Testing

Expand Down
11 changes: 6 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
}
],
"require": {
"php": "^5.6 || ^7.1.0",
"php": "^7.1",
"symfony/event-dispatcher": "^3.4 || ^4.3 || ^5.0",
"symfony/options-resolver": "^3.4 || ^4.3 || ^5.0",
"php-http/client-implementation": "^1.0 || ^2.0",
Expand All @@ -30,20 +30,21 @@
"php-http/discovery": "^1.0"
},
"require-dev": {
"mockery/mockery": "~0.9.5",
"mockery/mockery": "^1.3.1",
"monolog/monolog": "^1.0",
"php-http/guzzle6-adapter": "^1.0 || ^2.0",
"php-http/mock-client": "^1.2",
"phpunit/phpunit": "^5.7 || ^6.0",
"symfony/process": "^3.4 || ^4.3 || ^5.0",
"symfony/http-kernel": "^3.4 || ^4.3 || ^5.0"
"symfony/http-kernel": "^3.4 || ^4.3 || ^5.0",
"symfony/phpunit-bridge": "^5.0"
},
"conflict": {
"toflar/psr6-symfony-http-cache-store": "<2.2.1"
},
"suggest": {
"friendsofsymfony/http-cache-bundle": "For integration with the Symfony framework",
"monolog/monolog": "For logging issues while invalidating"
"monolog/monolog": "For logging issues while invalidating",
"phpunit/phpunit": "Functional tests for your cache invalidation system, 5.7 || 6.0 || 7.0 || 8.0"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
syntaxCheck="true">
>
<testsuites>
<testsuite name="FOSHttpCache tests">
<directory suffix="Test.php">./tests/</directory>
Expand Down
4 changes: 2 additions & 2 deletions src/Test/CacheAssertions.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ trait CacheAssertions
* @param ResponseInterface $response
* @param string $message Test failure message (optional)
*/
public function assertMiss(ResponseInterface $response, $message = null)
public function assertMiss(ResponseInterface $response, $message = '')
{
TestCase::assertThat($response, self::isCacheMiss(), $message);
}
Expand All @@ -45,7 +45,7 @@ public function assertMiss(ResponseInterface $response, $message = null)
* @param ResponseInterface $response
* @param string $message Test failure message (optional)
*/
public function assertHit(ResponseInterface $response, $message = null)
public function assertHit(ResponseInterface $response, $message = '')
{
TestCase::assertThat($response, self::isCacheHit(), $message);
}
Expand Down
153 changes: 153 additions & 0 deletions src/Test/Legacy/WebServerListener6.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
<?php

/*
* This file is part of the FOSHttpCache package.
*
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace FOS\HttpCache\Test\Legacy;

use FOS\HttpCache\Test\WebServerListenerTrait;
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\Test;
use PHPUnit\Framework\TestListener;
use PHPUnit\Framework\TestSuite;
use PHPUnit\Framework\Warning;

/**
* A PHPUnit test listener that starts and stops the PHP built-in web server.
*
* This legacy version is for PHPUnit 6.x.
*
* This listener is configured with a couple of constants from the phpunit.xml
* file. To define constants in the phpunit file, use this syntax:
* <php>
* <const name="WEB_SERVER_HOSTNAME" value="localhost" />
* </php>
*
* WEB_SERVER_HOSTNAME host name of the web server (required)
* WEB_SERVER_PORT port to listen on (required)
* WEB_SERVER_DOCROOT path to the document root for the server (required)
*/
class WebServerListener6 implements TestListener
{
/** @var WebServerListenerTrait */
private $trait;

public function __construct()
{
$this->trait = new WebServerListenerTrait();
}

/**
* Make sure the PHP built-in web server is running for tests with group
* 'webserver'.
*/
public function startTestSuite(TestSuite $suite)
{
$this->trait->startTestSuite($suite);
}

/**
* We don't need these.
*/
public function endTestSuite(TestSuite $suite)
{
}

public function addError(Test $test, \Exception $e, $time)
{
}

public function addFailure(Test $test, AssertionFailedError $e, $time)
{
}

public function addIncompleteTest(Test $test, \Exception $e, $time)
{
}

public function addSkippedTest(Test $test, \Exception $e, $time)
{
}

public function startTest(Test $test)
{
}

public function endTest(Test $test, $time)
{
}

public function addRiskyTest(Test $test, \Exception $e, $time)
{
}

public function addWarning(Test $test, Warning $e, $time)
{
}

/**
* Get web server hostname.
*
* @throws \Exception
*
* @return string
*/
protected function getHostName()
{
return $this->trait->getHostName();
}

/**
* Get web server port.
*
* @throws \Exception
*
* @return int
*/
protected function getPort()
{
return $this->trait->getPort();
}

/**
* Get web server port.
*
* @throws \Exception
*
* @return int
*/
protected function getDocRoot()
{
return $this->trait->getDocRoot();
}

/**
* Start PHP built-in web server.
*
* @return int PID
*/
protected function startPhpWebServer()
{
return $this->trait->startPhpWebServer();
}

/**
* Wait for caching proxy to be started up and reachable.
*
* @param string $ip
* @param int $port
* @param int $timeout Timeout in milliseconds
*
* @throws \RuntimeException If proxy is not reachable within timeout
*/
protected function waitFor($ip, $port, $timeout)
{
$this->trait->waitFor($ip, $port, $timeout);
}
}
4 changes: 2 additions & 2 deletions src/Test/NginxTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ trait NginxTest
*/
protected $proxy;

protected function setUp()
protected function setUp(): void
{
$this->getProxy()->clear();
}

protected function tearDown()
protected function tearDown(): void
{
$this->getProxy()->stop();
}
Expand Down
9 changes: 6 additions & 3 deletions src/Test/PHPUnit/AbstractCacheConstraintTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace FOS\HttpCache\Test\PHPUnit;

use PHPUnit\Runner\Version;
use Psr\Http\Message\ResponseInterface;

/**
Expand All @@ -31,15 +32,17 @@ public function __construct($header = null)
$this->header = $header;
}

parent::__construct();
if (version_compare(Version::id(), '8.0.0', '<')) {
parent::__construct();
}
}

/**
* {@inheritdoc}
*
* @param ResponseInterface $other The guzzle response object
*/
public function matches($other)
public function matches($other): bool
{
if (!$other instanceof ResponseInterface) {
throw new \RuntimeException(sprintf('Expected a GuzzleHttp\Psr7\Response but got %s', get_class($other)));
Expand Down Expand Up @@ -75,7 +78,7 @@ public function matches($other)
/**
* {@inheritdoc}
*/
public function failureDescription($other)
public function failureDescription($other): string
{
return sprintf(
'response (with status code %s) %s',
Expand Down
2 changes: 1 addition & 1 deletion src/Test/PHPUnit/IsCacheHitConstraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class IsCacheHitConstraint extends AbstractCacheConstraint
/**
* {@inheritdoc}
*/
public function toString()
public function toString(): string
{
return 'is a cache hit';
}
Expand Down
2 changes: 1 addition & 1 deletion src/Test/PHPUnit/IsCacheMissConstraint.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class IsCacheMissConstraint extends AbstractCacheConstraint
/**
* {@inheritdoc}
*/
public function toString()
public function toString(): string
{
return 'is a cache miss';
}
Expand Down
2 changes: 1 addition & 1 deletion src/Test/SymfonyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ trait SymfonyTest
*
* @throws \Exception
*/
protected function setUp()
protected function setUp(): void
{
$this->getProxy()->clear();
}
Expand Down

0 comments on commit 1658d8a

Please sign in to comment.