Skip to content

Commit 1658d8a

Browse files
authored
Merge pull request #472 from FriendsOfSymfony/php-7.4
test with php 7.4
2 parents 5abb500 + e25654e commit 1658d8a

37 files changed

+328
-178
lines changed

.travis.yml

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,33 +8,40 @@ cache:
88
env:
99
global:
1010
- VARNISH_VERSION=5.1
11+
- SYMFONY_PHPUNIT_VERSION=8
12+
- SYMFONY_DEPRECATIONS_HELPER="max[self]=0"
1113
- DEPENDENCIES="toflar/psr6-symfony-http-cache-store:^2.2.0"
1214

1315
matrix:
1416
fast_finish: true
1517
include:
1618
# Minimum supported versions
17-
- php: 5.6
18-
env: VARNISH_VERSION=3.0 COMPOSER_FLAGS="--prefer-lowest" DEPENDENCIES=""
19+
- php: 7.1
20+
env: VARNISH_VERSION=3.0 SYMFONY_PHPUNIT_VERSION=5.7 COMPOSER_FLAGS="--prefer-lowest" DEPENDENCIES=""
1921

20-
- php: 5.6
2122
- php: 7.1
23+
env: SYMFONY_PHPUNIT_VERSION=7
2224
- php: 7.2
2325
- php: 7.3
26+
- php: 7.4
2427
env: DOCCHECK=true COVERAGE=true PHPUNIT_FLAGS="-v --coverage-text" VARNISH_MODULES_VERSION=0.12.1
2528

2629
# Test with Varnish 4
27-
- php: 7.3
30+
- php: 7.4
2831
env: VARNISH_VERSION=4.1 VARNISH_MODULES_VERSION=0.9.1
2932

30-
# Test Symfony LTS versions
31-
- php: 7.3
33+
# Test PHPUnit versions
34+
- php: 7.4
35+
env: SYMFONY_PHPUNIT_VERSION=6
36+
37+
# Test SYMFONY LTS versions
38+
- php: 7.4
3239
env: DEPENDENCIES="symfony/lts:^3 toflar/psr6-symfony-http-cache-store:^2.2.0"
33-
- php: 7.3
40+
- php: 7.4
3441
env: DEPENDENCIES="symfony/flex" SYMFONY_VERSION="^4"
3542

3643
# Latest commit to master
37-
- php: 7.3
44+
- php: 7.4
3845
env: STABILITY="dev"
3946

4047
allow_failures:
@@ -73,7 +80,7 @@ before_script:
7380

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

CHANGELOG.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ Changelog
33

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

6-
2.8.1
6+
2.9.0
77
-----
88

99
### General
1010

11-
* Removed PHP 7.0 compatibility
11+
* Raised minimal PHP version to 7.1
12+
* Test helper classes upgraded to support PHPUnit 7/8
1213

1314
### Symfony HttpCache
1415

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

99100
* Added: `CleanupCacheTagsListener` to remove the cache tags header from the final
100101
response that is sent to the client. Add this listener to your cache kernel.
101-
102+
102103
### Cache Tagging
103104

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

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

285286
### Testing
286287

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
}
2222
],
2323
"require": {
24-
"php": "^5.6 || ^7.1.0",
24+
"php": "^7.1",
2525
"symfony/event-dispatcher": "^3.4 || ^4.3 || ^5.0",
2626
"symfony/options-resolver": "^3.4 || ^4.3 || ^5.0",
2727
"php-http/client-implementation": "^1.0 || ^2.0",
@@ -30,20 +30,21 @@
3030
"php-http/discovery": "^1.0"
3131
},
3232
"require-dev": {
33-
"mockery/mockery": "~0.9.5",
33+
"mockery/mockery": "^1.3.1",
3434
"monolog/monolog": "^1.0",
3535
"php-http/guzzle6-adapter": "^1.0 || ^2.0",
3636
"php-http/mock-client": "^1.2",
37-
"phpunit/phpunit": "^5.7 || ^6.0",
3837
"symfony/process": "^3.4 || ^4.3 || ^5.0",
39-
"symfony/http-kernel": "^3.4 || ^4.3 || ^5.0"
38+
"symfony/http-kernel": "^3.4 || ^4.3 || ^5.0",
39+
"symfony/phpunit-bridge": "^5.0"
4040
},
4141
"conflict": {
4242
"toflar/psr6-symfony-http-cache-store": "<2.2.1"
4343
},
4444
"suggest": {
4545
"friendsofsymfony/http-cache-bundle": "For integration with the Symfony framework",
46-
"monolog/monolog": "For logging issues while invalidating"
46+
"monolog/monolog": "For logging issues while invalidating",
47+
"phpunit/phpunit": "Functional tests for your cache invalidation system, 5.7 || 6.0 || 7.0 || 8.0"
4748
},
4849
"autoload": {
4950
"psr-4": {

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
convertErrorsToExceptions="true"
66
convertNoticesToExceptions="true"
77
convertWarningsToExceptions="true"
8-
syntaxCheck="true">
8+
>
99
<testsuites>
1010
<testsuite name="FOSHttpCache tests">
1111
<directory suffix="Test.php">./tests/</directory>

src/Test/CacheAssertions.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ trait CacheAssertions
3434
* @param ResponseInterface $response
3535
* @param string $message Test failure message (optional)
3636
*/
37-
public function assertMiss(ResponseInterface $response, $message = null)
37+
public function assertMiss(ResponseInterface $response, $message = '')
3838
{
3939
TestCase::assertThat($response, self::isCacheMiss(), $message);
4040
}
@@ -45,7 +45,7 @@ public function assertMiss(ResponseInterface $response, $message = null)
4545
* @param ResponseInterface $response
4646
* @param string $message Test failure message (optional)
4747
*/
48-
public function assertHit(ResponseInterface $response, $message = null)
48+
public function assertHit(ResponseInterface $response, $message = '')
4949
{
5050
TestCase::assertThat($response, self::isCacheHit(), $message);
5151
}
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the FOSHttpCache package.
5+
*
6+
* (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace FOS\HttpCache\Test\Legacy;
13+
14+
use FOS\HttpCache\Test\WebServerListenerTrait;
15+
use PHPUnit\Framework\AssertionFailedError;
16+
use PHPUnit\Framework\Test;
17+
use PHPUnit\Framework\TestListener;
18+
use PHPUnit\Framework\TestSuite;
19+
use PHPUnit\Framework\Warning;
20+
21+
/**
22+
* A PHPUnit test listener that starts and stops the PHP built-in web server.
23+
*
24+
* This legacy version is for PHPUnit 6.x.
25+
*
26+
* This listener is configured with a couple of constants from the phpunit.xml
27+
* file. To define constants in the phpunit file, use this syntax:
28+
* <php>
29+
* <const name="WEB_SERVER_HOSTNAME" value="localhost" />
30+
* </php>
31+
*
32+
* WEB_SERVER_HOSTNAME host name of the web server (required)
33+
* WEB_SERVER_PORT port to listen on (required)
34+
* WEB_SERVER_DOCROOT path to the document root for the server (required)
35+
*/
36+
class WebServerListener6 implements TestListener
37+
{
38+
/** @var WebServerListenerTrait */
39+
private $trait;
40+
41+
public function __construct()
42+
{
43+
$this->trait = new WebServerListenerTrait();
44+
}
45+
46+
/**
47+
* Make sure the PHP built-in web server is running for tests with group
48+
* 'webserver'.
49+
*/
50+
public function startTestSuite(TestSuite $suite)
51+
{
52+
$this->trait->startTestSuite($suite);
53+
}
54+
55+
/**
56+
* We don't need these.
57+
*/
58+
public function endTestSuite(TestSuite $suite)
59+
{
60+
}
61+
62+
public function addError(Test $test, \Exception $e, $time)
63+
{
64+
}
65+
66+
public function addFailure(Test $test, AssertionFailedError $e, $time)
67+
{
68+
}
69+
70+
public function addIncompleteTest(Test $test, \Exception $e, $time)
71+
{
72+
}
73+
74+
public function addSkippedTest(Test $test, \Exception $e, $time)
75+
{
76+
}
77+
78+
public function startTest(Test $test)
79+
{
80+
}
81+
82+
public function endTest(Test $test, $time)
83+
{
84+
}
85+
86+
public function addRiskyTest(Test $test, \Exception $e, $time)
87+
{
88+
}
89+
90+
public function addWarning(Test $test, Warning $e, $time)
91+
{
92+
}
93+
94+
/**
95+
* Get web server hostname.
96+
*
97+
* @throws \Exception
98+
*
99+
* @return string
100+
*/
101+
protected function getHostName()
102+
{
103+
return $this->trait->getHostName();
104+
}
105+
106+
/**
107+
* Get web server port.
108+
*
109+
* @throws \Exception
110+
*
111+
* @return int
112+
*/
113+
protected function getPort()
114+
{
115+
return $this->trait->getPort();
116+
}
117+
118+
/**
119+
* Get web server port.
120+
*
121+
* @throws \Exception
122+
*
123+
* @return int
124+
*/
125+
protected function getDocRoot()
126+
{
127+
return $this->trait->getDocRoot();
128+
}
129+
130+
/**
131+
* Start PHP built-in web server.
132+
*
133+
* @return int PID
134+
*/
135+
protected function startPhpWebServer()
136+
{
137+
return $this->trait->startPhpWebServer();
138+
}
139+
140+
/**
141+
* Wait for caching proxy to be started up and reachable.
142+
*
143+
* @param string $ip
144+
* @param int $port
145+
* @param int $timeout Timeout in milliseconds
146+
*
147+
* @throws \RuntimeException If proxy is not reachable within timeout
148+
*/
149+
protected function waitFor($ip, $port, $timeout)
150+
{
151+
$this->trait->waitFor($ip, $port, $timeout);
152+
}
153+
}

src/Test/NginxTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ trait NginxTest
5151
*/
5252
protected $proxy;
5353

54-
protected function setUp()
54+
protected function setUp(): void
5555
{
5656
$this->getProxy()->clear();
5757
}
5858

59-
protected function tearDown()
59+
protected function tearDown(): void
6060
{
6161
$this->getProxy()->stop();
6262
}

src/Test/PHPUnit/AbstractCacheConstraintTrait.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace FOS\HttpCache\Test\PHPUnit;
1313

14+
use PHPUnit\Runner\Version;
1415
use Psr\Http\Message\ResponseInterface;
1516

1617
/**
@@ -31,15 +32,17 @@ public function __construct($header = null)
3132
$this->header = $header;
3233
}
3334

34-
parent::__construct();
35+
if (version_compare(Version::id(), '8.0.0', '<')) {
36+
parent::__construct();
37+
}
3538
}
3639

3740
/**
3841
* {@inheritdoc}
3942
*
4043
* @param ResponseInterface $other The guzzle response object
4144
*/
42-
public function matches($other)
45+
public function matches($other): bool
4346
{
4447
if (!$other instanceof ResponseInterface) {
4548
throw new \RuntimeException(sprintf('Expected a GuzzleHttp\Psr7\Response but got %s', get_class($other)));
@@ -75,7 +78,7 @@ public function matches($other)
7578
/**
7679
* {@inheritdoc}
7780
*/
78-
public function failureDescription($other)
81+
public function failureDescription($other): string
7982
{
8083
return sprintf(
8184
'response (with status code %s) %s',

src/Test/PHPUnit/IsCacheHitConstraint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class IsCacheHitConstraint extends AbstractCacheConstraint
1616
/**
1717
* {@inheritdoc}
1818
*/
19-
public function toString()
19+
public function toString(): string
2020
{
2121
return 'is a cache hit';
2222
}

src/Test/PHPUnit/IsCacheMissConstraint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class IsCacheMissConstraint extends AbstractCacheConstraint
1616
/**
1717
* {@inheritdoc}
1818
*/
19-
public function toString()
19+
public function toString(): string
2020
{
2121
return 'is a cache miss';
2222
}

0 commit comments

Comments
 (0)