Skip to content

Commit b33571d

Browse files
committed
Upgrade PHPUnit
1 parent 7b89caa commit b33571d

7 files changed

Lines changed: 164 additions & 155 deletions

File tree

.github/workflows/run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ jobs:
4040
SYMFONY_REQUIRE: ${{ matrix.symfony }}
4141

4242
- name: Execute tests
43-
run: vendor/bin/phpunit
43+
run: vendor/bin/phpunit --display-deprecations

.php-cs-fixer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
'@Symfony:risky' => true,
77
'@PHP83Migration' => true,
88
'@PHP82Migration:risky' => true,
9-
'@PHPUnit91Migration:risky' => true,
9+
'@PHPUnit100Migration:risky' => true,
1010
'array_syntax' => ['syntax' => 'short'],
1111
'blank_line_after_opening_tag' => false,
1212
'fopen_flags' => false,

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@
2929
"doctrine/doctrine-bundle": "^2.7",
3030
"fig/log-test": "^1.1",
3131
"guzzlehttp/psr7": "^2.4",
32-
"matthiasnoback/symfony-config-test": "^5.2",
33-
"matthiasnoback/symfony-dependency-injection-test": "^5.1",
32+
"matthiasnoback/symfony-config-test": "^6.1",
33+
"matthiasnoback/symfony-dependency-injection-test": "^6.1",
3434
"phpstan/extension-installer": "^1.2",
3535
"phpstan/phpstan": "2.1.29",
3636
"phpstan/phpstan-phpunit": "2.0.7",
3737
"phpstan/phpstan-symfony": "2.0.8",
38-
"phpunit/phpunit": "9.6.29",
38+
"phpunit/phpunit": "12.3.15",
3939
"psr/cache": "^1.0 || ^2.0 || ^3.0",
4040
"psr/container": "^1.0 || ^2.0",
4141
"psr/http-message": "^1.0 || ^2.0",

phpstan-baseline.neon

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,18 @@ parameters:
234234
count: 1
235235
path: src/Routing/Loader/AttributeLoader.php
236236

237+
-
238+
message: '#^Cannot use array destructuring on \(list\<\(BabDev\\WebSocket\\Server\\WAMP\\WAMPConnection&PHPUnit\\Framework\\MockObject\\MockObject\)\|string\>\)\|null\.$#'
239+
identifier: offsetAccess.nonArray
240+
count: 5
241+
path: tests/Authentication/StorageBackedConnectionRepositoryTest.php
242+
243+
-
244+
message: '#^Cannot use array destructuring on \(list\<\(PHPUnit\\Framework\\MockObject\\MockObject&Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface\)\|string\>\)\|null\.$#'
245+
identifier: offsetAccess.nonArray
246+
count: 5
247+
path: tests/Authentication/StorageBackedConnectionRepositoryTest.php
248+
237249
-
238250
message: '#^Cannot cast mixed to string\.$#'
239251
identifier: cast.string

phpunit.xml.dist

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,9 @@
1111
</testsuite>
1212
</testsuites>
1313

14-
<coverage processUncoveredFiles="true">
14+
<source>
1515
<include>
16-
<directory suffix=".php">./src</directory>
16+
<directory>./src</directory>
1717
</include>
18-
</coverage>
19-
20-
<listeners>
21-
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
22-
</listeners>
23-
24-
<php>
25-
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[direct]=2"/>
26-
</php>
18+
</source>
2719
</phpunit>

tests/Authentication/Provider/SessionAuthenticationProviderTest.php

Lines changed: 10 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace BabDev\WebSocketBundle\Tests\Authentication\Provider;
44

55
use BabDev\WebSocket\Server\Connection;
6-
use BabDev\WebSocket\Server\Connection\AttributeStore;
6+
use BabDev\WebSocket\Server\Connection\ArrayAttributeStore;
77
use BabDev\WebSocketBundle\Authentication\Provider\SessionAuthenticationProvider;
88
use BabDev\WebSocketBundle\Authentication\Storage\TokenStorage;
99
use PHPUnit\Framework\MockObject\MockObject;
@@ -34,17 +34,8 @@ protected function setUp(): void
3434

3535
public function testTheProviderSupportsAConnectionWhenItHasASession(): void
3636
{
37-
/** @var MockObject&AttributeStore $attributeStore */
38-
$attributeStore = $this->createMock(AttributeStore::class);
39-
$attributeStore->expects(self::once())
40-
->method('has')
41-
->with('session')
42-
->willReturn(true);
43-
44-
$attributeStore->expects(self::once())
45-
->method('get')
46-
->with('session')
47-
->willReturn($this->createMock(SessionInterface::class));
37+
$attributeStore = new ArrayAttributeStore();
38+
$attributeStore->set('session', $this->createMock(SessionInterface::class));
4839

4940
/** @var MockObject&Connection $connection */
5041
$connection = $this->createMock(Connection::class);
@@ -56,12 +47,7 @@ public function testTheProviderSupportsAConnectionWhenItHasASession(): void
5647

5748
public function testTheProviderDoesNotSupportAConnectionWhenItDoesNotHaveASession(): void
5849
{
59-
/** @var MockObject&AttributeStore $attributeStore */
60-
$attributeStore = $this->createMock(AttributeStore::class);
61-
$attributeStore->expects(self::once())
62-
->method('has')
63-
->with('session')
64-
->willReturn(false);
50+
$attributeStore = new ArrayAttributeStore();
6551

6652
/** @var MockObject&Connection $connection */
6753
$connection = $this->createMock(Connection::class);
@@ -80,18 +66,9 @@ public function testATokenIsCreatedAndAddedToStorageWhenAGuestUserWithoutASessio
8066
->with('_security_main')
8167
->willReturn(false);
8268

83-
/** @var MockObject&AttributeStore $attributeStore */
84-
$attributeStore = $this->createMock(AttributeStore::class);
85-
$attributeStore->method('get')
86-
->withConsecutive(
87-
['session'],
88-
['resource_id'],
89-
)
90-
->willReturnOnConsecutiveCalls(
91-
$session,
92-
'resource',
93-
'test',
94-
);
69+
$attributeStore = new ArrayAttributeStore();
70+
$attributeStore->set('session', $session);
71+
$attributeStore->set('resource_id', 'resource');
9572

9673
/** @var MockObject&Connection $connection */
9774
$connection = $this->createMock(Connection::class);
@@ -126,17 +103,9 @@ public function testAnAuthenticatedUserFromASharedSessionIsAuthenticated(): void
126103
->with('_security_main')
127104
->willReturn(serialize($token));
128105

129-
/** @var MockObject&AttributeStore $attributeStore */
130-
$attributeStore = $this->createMock(AttributeStore::class);
131-
$attributeStore->method('get')
132-
->withConsecutive(
133-
['session'],
134-
['resource_id'],
135-
)
136-
->willReturnOnConsecutiveCalls(
137-
$session,
138-
'resource',
139-
);
106+
$attributeStore = new ArrayAttributeStore();
107+
$attributeStore->set('session', $session);
108+
$attributeStore->set('resource_id', 'resource');
140109

141110
/** @var MockObject&Connection $connection */
142111
$connection = $this->createMock(Connection::class);

0 commit comments

Comments
 (0)