Skip to content

Commit 9489ab2

Browse files
authored
Update test matrix, bump minimium requirements (#19)
1 parent f582f29 commit 9489ab2

File tree

6 files changed

+59
-81
lines changed

6 files changed

+59
-81
lines changed

.github/workflows/lock-symfony-version.sh

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/workflows/tests.yml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,32 @@ on:
66
- master
77
pull_request:
88

9-
env:
10-
SYMFONY_DEPRECATIONS_HELPER: weak
11-
129
jobs:
1310
PHPUnit:
1411
runs-on: ubuntu-22.04
1512
strategy:
1613
fail-fast: false
1714
matrix:
1815
include:
19-
- { php-version: 8.1, symfony-locked-version: none, dependency-version: prefer-lowest }
20-
- { php-version: 8.2, symfony-locked-version: 6.4.*, dependency-version: prefer-stable }
21-
- { php-version: 8.3, symfony-locked-version: none, dependency-version: prefer-stable }
22-
name: PHPUnit (PHP ${{matrix.php-version}}, Symfony Version Lock ${{ matrix.symfony-locked-version }}, ${{ matrix.dependency-version }})
16+
- { php-version: 8.1, symfony-version: '', dependency-version: prefer-lowest }
17+
- { php-version: 8.3, symfony-version: 6.4.*, dependency-version: prefer-stable }
18+
- { php-version: 8.4, symfony-version: 7.*, dependency-version: prefer-stable }
19+
name: PHPUnit (PHP ${{matrix.php-version}}, Symfony version lock ${{ matrix.symfony-version || 'none' }}, ${{ matrix.dependency-version }})
2320
steps:
2421
- uses: actions/checkout@v4
2522
- uses: shivammathur/setup-php@v2
2623
with:
2724
php-version: ${{ matrix.php-version }}
2825
coverage: none
29-
tools: composer:v2
26+
tools: composer:v2, flex
3027
- uses: actions/cache@v4
3128
with:
3229
path: vendor
33-
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.symfony-locked-version }}-${{ matrix.dependency-version }}-${{ hashFiles('composer.json') }}
30+
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ matrix.dependency-version }}-${{ hashFiles('composer.json') }}
3431
restore-keys: |
35-
composer-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.symfony-locked-version }}-${{ matrix.dependency-version }}-
36-
- run: VERSION=${{ matrix.symfony-locked-version }} .github/workflows/lock-symfony-version.sh
37-
if: matrix.symfony-locked-version != 'none'
32+
composer-${{ runner.os }}-${{ matrix.php-version }}-${{ matrix.symfony-version }}-${{ matrix.dependency-version }}-
3833
- run: composer update --${{ matrix.dependency-version }} --no-interaction --no-scripts --no-progress --ansi
34+
env:
35+
SYMFONY_REQUIRE: ${{ matrix.symfony-version }}
3936
- run: composer show
40-
- run: vendor/bin/phpunit
37+
- run: vendor/bin/phpunit --display-warnings --display-deprecations

composer.json

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,16 @@
1919
],
2020

2121
"require": {
22-
"php": "^8.1",
23-
"symfony/config": "^5.0 | ^6.0 | ^7.0",
24-
"symfony/dependency-injection": "^5.0 | ^6.0 | ^7.0",
25-
"symfony/deprecation-contracts": "^2.0|^3.0",
26-
"symfony/http-foundation": "^5.0 | ^6.0 | ^7.0",
27-
"symfony/http-kernel": "^6.4 | ^7.0"
22+
"php": ">= 8.1",
23+
"symfony/config": "^6.4|^7.0",
24+
"symfony/dependency-injection": "^6.4|^7.0",
25+
"symfony/deprecation-contracts": "^3.0",
26+
"symfony/http-foundation": "^6.4|^7.0",
27+
"symfony/http-kernel": "^6.4|^7.0"
2828
},
2929

3030
"require-dev": {
31-
"phpunit/phpunit": "^9.6",
32-
"symfony/phpunit-bridge": "^6.0 | ^7.0"
31+
"phpunit/phpunit": "^10.5.58"
3332
},
3433

3534
"suggest": {

phpunit.xml.dist

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd">
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd"
5+
bootstrap="vendor/autoload.php"
6+
colors="true"
7+
displayDetailsOnTestsThatTriggerDeprecations="true"
8+
displayDetailsOnTestsThatTriggerNotices="true"
9+
displayDetailsOnTestsThatTriggerWarnings="true"
10+
>
11+
<source ignoreSuppressionOfDeprecations="true">
12+
<include>
13+
<directory>src</directory>
14+
</include>
15+
</source>
516
<testsuites>
617
<testsuite name="Library Test Suite">
718
<directory>tests</directory>
819
</testsuite>
920
</testsuites>
10-
11-
<!-- Filter for code coverage -->
12-
<filter>
13-
<whitelist processUncoveredFilesFromWhitelist="true">
14-
<directory suffix=".php">src/</directory>
15-
</whitelist>
16-
</filter>
17-
18-
<listeners>
19-
<listener class="\Symfony\Bridge\PhpUnit\SymfonyTestsListener" />
20-
</listeners>
2121
</phpunit>

tests/NotModified/Attribute/ReplaceWithNotModifiedResponseTest.php

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
namespace Webfactory\HttpCacheBundle\Tests\NotModified\Attribute;
1111

1212
use DateTime;
13+
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
14+
use PHPUnit\Framework\Attributes\Group;
15+
use PHPUnit\Framework\Attributes\Test;
1316
use PHPUnit\Framework\MockObject\MockObject;
1417
use PHPUnit\Framework\TestCase;
1518
use RuntimeException;
@@ -23,30 +26,23 @@
2326
*/
2427
final class ReplaceWithNotModifiedResponseTest extends TestCase
2528
{
26-
/**
27-
* @test
28-
*/
29+
#[Test]
2930
public function lastModifiedDescriptionsCannotBeEmpty()
3031
{
3132
$this->expectException(RuntimeException::class);
3233
$attribute = new ReplaceWithNotModifiedResponse([]);
3334
$attribute->determineLastModified(new Request());
3435
}
3536

36-
/**
37-
* @test
38-
*
39-
* @doesNotPerformAssertions
40-
*/
37+
#[Test]
38+
#[DoesNotPerformAssertions]
4139
public function stringAsSimpleLastModifiedDescription()
4240
{
4341
$attribute = new ReplaceWithNotModifiedResponse([MyLastModifedDeterminator::class]);
4442
$attribute->determineLastModified(new Request());
4543
}
4644

47-
/**
48-
* @test
49-
*/
45+
#[Test]
5046
public function serviceNameAsLastModifiedDescription()
5147
{
5248
/** @var ContainerInterface|MockObject $container */
@@ -62,32 +58,24 @@ public function serviceNameAsLastModifiedDescription()
6258
$attribute->determineLastModified(new Request());
6359
}
6460

65-
/**
66-
* @test
67-
*
68-
* @doesNotPerformAssertions
69-
*/
61+
#[Test]
62+
#[DoesNotPerformAssertions]
7063
public function arrayAslastModifiedDeterminatorDescriptionWithConstructorArguments()
7164
{
7265
$attribute = new ReplaceWithNotModifiedResponse([[MyLastModifedDeterminator::class => new DateTime('2000-01-01')]]);
7366
$attribute->determineLastModified(new Request());
7467
}
7568

76-
/**
77-
* @test
78-
*/
69+
#[Test]
7970
public function lastModifiedDeterminatorsHaveToImplementInterface()
8071
{
8172
$this->expectException(RuntimeException::class);
8273
$attribute = new ReplaceWithNotModifiedResponse([FakeLastModifiedDeterminatorWithoutInterface::class]);
8374
$attribute->determineLastModified(new Request());
8475
}
8576

86-
/**
87-
* @test
88-
*
89-
* @group time-sensitive
90-
*/
77+
#[Group('time-sensitive')]
78+
#[Test]
9179
public function determineLastModifiedDeterminesLastModifiedOfOneDeterminator()
9280
{
9381
$attribute = new ReplaceWithNotModifiedResponse([MyLastModifedDeterminator::class]);
@@ -97,9 +85,7 @@ public function determineLastModifiedDeterminesLastModifiedOfOneDeterminator()
9785
self::assertEquals(DateTime::createFromFormat('U', time()), $lastModified);
9886
}
9987

100-
/**
101-
* @test
102-
*/
88+
#[Test]
10389
public function determineLastModifiedDeterminesLastModifiedOfMultipleDeterminators()
10490
{
10591
$attribute = new ReplaceWithNotModifiedResponse([

tests/NotModified/EventListenerTest.php

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
use Closure;
1313
use DateTime;
1414
use Error;
15+
use PHPUnit\Framework\Attributes\Group;
16+
use PHPUnit\Framework\Attributes\Test;
1517
use PHPUnit\Framework\MockObject\MockObject;
1618
use PHPUnit\Framework\TestCase;
1719
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -27,9 +29,8 @@
2729

2830
/**
2931
* Tests for the EventListener.
30-
*
31-
* @group time-sensitive
3232
*/
33+
#[Group('time-sensitive')]
3334
final class EventListenerTest extends TestCase
3435
{
3536
/**
@@ -53,31 +54,31 @@ protected function setUp(): void
5354
$this->eventListener = new EventListener($this->container);
5455
}
5556

56-
/** @test */
57+
#[Test]
5758
public function onKernelControllerDoesNoHarmForMissingAnnotation(): void
5859
{
5960
$this->exerciseOnKernelController([DummyController::class, 'plainAction']);
6061

6162
$this->assertRegularControllerResponse();
6263
}
6364

64-
/** @test */
65+
#[Test]
6566
public function onKernelControllerDoesNoHarmForNoDeterminedLastModified(): void
6667
{
6768
$this->exerciseOnKernelController([DummyController::class, 'abstainingLastModifiedAction']);
6869

6970
$this->assertRegularControllerResponse();
7071
}
7172

72-
/** @test */
73+
#[Test]
7374
public function onKernelControllerDoesNoHarmIfNotModifiedSinceHeaderIsNotInRequest(): void
7475
{
7576
$this->exerciseOnKernelController([DummyController::class, 'oneDayAgoModifiedLastModifiedAction']);
7677

7778
$this->assertRegularControllerResponse();
7879
}
7980

80-
/** @test */
81+
#[Test]
8182
public function onKernelControllerSkipsToModifiedResponseIfLastModifiedIsSmallerThanIfNotModifiedSinceHeader(): void
8283
{
8384
$this->request->headers->set('If-Modified-Since', '-1 hour');
@@ -87,7 +88,7 @@ public function onKernelControllerSkipsToModifiedResponseIfLastModifiedIsSmaller
8788
$this->assertNotModifiedResponse();
8889
}
8990

90-
/** @test */
91+
#[Test]
9192
public function onKernelControllerAlwaysRunsControllerInKernelDebugMode(): void
9293
{
9394
$this->eventListener = new EventListener($this->container, true);
@@ -98,7 +99,7 @@ public function onKernelControllerAlwaysRunsControllerInKernelDebugMode(): void
9899
$this->assertRegularControllerResponse();
99100
}
100101

101-
/** @test */
102+
#[Test]
102103
public function onKernelControllerSkipsToNotModifiedResponseIfLastModifiedIsEqualToIfNotModifiedSinceHeader(): void
103104
{
104105
$this->request->headers->set('If-Modified-Since', '2000-01-01');
@@ -108,7 +109,7 @@ public function onKernelControllerSkipsToNotModifiedResponseIfLastModifiedIsEqua
108109
$this->assertNotModifiedResponse();
109110
}
110111

111-
/** @test */
112+
#[Test]
112113
public function onKernelControllerDoesNotReplaceDeterminedControllerIfLastModifiedIsGreaterThanIfNotModifiedSinceHeader(): void
113114
{
114115
$this->request->headers->set('If-Modified-Since', '-2 day');
@@ -118,9 +119,7 @@ public function onKernelControllerDoesNotReplaceDeterminedControllerIfLastModifi
118119
$this->assertRegularControllerResponse();
119120
}
120121

121-
/**
122-
* @test
123-
*/
122+
#[Test]
124123
public function onKernelResponseSetsLastModifiedHeaderToResponseIfAvailable(): void
125124
{
126125
$this->exerciseOnKernelController([DummyController::class, 'oneDayAgoModifiedLastModifiedAction']);
@@ -131,7 +130,7 @@ public function onKernelResponseSetsLastModifiedHeaderToResponseIfAvailable(): v
131130
self::assertEquals(DateTime::createFromFormat('U', time() - 86400), $this->response->getLastModified());
132131
}
133132

134-
/** @test */
133+
#[Test]
135134
public function onKernelResponseDoesNotSetLastModifiedHeaderToResponseIfNotAvailable(): void
136135
{
137136
$this->exerciseOnKernelController([DummyController::class, 'abstainingLastModifiedAction']);
@@ -142,7 +141,7 @@ public function onKernelResponseDoesNotSetLastModifiedHeaderToResponseIfNotAvail
142141
self::assertNull($this->response->getLastModified());
143142
}
144143

145-
/** @test */
144+
#[Test]
146145
public function eventListenerDifferentiatesBetweenMultipleRequests(): void
147146
{
148147
$this->exerciseOnKernelController([DummyController::class, 'oneDayAgoModifiedLastModifiedAction']);
@@ -160,7 +159,7 @@ public function eventListenerDifferentiatesBetweenMultipleRequests(): void
160159
self::assertNull($anotherResponse->getLastModified());
161160
}
162161

163-
/** @test */
162+
#[Test]
164163
public function onKernelControllerSearchesEventInsteadOfControllerForAttribute(): void
165164
{
166165
// setup an event that should lead to a NotModified response
@@ -186,7 +185,7 @@ function () {
186185
self::assertNotModifiedResponse();
187186
}
188187

189-
/** @test */
188+
#[Test]
190189
public function onKernelControllerSavesOriginalControllerAttributesWhenReplacingTheController(): void
191190
{
192191
$this->request->headers->set('If-Modified-Since', '-1 hour');
@@ -196,7 +195,7 @@ public function onKernelControllerSavesOriginalControllerAttributesWhenReplacing
196195
self::assertNotEmpty($this->filterControllerEvent->getAttributes());
197196
}
198197

199-
/** @test */
198+
#[Test]
200199
public function onKernelControllerThrowsExceptionIfAttributeIsFoundMoreThanOnce(): void
201200
{
202201
self::expectException(Error::class);

0 commit comments

Comments
 (0)